diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 15 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 15 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 15 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 15 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 15 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 15 | ||||
-rw-r--r-- | gdk/gdk.h | 3 | ||||
-rw-r--r-- | gdk/gdkglobals.c | 2 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 58 | ||||
-rw-r--r-- | gdk/x11/gdkglobals-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 58 | ||||
-rw-r--r-- | gtk/testgtk.c | 115 | ||||
-rw-r--r-- | tests/testgtk.c | 115 |
14 files changed, 454 insertions, 4 deletions
@@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 2973185416..f4ecaad421 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2973185416..f4ecaad421 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 2973185416..f4ecaad421 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 2973185416..f4ecaad421 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 2973185416..f4ecaad421 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 2973185416..f4ecaad421 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,18 @@ +Sat Sep 25 23:33:55 1998 Tim Janik <timj@gtk.org> + + * gdk/gdkwindow.c (gdk_window_get_root_origin): new function to get + the *real* geometry position of a window, taken possible window + manager offsets into account. + this has been succesfully tested with fvwm, fvwm-2, bowman, olwm, + olvwm, twm, ctwm, mlvwm, windowmaker and enlightenment. + it does fail though for amiwm which adds windows to a pseudo root + window, and for icewm by a small offset because it defines the + geometry position whithin its border. + + * gtk/testgtk.c: added "saved position" test to figure how + gdk_window_get_root_origin() interacts with window managers (repopup + this window to figure ;). + Wed Sep 23 06:09:19 1998 Tim Janik <timj@gtk.org> * configure.in: update to Gtk+ version 1.1.3, binary age 1, @@ -282,6 +282,9 @@ GdkWindowType gdk_window_get_type (GdkWindow *window); gint gdk_window_get_origin (GdkWindow *window, gint *x, gint *y); +void gdk_window_get_root_origin (GdkWindow *window, + gint *x, + gint *y); GdkWindow* gdk_window_get_pointer (GdkWindow *window, gint *x, gint *y, diff --git a/gdk/gdkglobals.c b/gdk/gdkglobals.c index bd8d537852..d21be2f294 100644 --- a/gdk/gdkglobals.c +++ b/gdk/gdkglobals.c @@ -29,7 +29,7 @@ Display *gdk_display = NULL; gint gdk_screen; Window gdk_root_window; Window gdk_leader_window; -GdkWindowPrivate gdk_root_parent; +GdkWindowPrivate gdk_root_parent = { { NULL, }, NULL, }; Atom gdk_wm_delete_window; Atom gdk_wm_take_focus; Atom gdk_wm_protocols; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index afbcdc4cc9..7c2d9b099c 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -208,8 +208,8 @@ gdk_window_init (void) &x, &y, &width, &height, &border_width, &depth); XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes); - gdk_root_parent.xdisplay = gdk_display; gdk_root_parent.xwindow = gdk_root_window; + gdk_root_parent.xdisplay = gdk_display; gdk_root_parent.window_type = GDK_WINDOW_ROOT; gdk_root_parent.window.user_data = NULL; gdk_root_parent.width = width; @@ -1322,6 +1322,62 @@ gdk_window_get_origin (GdkWindow *window, return return_val; } +void +gdk_window_get_root_origin (GdkWindow *window, + gint *x, + gint *y) +{ + GdkWindowPrivate *private; + Window xwindow; + Window xparent; + Window root; + Window *children; + unsigned int nchildren; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + if (x) + *x = 0; + if (y) + *y = 0; + if (private->destroyed) + return; + + while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) + private = (GdkWindowPrivate*) private->parent; + if (private->destroyed) + return; + + xparent = private->xwindow; + do + { + xwindow = xparent; + if (!XQueryTree (private->xdisplay, xwindow, + &root, &xparent, + &children, &nchildren)) + return; + + if (children) + XFree (children); + } + while (xparent != root); + + if (xparent == root) + { + unsigned int ww, wh, wb, wd; + int wx, wy; + + if (XGetGeometry (private->xdisplay, xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) + { + if (x) + *x = wx; + if (y) + *y = wy; + } + } +} + GdkWindow* gdk_window_get_pointer (GdkWindow *window, gint *x, diff --git a/gdk/x11/gdkglobals-x11.c b/gdk/x11/gdkglobals-x11.c index bd8d537852..d21be2f294 100644 --- a/gdk/x11/gdkglobals-x11.c +++ b/gdk/x11/gdkglobals-x11.c @@ -29,7 +29,7 @@ Display *gdk_display = NULL; gint gdk_screen; Window gdk_root_window; Window gdk_leader_window; -GdkWindowPrivate gdk_root_parent; +GdkWindowPrivate gdk_root_parent = { { NULL, }, NULL, }; Atom gdk_wm_delete_window; Atom gdk_wm_take_focus; Atom gdk_wm_protocols; diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index afbcdc4cc9..7c2d9b099c 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -208,8 +208,8 @@ gdk_window_init (void) &x, &y, &width, &height, &border_width, &depth); XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes); - gdk_root_parent.xdisplay = gdk_display; gdk_root_parent.xwindow = gdk_root_window; + gdk_root_parent.xdisplay = gdk_display; gdk_root_parent.window_type = GDK_WINDOW_ROOT; gdk_root_parent.window.user_data = NULL; gdk_root_parent.width = width; @@ -1322,6 +1322,62 @@ gdk_window_get_origin (GdkWindow *window, return return_val; } +void +gdk_window_get_root_origin (GdkWindow *window, + gint *x, + gint *y) +{ + GdkWindowPrivate *private; + Window xwindow; + Window xparent; + Window root; + Window *children; + unsigned int nchildren; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + if (x) + *x = 0; + if (y) + *y = 0; + if (private->destroyed) + return; + + while (private->parent && ((GdkWindowPrivate*) private->parent)->parent) + private = (GdkWindowPrivate*) private->parent; + if (private->destroyed) + return; + + xparent = private->xwindow; + do + { + xwindow = xparent; + if (!XQueryTree (private->xdisplay, xwindow, + &root, &xparent, + &children, &nchildren)) + return; + + if (children) + XFree (children); + } + while (xparent != root); + + if (xparent == root) + { + unsigned int ww, wh, wb, wd; + int wx, wy; + + if (XGetGeometry (private->xdisplay, xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd)) + { + if (x) + *x = wx; + if (y) + *y = wy; + } + } +} + GdkWindow* gdk_window_get_pointer (GdkWindow *window, gint *x, diff --git a/gtk/testgtk.c b/gtk/testgtk.c index f101c15a7a..1c8e9ed376 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -1713,6 +1713,120 @@ create_reparent (void) } /* + * Saved Position + */ +gint upositionx = 0; +gint upositiony = 0; + +static gint +uposition_configure (GtkWidget *window) +{ + GtkLabel *lx; + GtkLabel *ly; + gchar buffer[64]; + + lx = gtk_object_get_data (GTK_OBJECT (window), "x"); + ly = gtk_object_get_data (GTK_OBJECT (window), "y"); + + gdk_window_get_root_origin (window->window, &upositionx, &upositiony); + sprintf (buffer, "%d", upositionx); + gtk_label_set (lx, buffer); + sprintf (buffer, "%d", upositiony); + gtk_label_set (ly, buffer); + + return FALSE; +} + +static void +create_saved_position (void) +{ + static GtkWidget *window = NULL; + + if (!window) + { + GtkWidget *hbox; + GtkWidget *main_vbox; + GtkWidget *vbox; + GtkWidget *x_label; + GtkWidget *y_label; + GtkWidget *button; + GtkWidget *label; + GtkWidget *any; + + window = gtk_widget_new (GTK_TYPE_WINDOW, + "type", GTK_WINDOW_TOPLEVEL, + "signal::configure_event", uposition_configure, NULL, + "x", upositionx, + "y", upositiony, + "title", "Saved Position", + NULL); + + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &window); + + main_vbox = gtk_vbox_new (FALSE, 5); + gtk_container_border_width (GTK_CONTAINER (main_vbox), 0); + gtk_container_add (GTK_CONTAINER (window), main_vbox); + + vbox = + gtk_widget_new (gtk_vbox_get_type (), + "GtkBox::homogeneous", FALSE, + "GtkBox::spacing", 5, + "GtkContainer::border_width", 10, + "GtkWidget::parent", main_vbox, + "GtkWidget::visible", TRUE, + NULL); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + + label = gtk_label_new ("X Origin : "); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); + + x_label = gtk_label_new (""); + gtk_box_pack_start (GTK_BOX (hbox), x_label, TRUE, TRUE, 0); + gtk_object_set_data (GTK_OBJECT (window), "x", x_label); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + + label = gtk_label_new ("Y Origin : "); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); + + y_label = gtk_label_new (""); + gtk_box_pack_start (GTK_BOX (hbox), y_label, TRUE, TRUE, 0); + gtk_object_set_data (GTK_OBJECT (window), "y", y_label); + + any = + gtk_widget_new (gtk_hseparator_get_type (), + "GtkWidget::visible", TRUE, + NULL); + gtk_box_pack_start (GTK_BOX (main_vbox), any, FALSE, TRUE, 0); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (hbox), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0); + + button = gtk_button_new_with_label ("Close"); + gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (window)); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_grab_default (button); + + gtk_widget_show_all (window); + } + else + gtk_widget_destroy (window); +} + +/* * GtkPixmap */ @@ -7621,6 +7735,7 @@ create_main_window (void) { "rc file", create_rc_file }, { "reparent", create_reparent }, { "rulers", create_rulers }, + { "saved position", create_saved_position }, { "scrolled windows", create_scrolled_windows }, { "shapes", create_shapes }, { "spinbutton", create_spins }, diff --git a/tests/testgtk.c b/tests/testgtk.c index f101c15a7a..1c8e9ed376 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -1713,6 +1713,120 @@ create_reparent (void) } /* + * Saved Position + */ +gint upositionx = 0; +gint upositiony = 0; + +static gint +uposition_configure (GtkWidget *window) +{ + GtkLabel *lx; + GtkLabel *ly; + gchar buffer[64]; + + lx = gtk_object_get_data (GTK_OBJECT (window), "x"); + ly = gtk_object_get_data (GTK_OBJECT (window), "y"); + + gdk_window_get_root_origin (window->window, &upositionx, &upositiony); + sprintf (buffer, "%d", upositionx); + gtk_label_set (lx, buffer); + sprintf (buffer, "%d", upositiony); + gtk_label_set (ly, buffer); + + return FALSE; +} + +static void +create_saved_position (void) +{ + static GtkWidget *window = NULL; + + if (!window) + { + GtkWidget *hbox; + GtkWidget *main_vbox; + GtkWidget *vbox; + GtkWidget *x_label; + GtkWidget *y_label; + GtkWidget *button; + GtkWidget *label; + GtkWidget *any; + + window = gtk_widget_new (GTK_TYPE_WINDOW, + "type", GTK_WINDOW_TOPLEVEL, + "signal::configure_event", uposition_configure, NULL, + "x", upositionx, + "y", upositiony, + "title", "Saved Position", + NULL); + + gtk_signal_connect (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &window); + + main_vbox = gtk_vbox_new (FALSE, 5); + gtk_container_border_width (GTK_CONTAINER (main_vbox), 0); + gtk_container_add (GTK_CONTAINER (window), main_vbox); + + vbox = + gtk_widget_new (gtk_vbox_get_type (), + "GtkBox::homogeneous", FALSE, + "GtkBox::spacing", 5, + "GtkContainer::border_width", 10, + "GtkWidget::parent", main_vbox, + "GtkWidget::visible", TRUE, + NULL); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + + label = gtk_label_new ("X Origin : "); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); + + x_label = gtk_label_new (""); + gtk_box_pack_start (GTK_BOX (hbox), x_label, TRUE, TRUE, 0); + gtk_object_set_data (GTK_OBJECT (window), "x", x_label); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + + label = gtk_label_new ("Y Origin : "); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); + + y_label = gtk_label_new (""); + gtk_box_pack_start (GTK_BOX (hbox), y_label, TRUE, TRUE, 0); + gtk_object_set_data (GTK_OBJECT (window), "y", y_label); + + any = + gtk_widget_new (gtk_hseparator_get_type (), + "GtkWidget::visible", TRUE, + NULL); + gtk_box_pack_start (GTK_BOX (main_vbox), any, FALSE, TRUE, 0); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_border_width (GTK_CONTAINER (hbox), 10); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0); + + button = gtk_button_new_with_label ("Close"); + gtk_signal_connect_object (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + GTK_OBJECT (window)); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5); + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_grab_default (button); + + gtk_widget_show_all (window); + } + else + gtk_widget_destroy (window); +} + +/* * GtkPixmap */ @@ -7621,6 +7735,7 @@ create_main_window (void) { "rc file", create_rc_file }, { "reparent", create_reparent }, { "rulers", create_rulers }, + { "saved position", create_saved_position }, { "scrolled windows", create_scrolled_windows }, { "shapes", create_shapes }, { "spinbutton", create_spins }, |