setting window gravity hints



I'm adding a 'geometry' option to my GTK+ application. After parsing it with
XParseGeometry(), I set the window's size, pos and gravity with
XSetWMNormalHints(). This has to be done before the window is shown,
otherwise the window will pop up at different coordinates determined by GTK.

However, the XSetWMNormalHints() has no effects at all. If the code below
can be rewritten without XSetWMNormalHints to do the same, that would be
great. Being able to set the gravity [which corner of the screen X/Y is
relative to] is _vital_ though. I was able to set size & pos using
gtk_widget_set_{usize,uposition}, but not the gravity.

---
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>

int main(int argc, char **argv)
{
GtkWidget *window;
XSizeHints hints;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(window);

hints.flags = USSize | USPosition | PGravity;
hints.x = 0;
hints.y = 0;
hints.width = 150;
hints.height = 60;
hints.win_gravity = SouthEastGravity;

XSetWMNormalHints(GDK_WINDOW_XDISPLAY(window->window),
GDK_WINDOW_XWINDOW(window->window), &hints);

gtk_widget_show(window);
gtk_main();
}
---

Oskar Liljeblad (osk@hem.passagen.se)





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