Make detached handleboxes work when their parent is minimized, porting the

Mon May 31 02:16:37 2004  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkhandlebox.c: Make detached handleboxes work when their
	parent is minimized, porting the fix from 1.2.  (#1923, #57182)

Mon May 31 02:03:17 2004  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkwindow.c (gtk_window_show): Make moving realized,
	unmapped windows work.
This commit is contained in:
Matthias Clasen 2004-05-31 06:29:07 +00:00 committed by Matthias Clasen
parent 83f413b130
commit 684ce0c68b
6 changed files with 132 additions and 38 deletions

View File

@ -1,3 +1,13 @@
Mon May 31 02:16:37 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkhandlebox.c: Make detached handleboxes work when their
parent is minimized, porting the fix from 1.2. (#1923, #57182)
Mon May 31 02:03:17 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwindow.c (gtk_window_show): Make moving realized,
unmapped windows work.
Mon May 31 00:27:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserutils.c (_gtk_file_chooser_set_delegate): Fix

View File

@ -1,3 +1,13 @@
Mon May 31 02:16:37 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkhandlebox.c: Make detached handleboxes work when their
parent is minimized, porting the fix from 1.2. (#1923, #57182)
Mon May 31 02:03:17 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwindow.c (gtk_window_show): Make moving realized,
unmapped windows work.
Mon May 31 00:27:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserutils.c (_gtk_file_chooser_set_delegate): Fix

View File

@ -1,3 +1,13 @@
Mon May 31 02:16:37 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkhandlebox.c: Make detached handleboxes work when their
parent is minimized, porting the fix from 1.2. (#1923, #57182)
Mon May 31 02:03:17 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwindow.c (gtk_window_show): Make moving realized,
unmapped windows work.
Mon May 31 00:27:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserutils.c (_gtk_file_chooser_set_delegate): Fix

View File

@ -1,3 +1,13 @@
Mon May 31 02:16:37 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkhandlebox.c: Make detached handleboxes work when their
parent is minimized, porting the fix from 1.2. (#1923, #57182)
Mon May 31 02:03:17 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkwindow.c (gtk_window_show): Make moving realized,
unmapped windows work.
Mon May 31 00:27:33 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserutils.c (_gtk_file_chooser_set_delegate): Fix

View File

@ -28,6 +28,7 @@
#include <config.h>
#include <stdlib.h>
#include "gtkhandlebox.h"
#include "gtkinvisible.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkwindow.h"
@ -139,6 +140,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;
@ -243,8 +246,6 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
widget_class->size_allocate = gtk_handle_box_size_allocate;
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;
@ -996,6 +997,46 @@ 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
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)
@ -1053,6 +1094,7 @@ gtk_handle_box_button_changed (GtkWidget *widget,
if (event->type == GDK_BUTTON_PRESS) /* Start a drag */
{
GtkHandleBoxPrivate *private = gtk_handle_box_get_private (hb);
GtkWidget *invisible = gtk_handle_box_get_invisible ();
gint desk_x, desk_y;
gint root_x, root_y;
gint width, height;
@ -1060,10 +1102,10 @@ gtk_handle_box_button_changed (GtkWidget *widget,
gdk_window_get_deskrelative_origin (hb->bin_window, &desk_x, &desk_y);
gdk_window_get_origin (hb->bin_window, &root_x, &root_y);
gdk_drawable_get_size (hb->bin_window, &width, &height);
private->orig_x = event->x_root;
private->orig_y = event->y_root;
hb->float_allocation.x = root_x - event->x_root;
hb->float_allocation.y = root_y - event->y_root;
hb->float_allocation.width = width;
@ -1072,28 +1114,43 @@ 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_drawable_get_size (widget->window, &width, &height);
if (gdk_window_is_viewable (widget->window))
{
gdk_window_get_origin (widget->window, &root_x, &root_y);
gdk_drawable_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;
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_for_display (gtk_widget_get_display (widget),
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_grab_add (invisible);
g_signal_connect (invisible, "event",
G_CALLBACK (gtk_handle_box_grab_event), hb);
}
gdk_cursor_unref (fleur);
event_handled = TRUE;
@ -1104,17 +1161,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_display_pointer_ungrab (gtk_widget_get_display (widget),
GDK_CURRENT_TIME);
hb->in_drag = FALSE;
event_handled = TRUE;
}
return event_handled;
}
@ -1123,7 +1169,7 @@ 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;
@ -1131,13 +1177,8 @@ gtk_handle_box_motion (GtkWidget *widget,
GdkGeometry geometry;
GdkScreen *screen, *pointer_screen;
hb = GTK_HANDLE_BOX (widget);
if (!hb->in_drag)
return FALSE;
if (!hb->in_drag || (event->window != widget->window))
return FALSE;
handle_position = effective_handle_position (hb);
/* Calculate the attachment point on the float, if the float
@ -1386,11 +1427,22 @@ gtk_handle_box_reattach (GtkHandleBox *hb)
hb->float_window_mapped = FALSE;
}
if (hb->in_drag)
{
gdk_display_pointer_ungrab (gtk_widget_get_display (GTK_WIDGET (hb)),
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;
gtk_grab_remove (invisible);
gdk_pointer_ungrab (time);
g_signal_handlers_disconnect_by_func (invisible,
G_CALLBACK (gtk_handle_box_grab_event),
hb);
}

View File

@ -3724,9 +3724,11 @@ gtk_window_show (GtkWidget *widget)
* then we created it with widget->allocation anyhow.
*/
if (!was_realized)
gdk_window_resize (widget->window,
configure_request.width,
configure_request.height);
gdk_window_move_resize (widget->window,
configure_request.x,
configure_request.y,
configure_request.width,
configure_request.height);
}
gtk_container_check_resize (container);