diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-02-23 00:55:46 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-02-23 00:55:46 +0000 |
commit | d7a68f63bef9dd37a21957f4eed1117716de3298 (patch) | |
tree | 4c75c8c5ef78b48f6bb6e320081975635f1ca413 | |
parent | 478449f6cd11fd18ed4d209f5cb473469a7fff02 (diff) | |
download | gdk-pixbuf-d7a68f63bef9dd37a21957f4eed1117716de3298.tar.gz |
Grab on a offscreen GtkInvisible so that we can move handle boxes whose
Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab
on a offscreen GtkInvisible so that we can move handle boxes
whose parents are iconified or on another desktop. Also,
make sure we don't reattach to such parents. (#1923)
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 7 | ||||
-rw-r--r-- | gtk/gtkhandlebox.c | 143 |
8 files changed, 156 insertions, 36 deletions
@@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index e669b4363..08cf177d6 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e669b4363..08cf177d6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e669b4363..08cf177d6 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e669b4363..08cf177d6 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e669b4363..08cf177d6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e669b4363..08cf177d6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Thu Feb 22 19:53:55 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Grab + on a offscreen GtkInvisible so that we can move handle boxes + whose parents are iconified or on another desktop. Also, + make sure we don't reattach to such parents. (#1923) + Thu Feb 22 17:07:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_popup): Don't flip cursor. (#50934) diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index 444582eb5..d25936876 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include "gdk/gdkx.h" #include "gtkhandlebox.h" +#include "gtkinvisible.h" #include "gtkmain.h" #include "gtksignal.h" #include "gtkwindow.h" @@ -128,7 +129,8 @@ static gint gtk_handle_box_motion (GtkWidget *widget, static gint gtk_handle_box_delete_event (GtkWidget *widget, GdkEventAny *event); static void gtk_handle_box_reattach (GtkHandleBox *hb); - +static void gtk_handle_box_end_drag (GtkHandleBox *hb, + guint32 time); static GtkBinClass *parent_class; static guint handle_box_signals[SIGNAL_LAST] = { 0 }; @@ -209,8 +211,6 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class) widget_class->draw = gtk_handle_box_draw; widget_class->expose_event = gtk_handle_box_expose; widget_class->button_press_event = gtk_handle_box_button_changed; - widget_class->button_release_event = gtk_handle_box_button_changed; - widget_class->motion_notify_event = gtk_handle_box_motion; widget_class->delete_event = gtk_handle_box_delete_event; container_class->add = gtk_handle_box_add; @@ -898,6 +898,68 @@ gtk_handle_box_expose (GtkWidget *widget, return FALSE; } +static GtkWidget * +gtk_handle_box_get_invisible (void) +{ + static GtkWidget *handle_box_invisible = NULL; + + if (!handle_box_invisible) + { + handle_box_invisible = gtk_invisible_new (); + gtk_widget_show (handle_box_invisible); + } + + return handle_box_invisible; +} + +static gboolean +window_is_viewable (GdkWindow *window) +{ + GdkWindowPrivate *window_private = (GdkWindowPrivate *)window; + XWindowAttributes xwa; + + while (window_private->parent) + { + GdkWindowPrivate *parent_private = (GdkWindowPrivate *)window_private->parent; + + if (parent_private->window_type == GDK_WINDOW_ROOT || + parent_private->window_type == GDK_WINDOW_FOREIGN) + break; + + window_private = parent_private; + } + + XGetWindowAttributes (window_private->xdisplay, window_private->xwindow, &xwa); + + return xwa.map_state == IsViewable; +} + +static gboolean +gtk_handle_box_grab_event (GtkWidget *widget, + GdkEvent *event, + GtkHandleBox *hb) +{ + switch (event->type) + { + case GDK_BUTTON_RELEASE: + if (hb->in_drag) /* sanity check */ + { + gtk_handle_box_end_drag (hb, event->button.time); + return TRUE; + } + break; + + case GDK_MOTION_NOTIFY: + return gtk_handle_box_motion (GTK_WIDGET (hb), (GdkEventMotion *)event); + break; + + default: + break; + } + + return FALSE; +} + static gint gtk_handle_box_button_changed (GtkWidget *widget, GdkEventButton *event) @@ -955,6 +1017,8 @@ gtk_handle_box_button_changed (GtkWidget *widget, { if (event->type == GDK_BUTTON_PRESS) /* Start a drag */ { + GtkWidget *invisible = gtk_handle_box_get_invisible (); + gint desk_x, desk_y; gint root_x, root_y; gint width, height; @@ -970,28 +1034,41 @@ gtk_handle_box_button_changed (GtkWidget *widget, hb->deskoff_x = desk_x - root_x; hb->deskoff_y = desk_y - root_y; - - gdk_window_get_origin (widget->window, &root_x, &root_y); - gdk_window_get_size (widget->window, &width, &height); - - hb->attach_allocation.x = root_x; - hb->attach_allocation.y = root_y; - hb->attach_allocation.width = width; - hb->attach_allocation.height = height; + + if (window_is_viewable (widget->window)) + { + gdk_window_get_origin (widget->window, &root_x, &root_y); + gdk_window_get_size (widget->window, &width, &height); + + hb->attach_allocation.x = root_x; + hb->attach_allocation.y = root_y; + hb->attach_allocation.width = width; + hb->attach_allocation.height = height; + } + else + { + hb->attach_allocation.x = -1; + hb->attach_allocation.y = -1; + hb->attach_allocation.width = 0; + hb->attach_allocation.height = 0; + } hb->in_drag = TRUE; fleur = gdk_cursor_new (GDK_FLEUR); - if (gdk_pointer_grab (widget->window, + if (gdk_pointer_grab (invisible->window, FALSE, (GDK_BUTTON1_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK), NULL, fleur, - GDK_CURRENT_TIME) != 0) + event->time) != 0) { hb->in_drag = FALSE; } + else + gtk_signal_connect (GTK_OBJECT (invisible), "event", + GTK_SIGNAL_FUNC (gtk_handle_box_grab_event), hb); gdk_cursor_destroy (fleur); event_handled = TRUE; @@ -1002,16 +1079,6 @@ gtk_handle_box_button_changed (GtkWidget *widget, } } } - else if (event->type == GDK_BUTTON_RELEASE && - hb->in_drag) - { - if (event->window != widget->window) - return FALSE; - - gdk_pointer_ungrab (GDK_CURRENT_TIME); - hb->in_drag = FALSE; - event_handled = TRUE; - } return event_handled; } @@ -1020,21 +1087,13 @@ static gint gtk_handle_box_motion (GtkWidget *widget, GdkEventMotion *event) { - GtkHandleBox *hb; + GtkHandleBox *hb = GTK_HANDLE_BOX (widget); gint new_x, new_y; gint snap_edge; gboolean is_snapped = FALSE; - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_HANDLE_BOX (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - hb = GTK_HANDLE_BOX (widget); if (!hb->in_drag) return FALSE; - - if (!hb->in_drag || (event->window != widget->window)) - return FALSE; /* Calculate the attachment point on the float, if the float * were detached @@ -1259,11 +1318,23 @@ gtk_handle_box_reattach (GtkHandleBox *hb) } hb->float_window_mapped = FALSE; } + if (hb->in_drag) - { - gdk_pointer_ungrab (GDK_CURRENT_TIME); - hb->in_drag = FALSE; - } + gtk_handle_box_end_drag (hb, GDK_CURRENT_TIME); gtk_widget_queue_resize (GTK_WIDGET (hb)); } + +static void +gtk_handle_box_end_drag (GtkHandleBox *hb, + guint32 time) +{ + GtkWidget *invisible = gtk_handle_box_get_invisible (); + + hb->in_drag = FALSE; + + gdk_pointer_ungrab (time); + gtk_signal_disconnect_by_func (GTK_OBJECT (invisible), + GTK_SIGNAL_FUNC (gtk_handle_box_grab_event), + hb); +} |