writing a dockapp



Hi,
I'am trying to write a dockapp, and I'am having a hard time understanding how the order of some operations influences the result. The following code:
---
wmhints.initial_state = WithdrawnState;
wmhints.icon_window = GDK_WINDOW_XWINDOW(icon_dockapp->window);
wmhints.icon_x = 0;
wmhints.icon_y = 0;
wmhints.window_group = GDK_WINDOW_XWINDOW(status_dockapp->window);
wmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;

gtk_widget_show_all(status_dockapp);

XSetWMHints(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(status_dockapp->window), &wmhints);
---

Gives the following result:
http://62.121.81.182/pub/dock1.png
which is what I want. But why show a window first, and then set it's properties (actually to make it disapear and only leave the apicon)? So let's reverse it:

---
wmhints.initial_state = WithdrawnState;
wmhints.icon_window = GDK_WINDOW_XWINDOW(icon_dockapp->window);
wmhints.icon_x = 0;
wmhints.icon_y = 0;
wmhints.window_group = GDK_WINDOW_XWINDOW(status_dockapp->window);
wmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;

XSetWMHints(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(status_dockapp->window), &wmhints);

gtk_widget_show_all(status_dockapp);
---

Here it is:
http://62.121.81.182/pub/dock2.png
Surprise... none of the properties got set, no icon, no group, no WithdrawnState. There were previos calls to gtk_widget_realize for both status_dockapp and icon_dockapp, so (I hope) it should be perfectly ok to set their properties even if the window is not shown, no?
Ok, but why use Xlib, when we have GTK? Let's make the code prettier:
---
wmhints.initial_state = WithdrawnState;
wmhints.flags = StateHint;

gtk_widget_show_all(status_dockapp);

gdk_window_set_icon(status_dockapp->window, icon_dockapp->window, NULL, NULL);
gdk_window_set_group(status_dockapp->window, status_dockapp->window);
XSetWMHints(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(status_dockapp->window), &wmhints);
---

http://62.121.81.182/pub/dock3.png
Hmm... for some reason gdk functions don't work. Group and icon are non set, Xlib works. But let's switch the order:
---
wmhints.initial_state = WithdrawnState;
wmhints.flags = StateHint;

gtk_widget_show_all(status_dockapp);

XSetWMHints(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(status_dockapp->window), &wmhints); gdk_window_set_icon(status_dockapp->window, icon_dockapp->window, NULL, NULL);
gdk_window_set_group(status_dockapp->window, status_dockapp->window);
---

http://62.121.81.182/pub/dock4.png
Somebody get me a glass of water... group and icon *are* set, but Xlib is no longer capable of setting state to WithdrawnState. It looks, like GDK and XLib don't like each other, the later get's called it wipes out what the other did set, without being told to do so. Why? What am I missing? The big question is how can I create a dockapp using GTK, when I absolutely need to have group, icon and state set and GTK offers me only two functions to do so and prevents me from using Xlib to set the third property?

There are more funny things, if I try to call GTK and Xlib functions *before* the call to gtk_widget_show_all(status_dockapp) then, no matter what order, only GTK functions work. But if the sequence is: GTK, gtk_widget_show_all, Xlib then only Xlib call seems to work. In the order: Xlib, gtk_widget_show_all, GTK, GTK is the winner. I'd be grateful to somebody for explanation what is going on here.

What comes to mind is a new definition of the word 'hacker': a person able to create a dockapp window using GTK even looking at somebody's else work :-).

Tomek Grzejszczyk



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]