summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2001-08-19 02:29:38 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-08-19 02:29:38 +0000
commit922749e5b33ebe39bcf4441682b78adcefb01600 (patch)
tree86f7af8eba459dd8d38812014843df267704e26c
parent9acaa50f599c2e1dcd3c5e16f0eb9629b34701e9 (diff)
downloadmetacity-922749e5b33ebe39bcf4441682b78adcefb01600.tar.gz
hrm, I fixed this wrong the other day. Fixes static gravity when moving
2001-08-18 Havoc Pennington <hp@pobox.com> * src/window.c (meta_window_get_gravity_position): hrm, I fixed this wrong the other day. Fixes static gravity when moving windows.
-rw-r--r--ChangeLog8
-rw-r--r--src/window.c20
-rw-r--r--src/wm-tester/Makefile.am6
-rw-r--r--src/wm-tester/test-gravity.c110
4 files changed, 137 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 94bc75a0..003012d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,16 @@
2001-08-18 Havoc Pennington <hp@pobox.com>
+ * src/window.c (meta_window_get_gravity_position): hrm, I fixed
+ this wrong the other day. Fixes static gravity when moving
+ windows.
+
+2001-08-18 Havoc Pennington <hp@pobox.com>
+
* src/ui.c (meta_image_window_set_position): also set the current
size. Lame hack of the day.
* src/effects.c (effects_draw_box_animation_timeout): use the
- delay exposes feature to avoid the scren dirt
+ delay exposes feature to avoid the screen dirt
* src/ui.c
(meta_ui_push_delay_exposes):
diff --git a/src/window.c b/src/window.c
index e8a0d012..7c0b983d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1616,12 +1616,22 @@ meta_window_get_gravity_position (MetaWindow *window,
w = window->rect.width;
h = window->rect.height;
- if (window->frame == NULL ||
- /* ignore frame for static gravity */
- window->size_hints.win_gravity == StaticGravity)
- frame_extents = window->rect;
+ if (window->size_hints.win_gravity == StaticGravity)
+ {
+ frame_extents = window->rect;
+ if (window->frame)
+ {
+ frame_extents.x = window->frame->rect.x + window->frame->child_x;
+ frame_extents.y = window->frame->rect.y + window->frame->child_y;
+ }
+ }
else
- frame_extents = window->frame->rect;
+ {
+ if (window->frame == NULL)
+ frame_extents = window->rect;
+ else
+ frame_extents = window->frame->rect;
+ }
x = frame_extents.x;
y = frame_extents.y;
diff --git a/src/wm-tester/Makefile.am b/src/wm-tester/Makefile.am
index dc82c646..3cc8eeeb 100644
--- a/src/wm-tester/Makefile.am
+++ b/src/wm-tester/Makefile.am
@@ -4,6 +4,10 @@ INCLUDES=@METACITY_CFLAGS@
wm_tester_SOURCES= \
main.c
-bin_PROGRAMS=wm-tester
+test_gravity_SOURCES= \
+ test-gravity.c
+
+bin_PROGRAMS=wm-tester test-gravity
wm_tester_LDADD= @METACITY_LIBS@
+test_gravity_LDADD= @METACITY_LIBS@ \ No newline at end of file
diff --git a/src/wm-tester/test-gravity.c b/src/wm-tester/test-gravity.c
new file mode 100644
index 00000000..0773af22
--- /dev/null
+++ b/src/wm-tester/test-gravity.c
@@ -0,0 +1,110 @@
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+int gravities[10] = {
+ NorthWestGravity,
+ NorthGravity,
+ NorthEastGravity,
+ WestGravity,
+ CenterGravity,
+ EastGravity,
+ SouthWestGravity,
+ SouthGravity,
+ SouthEastGravity,
+ StaticGravity
+};
+
+Window windows[10];
+
+int x_offset[3] = { 0, -50, -100 };
+int y_offset[3] = { 0, -50, -100 };
+double screen_x_fraction[3] = { 0, 0.5, 1.0 };
+double screen_y_fraction[3] = { 0, 0.5, 1.0 };
+int screen_width;
+int screen_height;
+
+void calculate_position (int i, int *x, int *y)
+{
+ if (i == 9)
+ {
+ *x = 150;
+ *y = 150;
+ }
+ else
+ {
+ *x = screen_x_fraction[i % 3] * screen_width + x_offset[i % 3];
+ *y = screen_y_fraction[i / 3] * screen_height + y_offset[i / 3];
+ }
+}
+
+int main (int argc, char **argv)
+{
+ Display *d;
+ Window w;
+ XSizeHints hints;
+ int i;
+ int screen;
+ XEvent ev;
+
+ d = XOpenDisplay (NULL);
+
+ screen = DefaultScreen (d);
+ screen_width = DisplayWidth (d, screen);
+ screen_height = DisplayHeight (d, screen);
+
+ for (i=0; i<10; i++)
+ {
+ int x, y;
+
+ calculate_position (i, &x, &y);
+
+ w = XCreateSimpleWindow(d, RootWindow(d, screen),
+ x, y, 100, 100, 0,
+ WhitePixel(d, screen), WhitePixel(d, screen));
+
+ windows[i] = w;
+
+ XSelectInput (d, w, ButtonPressMask);
+
+ hints.flags = USPosition | PMinSize | PMaxSize | PWinGravity;
+
+ hints.min_width = 100;
+ hints.min_height = 100;
+ hints.max_width = 200;
+ hints.max_height = 200;
+ hints.win_gravity = gravities[i];
+
+ XSetWMNormalHints (d, w, &hints);
+ XMapWindow (d, w);
+ }
+
+ while (1)
+ {
+ XNextEvent (d, &ev);
+
+ if (ev.xany.type == ButtonPress)
+ {
+ for (i=0; i<10; i++)
+ {
+ if (windows[i] == ev.xbutton.window)
+ {
+ if (ev.xbutton.button == Button1)
+ {
+ int x, y;
+
+ calculate_position (i, &x, &y);
+ w = XMoveWindow (d, windows[i], x, y);
+ }
+ else
+ {
+ w = XResizeWindow (d, windows[i], 200, 200);
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+