}
}
+// ----------------------------------------------------------------------------
+// "key_press_event"
+// ----------------------------------------------------------------------------
+
+extern "C" {
+static gboolean
+wxgtk_tlw_key_press_event(GtkWidget *widget, GdkEventKey *event)
+{
+ GtkWindow* const window = GTK_WINDOW(widget);
+
+ // By default GTK+ checks for the menu accelerators in this (top level)
+ // window first and then propagates the event to the currently focused
+ // child from where it bubbles up the window parent chain. In wxWidgets,
+ // however, we want the child window to have the event first but still
+ // handle it as an accelerator if it's not processed there, so we need to
+ // customize this by reversing the order of the steps done in the standard
+ // GTK+ gtk_window_key_press_event() handler.
+
+ if ( gtk_window_propagate_key_event(window, event) )
+ return TRUE;
+
+ if ( gtk_window_activate_key(window, event) )
+ return TRUE;
+
+ if (GTK_WIDGET_GET_CLASS(widget)->key_press_event(widget, event))
+ return TRUE;
+
+ return FALSE;
+}
+}
+
//-----------------------------------------------------------------------------
// "size_allocate" from m_wxwindow
//-----------------------------------------------------------------------------
static void
size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win)
{
- if (win->m_oldClientWidth != alloc->width ||
- win->m_oldClientHeight != alloc->height)
+ win->m_useCachedClientSize = true;
+ if (win->m_clientWidth != alloc->width ||
+ win->m_clientHeight != alloc->height)
{
- win->m_oldClientWidth = alloc->width;
- win->m_oldClientHeight = alloc->height;
+ win->m_clientWidth = alloc->width;
+ win->m_clientHeight = alloc->height;
GtkAllocation a;
gtk_widget_get_allocation(win->m_widget, &a);
// tlw that was "rolled up" with some WMs.
// Queue a resize rather than sending size event directly to allow
// children to be made visible first.
- win->m_oldClientWidth = 0;
+ win->m_useCachedClientSize = false;
+ win->m_clientWidth = 0;
gtk_widget_queue_resize(win->m_wxwindow);
}
// it is possible for m_isShown to be false here, see bug #9909
g_signal_connect_after (m_widget, "focus_out_event",
G_CALLBACK (gtk_frame_focus_out_callback), this);
- // GTK processes key events at the top level first, which handles for
- // menu accelerators and shortcuts before passing the event on to the
- // focus child window to begin propagation. We want to propagate
- // first, so we connect gtk_window_propagate_key_event to
- // key_press_event.
+ // We need to customize the default GTK+ logic for key processing to make
+ // it conforming to wxWidgets event processing order.
g_signal_connect (m_widget, "key_press_event",
- G_CALLBACK (gtk_window_propagate_key_event), NULL);
+ G_CALLBACK (wxgtk_tlw_key_press_event), NULL);
#ifdef GDK_WINDOWING_X11
#ifdef __WXGTK3__
if (m_width != oldSize.x || m_height != oldSize.y)
{
m_deferShowAllowed = true;
+ m_useCachedClientSize = false;
int w, h;
GTKDoGetSize(&w, &h);
gtk_window_resize(GTK_WINDOW(m_widget), w, h);
- GetClientSize(&m_oldClientWidth, &m_oldClientHeight);
+ DoGetClientSize(&m_clientWidth, &m_clientHeight);
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
HandleWindowEvent(event);
if ( height )
*height = 0;
}
+ else if (m_useCachedClientSize)
+ base_type::DoGetClientSize(width, height);
else
{
GTKDoGetSize(width, height);
GetCachedDecorSize() = decorSize;
if (m_updateDecorSize && m_decorSize != decorSize)
{
+ m_useCachedClientSize = false;
const wxSize diff = decorSize - m_decorSize;
m_decorSize = decorSize;
bool resized = false;
m_height += diff.y;
if (m_width < 1) m_width = 1;
if (m_height < 1) m_height = 1;
- m_oldClientWidth = 0;
+ m_clientWidth = 0;
gtk_widget_queue_resize(m_wxwindow);
}
}
{
// gtk_widget_show() was deferred, do it now
m_deferShow = false;
- GetClientSize(&m_oldClientWidth, &m_oldClientHeight);
+ DoGetClientSize(&m_clientWidth, &m_clientHeight);
wxSizeEvent sizeEvent(GetSize(), GetId());
sizeEvent.SetEventObject(this);
HandleWindowEvent(sizeEvent);