Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-13-2010, 05:27 AM   #1
LQ Newbie
Registered: Jul 2009
Posts: 11

Rep: Reputation: 0
Creating a *top* level window, GTK/GDK/OpenGL...


Is it possible to create a window (with GTK+, GDK, or by using OpenGL, or Clutter) that stays on the top of all the other windows, even over a full-screened window?

I want to create a small window that remains visible when I enter the full-screen mode of a video player (VLC for example).

Thank you in advance!
Old 07-13-2010, 12:36 PM   #2
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
Yes its possible.

First you need to grab the "deskop window" from your window manager or make a fixed window yourself or do it in X directly(not recommende).

Then with that window you have to add a child and raise the window set signals so you lower it or raise it as you want(wen entering, leaving etc) or you can set it so its fixed on top.

its quite a lot of work.
Old 07-17-2010, 04:57 AM   #3
LQ Newbie
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Here I found an example on creating a window with xlib:

Do you think I should get the Display object of the 'VLC media player' window and start drawing on it? Do I need special permissions to do that?

I also tried the following (Clutter and X11 together):

clutter_init (&argc, &argv);
ClutterActor* stage = clutter_stage_new();

// 'p' is the xid of 'VLC media player' main window
// I found 'p' using "xwininfo -root -tree" command
clutter_x11_set_stage_foreign(stage, (Window)(p));
clutter_container_add_actor ((stage, rectangle);
// rectangle is just an object (a ClutterActor, more precisely).
With this, I've got the following run-time error [where 0x4800037 is the xid of VLC's window]:
ClutterGLX-CRITICAL **: Unable to make the stage window 0x4800037 the current GLX drawable

Clutter library is using OpenGL for rendering. Could this be a problem?
Anyway, using Clutter is not actually a 'must'. I haven't try with GTK yet.

Example of what I would like to do: when I watch a video (full screen), I sometimes get notifications from Network Manager (it gives me information regarding the Internet connection). I want to do something similar, I want to draw on the top of the 'fullscreen'.

Is the X11 example from Wikipedia (link above) a good start to do that? Any advice is welcome.

Thank you in advance!
Old 08-27-2010, 08:21 AM   #4
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38

I tried it in gtk and its simple. Here you have some code to play with. Dont forget to compile with `pkg-config --cflags --libs gtk+-2.0`. Most functions are from and Dont forget that the window manager needs to support the functions you use and some of them are only supported in X.

I hope this helps.


#include <stdio.h>
#include <stdlib.h>

#include <gtk/gtk.h>

int main(int argc, char **argv)
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *button;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    g_signal_connect(window, "delete_event", (GCallback)gtk_main_quit, 0);

    vbox = gtk_vbox_new(TRUE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    button = gtk_button_new_with_label("Hide");
    gtk_box_pack_start(GTK_BOX(vbox), button, TRUE,TRUE, 0);
    g_signal_connect_swapped(button, "clicked",
    (GCallback)gtk_widget_hide, window);

    button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
    gtk_box_pack_start(GTK_BOX(vbox), button, TRUE,TRUE, 0);
    g_signal_connect(button, "clicked", (GCallback)gtk_main_quit, 0);

    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);

    // gtk_window_set_default_size(GTK_WINDOW(window),500,500);

    // gtk_window_stick(GTK_WINDOW(window)); /* on all desktops or not */

    gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);


    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE);
    gtk_window_set_skip_pager_hint(GTK_WINDOW(window), TRUE);

    gtk_window_move(GTK_WINDOW(window), 100, 100);

    // gtk_window_set_opacity(GTK_WINDOW(window), 0); /* not working hmmmm*/



    return (EXIT_SUCCESS);

Last edited by kalleanka; 08-27-2010 at 08:25 AM.
1 members found this post helpful.
Old 09-03-2010, 01:40 AM   #5
LQ Newbie
Registered: Jul 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Thank you a lot for your help, kalleanka!
The example works fine

The only problem is that an application running in full screen mode covers the little window. Well, that is not actually a problem, I think I was a little stubborn about creating such a window. I realize now that it isn't really possible. That is, when an application goes into full screen mode, it says: "The screen is only mine now, so... stay away of it!"



fullscreen, gtk, level, opengl, top, window

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the name of the top-level or focused window in KDE narc Linux - Desktop 6 08-30-2008 09:17 AM
pkg-config glib gtk gdk Peterius Linux - Software 6 05-11-2007 02:38 AM
Help on GDK GTK+ programming varun_shrivastava Programming 0 05-07-2007 09:06 AM
how to get window from gdk to gtk? SciYro Programming 1 08-03-2004 09:01 PM
gtk , gdk ????? varunk123456 Linux - Software 7 04-03-2004 01:22 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration