From 410b70f907bc2867770c0f5267004549ee259052 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 17 May 2002 21:44:37 +0000 Subject: [PATCH] Only optimize out the full configure handling if we got a gratuitous Thu May 16 19:49:24 2002 Owen Taylor * gtk/gtkwindow.c (gtk_window_configure_event): Only optimize out the full configure handling if we got a gratuitous configure event(configure_request_count == 0) and the size didn't change. * gtk/gtkwindow.c (gtk_window_move_resize): Use g_message(), not g_print() for debug spew. * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref the old and new focus widgets for the scope of the function. * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd bits of old code. * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. --- ChangeLog | 19 ++++++++ ChangeLog.pre-2-10 | 19 ++++++++ ChangeLog.pre-2-2 | 19 ++++++++ ChangeLog.pre-2-4 | 19 ++++++++ ChangeLog.pre-2-6 | 19 ++++++++ ChangeLog.pre-2-8 | 19 ++++++++ gtk/gtkplug.c | 35 ++------------- gtk/gtksocket.c | 106 +++------------------------------------------ gtk/gtkwindow.c | 94 ++++++++++++++++++++++++++-------------- 9 files changed, 184 insertions(+), 165 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73b281e849..8654985183 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Thu May 16 19:49:24 2002 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_configure_event): Only + optimize out the full configure handling if we got + a gratuitous configure event(configure_request_count == 0) + and the size didn't change. + + * gtk/gtkwindow.c (gtk_window_move_resize): Use + g_message(), not g_print() for debug spew. + + * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref + the old and new focus widgets for the scope of + the function. + + * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd + bits of old code. + + * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. + Fri May 17 14:40:24 2002 Owen Taylor * gtk/gtkimmulticontext.c (gtk_im_multicontext_set_slave): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 73b281e849..8654985183 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,22 @@ +Thu May 16 19:49:24 2002 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_configure_event): Only + optimize out the full configure handling if we got + a gratuitous configure event(configure_request_count == 0) + and the size didn't change. + + * gtk/gtkwindow.c (gtk_window_move_resize): Use + g_message(), not g_print() for debug spew. + + * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref + the old and new focus widgets for the scope of + the function. + + * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd + bits of old code. + + * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. + Fri May 17 14:40:24 2002 Owen Taylor * gtk/gtkimmulticontext.c (gtk_im_multicontext_set_slave): diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 73b281e849..8654985183 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,22 @@ +Thu May 16 19:49:24 2002 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_configure_event): Only + optimize out the full configure handling if we got + a gratuitous configure event(configure_request_count == 0) + and the size didn't change. + + * gtk/gtkwindow.c (gtk_window_move_resize): Use + g_message(), not g_print() for debug spew. + + * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref + the old and new focus widgets for the scope of + the function. + + * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd + bits of old code. + + * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. + Fri May 17 14:40:24 2002 Owen Taylor * gtk/gtkimmulticontext.c (gtk_im_multicontext_set_slave): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 73b281e849..8654985183 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,22 @@ +Thu May 16 19:49:24 2002 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_configure_event): Only + optimize out the full configure handling if we got + a gratuitous configure event(configure_request_count == 0) + and the size didn't change. + + * gtk/gtkwindow.c (gtk_window_move_resize): Use + g_message(), not g_print() for debug spew. + + * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref + the old and new focus widgets for the scope of + the function. + + * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd + bits of old code. + + * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. + Fri May 17 14:40:24 2002 Owen Taylor * gtk/gtkimmulticontext.c (gtk_im_multicontext_set_slave): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 73b281e849..8654985183 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,22 @@ +Thu May 16 19:49:24 2002 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_configure_event): Only + optimize out the full configure handling if we got + a gratuitous configure event(configure_request_count == 0) + and the size didn't change. + + * gtk/gtkwindow.c (gtk_window_move_resize): Use + g_message(), not g_print() for debug spew. + + * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref + the old and new focus widgets for the scope of + the function. + + * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd + bits of old code. + + * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. + Fri May 17 14:40:24 2002 Owen Taylor * gtk/gtkimmulticontext.c (gtk_im_multicontext_set_slave): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 73b281e849..8654985183 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,22 @@ +Thu May 16 19:49:24 2002 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_configure_event): Only + optimize out the full configure handling if we got + a gratuitous configure event(configure_request_count == 0) + and the size didn't change. + + * gtk/gtkwindow.c (gtk_window_move_resize): Use + g_message(), not g_print() for debug spew. + + * gtk/gtkwindow.c (gtk_window_real_set_focus): Ref + the old and new focus widgets for the scope of + the function. + + * gtk/gtksocket.c gtkplug.c: Remove various #if 0'd + bits of old code. + + * gtk/gtksocket.c gtk/gtkplug.c: Enhance debug messages. + Fri May 17 14:40:24 2002 Owen Taylor * gtk/gtkimmulticontext.c (gtk_im_multicontext_set_slave): diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 9791280495..8daa05192d 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -606,23 +606,6 @@ gtk_plug_set_focus (GtkWindow *window, if (focus && !window->has_focus) { -#if 0 - XEvent xevent; - - xevent.xfocus.type = FocusIn; - xevent.xfocus.display = GDK_WINDOW_XDISPLAY (GTK_WIDGET(plug)->window); - xevent.xfocus.window = GDK_WINDOW_XWINDOW (plug->socket_window); - xevent.xfocus.mode = EMBEDDED_APP_WANTS_FOCUS; - xevent.xfocus.detail = FALSE; /* Don't force */ - - gdk_error_trap_push (); - XSendEvent (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (plug->socket_window), - False, NoEventMask, &xevent); - gdk_flush (); - gdk_error_trap_pop (); -#endif - send_xembed_message (plug, XEMBED_REQUEST_FOCUS, 0, 0, 0, gtk_get_current_event_time ()); } @@ -787,19 +770,6 @@ gtk_plug_focus (GtkWidget *widget, send_xembed_message (plug, message, 0, 0, 0, gtk_get_current_event_time ()); - -#if 0 - gtk_window_set_focus (GTK_WINDOW (widget), NULL); - - gdk_error_trap_push (); - XSetInputFocus (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (plug->socket_window), - RevertToParent, event->time); - gdk_flush (); - gdk_error_trap_pop (); - - gtk_plug_forward_key_press (plug, event); -#endif } } @@ -837,6 +807,9 @@ send_xembed_message (GtkPlug *plug, { XEvent xevent; + GTK_NOTE(PLUGSOCKET, + g_message ("GtkPlug: Sending XEMBED message of type %ld", message)); + xevent.xclient.window = GDK_WINDOW_XWINDOW (plug->socket_window); xevent.xclient.type = ClientMessage; xevent.xclient.message_type = gdk_x11_get_xatom_by_name ("_XEMBED"); @@ -928,7 +901,7 @@ handle_xembed_message (GtkPlug *plug, guint32 time) { GTK_NOTE (PLUGSOCKET, - g_message ("Message of type %ld received", message)); + g_message ("GtkPlug: Message of type %ld received", message)); switch (message) { diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index ac978b67f7..d609a4de83 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -125,6 +125,8 @@ gtk_socket_get_private (GtkSocket *socket) if (!private) { private = g_new0 (GtkSocketPrivate, 1); + private->resize_count = 0; + g_object_set_qdata_full (G_OBJECT (socket), private_quark, private, (GDestroyNotify) g_free); } @@ -785,19 +787,6 @@ gtk_socket_focus_out_event (GtkWidget *widget, GdkEventFocus *event) { GtkSocket *socket = GTK_SOCKET (widget); -#if 0 - GtkWidget *toplevel; - toplevel = gtk_widget_get_toplevel (widget); - - if (toplevel && GTK_IS_WINDOW (toplevel)) - { - XSetInputFocus (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (toplevel->window), - RevertToParent, CurrentTime); /* FIXME? */ - } - -#endif - if (socket->plug_window) { send_xembed_message (socket, XEMBED_FOCUS_OUT, 0, 0, 0, @@ -820,20 +809,6 @@ gtk_socket_claim_focus (GtkSocket *socket) GTK_WIDGET_SET_FLAGS (socket, GTK_CAN_FOCUS); gtk_widget_grab_focus (GTK_WIDGET (socket)); GTK_WIDGET_UNSET_FLAGS (socket, GTK_CAN_FOCUS); - - /* FIXME: we might grab the focus even if we don't have - * it as an app... (and see _focus_in ()) */ - if (socket->plug_window) - { -#if 0 - gdk_error_trap_push (); - XSetInputFocus (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (socket->plug_window), - RevertToParent, GDK_CURRENT_TIME); - gdk_flush (); - gdk_error_trap_pop (); -#endif - } } static gboolean @@ -875,66 +850,6 @@ gtk_socket_focus (GtkWidget *widget, GtkDirectionType direction) } else return FALSE; - -#if 0 - if (!socket->focus_in && socket->plug_window) - { - XEvent xevent; - - gtk_socket_claim_focus (socket); - - xevent.xkey.type = KeyPress; - xevent.xkey.display = GDK_DISPLAY (); - xevent.xkey.window = GDK_WINDOW_XWINDOW (socket->plug_window); - xevent.xkey.root = GDK_ROOT_WINDOW (); /* FIXME */ - xevent.xkey.time = GDK_CURRENT_TIME; /* FIXME */ - /* FIXME, the following might cause big problems for - * non-GTK apps */ - xevent.xkey.x = 0; - xevent.xkey.y = 0; - xevent.xkey.x_root = 0; - xevent.xkey.y_root = 0; - xevent.xkey.state = 0; - xevent.xkey.same_screen = TRUE; /* FIXME ? */ - - switch (direction) - { - case GTK_DIR_UP: - xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), GDK_Up); - break; - case GTK_DIR_DOWN: - xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), GDK_Down); - break; - case GTK_DIR_LEFT: - xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), GDK_Left); - break; - case GTK_DIR_RIGHT: - xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), GDK_Right); - break; - case GTK_DIR_TAB_FORWARD: - xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), GDK_Tab); - break; - case GTK_DIR_TAB_BACKWARD: - xevent.xkey.keycode = XKeysymToKeycode(GDK_DISPLAY(), GDK_Tab); - xevent.xkey.state = ShiftMask; - break; - } - - - gdk_error_trap_push (); - XSendEvent (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (socket->plug_window), - False, NoEventMask, &xevent); - gdk_flush(); - gdk_error_trap_pop (); - - return TRUE; - } - else - { - return FALSE; - } -#endif } static void @@ -1206,6 +1121,9 @@ handle_xembed_message (GtkSocket *socket, glong data2, guint32 time) { + GTK_NOTE (PLUGSOCKET, + g_message ("GtkPlug: Message of type %ld received", message)); + switch (message) { case XEMBED_EMBEDDED_NOTIFY: @@ -1395,20 +1313,6 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { gtk_socket_claim_focus (socket); } - else if (xevent->xfocus.detail == NotifyInferior) - { -#if 0 - GtkWidget *toplevel; - toplevel = gtk_widget_get_toplevel (widget); - - if (toplevel && GTK_IS_WINDOW (topelevel)) - { - XSetInputFocus (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (toplevel->window), - RevertToParent, CurrentTime); /* FIXME? */ - } -#endif - } return_val = GDK_FILTER_REMOVE; break; case FocusOut: diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 8c4979a047..be96fa303d 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -69,6 +69,10 @@ enum { PROP_DEFAULT_HEIGHT, PROP_DESTROY_WITH_PARENT, PROP_ICON, + + /* Readonly properties */ + PROP_ACTIVE, + PROP_FOCUS_IN_TOPLEVEL, LAST_ARG }; @@ -3475,6 +3479,7 @@ gtk_window_configure_event (GtkWidget *widget, GdkEventConfigure *event) { GtkWindow *window = GTK_WINDOW (widget); + gboolean expected_reply = window->configure_request_count > 0; /* window->configure_request_count incremented for each * configure request, and decremented to a min of 0 for @@ -3499,7 +3504,7 @@ gtk_window_configure_event (GtkWidget *widget, * notifies and can wait to resize when we get them */ - if (window->configure_request_count > 0 || + if (!expected_reply && (widget->allocation.width == event->width && widget->allocation.height == event->height)) return TRUE; @@ -3843,8 +3848,20 @@ static void gtk_window_real_set_focus (GtkWindow *window, GtkWidget *focus) { + GtkWidget *old_focus = window->focus_widget; gboolean def_flags = 0; + if (old_focus) + { + g_object_ref (old_focus); + g_object_freeze_notify (G_OBJECT (old_focus)); + } + if (focus) + { + g_object_ref (focus); + g_object_freeze_notify (G_OBJECT (focus)); + } + if (window->default_widget) def_flags = GTK_WIDGET_HAS_DEFAULT (window->default_widget); @@ -3884,6 +3901,17 @@ gtk_window_real_set_focus (GtkWindow *window, if (window->default_widget && (def_flags != GTK_WIDGET_FLAGS (window->default_widget))) gtk_widget_queue_draw (window->default_widget); + + if (old_focus) + { + g_object_thaw_notify (G_OBJECT (old_focus)); + g_object_unref (old_focus); + } + if (focus) + { + g_object_thaw_notify (G_OBJECT (focus)); + g_object_unref (focus); + } } /********************************* @@ -4274,38 +4302,38 @@ gtk_window_move_resize (GtkWindow *window) /* this is the position from the last configure notify */ gdk_window_get_position (widget->window, ¬ify_x, ¬ify_y); - g_print ("--- %s ---\n" - "last : %d,%d\t%d x %d\n" - "this : %d,%d\t%d x %d\n" - "alloc : %d,%d\t%d x %d\n" - "req : \t%d x %d\n" - "resize: \t%d x %d\n" - "size_changed: %d pos_changed: %d hints_changed: %d\n" - "configure_notify_received: %d\n" - "configure_request_count: %d\n" - "position_constraints_changed: %d\n", - window->title ? window->title : "(no title)", - info->last.configure_request.x, - info->last.configure_request.y, - info->last.configure_request.width, - info->last.configure_request.height, - new_request.x, - new_request.y, - new_request.width, - new_request.height, - notify_x, notify_y, - widget->allocation.width, - widget->allocation.height, - widget->requisition.width, - widget->requisition.height, - info->resize_width, - info->resize_height, - configure_request_pos_changed, - configure_request_size_changed, - hints_changed, - window->configure_notify_received, - window->configure_request_count, - info->position_constraints_changed); + g_message ("--- %s ---\n" + "last : %d,%d\t%d x %d\n" + "this : %d,%d\t%d x %d\n" + "alloc : %d,%d\t%d x %d\n" + "req : \t%d x %d\n" + "resize: \t%d x %d\n" + "size_changed: %d pos_changed: %d hints_changed: %d\n" + "configure_notify_received: %d\n" + "configure_request_count: %d\n" + "position_constraints_changed: %d\n", + window->title ? window->title : "(no title)", + info->last.configure_request.x, + info->last.configure_request.y, + info->last.configure_request.width, + info->last.configure_request.height, + new_request.x, + new_request.y, + new_request.width, + new_request.height, + notify_x, notify_y, + widget->allocation.width, + widget->allocation.height, + widget->requisition.width, + widget->requisition.height, + info->resize_width, + info->resize_height, + configure_request_pos_changed, + configure_request_size_changed, + hints_changed, + window->configure_notify_received, + window->configure_request_count, + info->position_constraints_changed); } #endif