From 25816c15e3f20ddf954aafbe675af68d9e1ead19 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Tue, 31 May 2005 13:06:39 +0000 Subject: Specify window gravity to help windowmanager with placement of windows on the right or lower border of the screen. Work around a metacity bug in the handling of reconfigure requests. --- zwgc/X_gram.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'zwgc') diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c index 37d78aa..d5879b3 100644 --- a/zwgc/X_gram.c +++ b/zwgc/X_gram.c @@ -100,7 +100,7 @@ void x_set_icccm_hints(dpy,w,name,icon_name,psizehints,pwmhints,main_window) { XStoreName(dpy,w,name); XSetIconName(dpy,w,icon_name); - XSetNormalHints(dpy,w,psizehints); + XSetWMNormalHints(dpy,w,psizehints); XSetWMHints(dpy,w,pwmhints); XSetClassHint(dpy,w,&classhint); /* in order for some wm's to iconify, the window shouldn't be transient. @@ -261,6 +261,24 @@ void x_gram_init(dpy) } } +int x_calc_gravity(xalign, yalign) + int xalign, yalign; +{ + if (yalign > 0) { /* North */ + return (xalign > 0) ? NorthWestGravity + : (xalign == 0) ? NorthGravity + : NorthEastGravity; + } else if (yalign == 0) { /* Center */ + return (xalign > 0) ? WestGravity + : (xalign == 0) ? CenterGravity + : EastGravity; + } else { /* South */ + return (xalign > 0) ? SouthWestGravity + : (xalign == 0) ? SouthGravity + : SouthEastGravity; + } +} + void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize, beepcount) Display *dpy; @@ -309,7 +327,8 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize, sizehints.y = ypos; sizehints.width = xsize; sizehints.height = ysize; - sizehints.flags = USPosition|USSize; + sizehints.win_gravity = x_calc_gravity(xalign, yalign); + sizehints.flags = USPosition|USSize|PWinGravity; wmhints.input = False; wmhints.initial_state = NormalState; @@ -348,6 +367,11 @@ void x_gram_create(dpy, gram, xalign, yalign, xpos, ypos, xsize, ysize, winchanges.sibling=bottom_gram->w; winchanges.stack_mode=Below; + /* Metacity may use border_width even if it's not specified in + * the value mask, so we must initialize it. See: + * http://bugzilla.gnome.org/show_bug.cgi?id=305257 */ + winchanges.border_width=border_width; + begin_xerror_trap (dpy); XReconfigureWMWindow (dpy, w, DefaultScreen (dpy), CWSibling|CWStackMode, &winchanges); -- cgit v1.2.3