X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ba5c12cb3346639944fe7d0b47bb38ad3310e4..2a45803fc3877afd0ae3ce356dfe216505165882:/src/gtk/toplevel.cpp?ds=sidebyside diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 4027023d7c..d6ad28c199 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -216,11 +216,12 @@ extern "C" { 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); @@ -269,7 +270,7 @@ gtk_frame_configure_callback( GtkWidget* widget, GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win ) { - if (!win->m_hasVMT || !win->IsShown()) + if (!win->IsShown()) return FALSE; wxPoint point; @@ -343,7 +344,8 @@ gtk_frame_map_callback( GtkWidget*, // 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 @@ -377,11 +379,14 @@ gtk_frame_window_state_callback( GtkWidget* WXUNUSED(widget), // if maximized bit changed and it is now set if (event->changed_mask & event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) { - wxMaximizeEvent event(win->GetId()); - event.SetEventObject(win); - win->HandleWindowEvent(event); + wxMaximizeEvent evt(win->GetId()); + evt.SetEventObject(win); + win->HandleWindowEvent(evt); } + if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) + win->m_fsIsShowing = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0; + return false; } } @@ -595,7 +600,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, G_CALLBACK (gtk_frame_delete_callback), this); // m_mainWidget is a GtkVBox, holding the bars and client area (m_wxwindow) - m_mainWidget = gtk_vbox_new(false, 0); + m_mainWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_show( m_mainWidget ); gtk_widget_set_can_focus(m_mainWidget, false); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); @@ -603,7 +608,7 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, // m_wxwindow is the client area m_wxwindow = wxPizza::New(); gtk_widget_show( m_wxwindow ); - gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); + gtk_box_pack_start(GTK_BOX(m_mainWidget), m_wxwindow, true, true, 0); // we donm't allow the frame to get the focus as otherwise // the frame will grab it at arbitrary focus changes @@ -640,6 +645,14 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, 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. + g_signal_connect (m_widget, "key_press_event", + G_CALLBACK (gtk_window_propagate_key_event), NULL); + #ifdef GDK_WINDOWING_X11 #ifdef __WXGTK3__ if (GDK_IS_X11_SCREEN(gtk_window_get_screen(GTK_WINDOW(m_widget)))) @@ -1022,8 +1035,6 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si { wxCHECK_RET( m_widget, wxT("invalid frame") ); - m_deferShowAllowed = true; - // deal with the position first int old_x = m_x; int old_y = m_y; @@ -1057,11 +1068,14 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si if (m_height < 1) m_height = 1; 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); @@ -1091,6 +1105,8 @@ void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const if ( height ) *height = 0; } + else if (m_useCachedClientSize) + base_type::DoGetClientSize(width, height); else { GTKDoGetSize(width, height); @@ -1148,6 +1164,7 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize) GetCachedDecorSize() = decorSize; if (m_updateDecorSize && m_decorSize != decorSize) { + m_useCachedClientSize = false; const wxSize diff = decorSize - m_decorSize; m_decorSize = decorSize; bool resized = false; @@ -1175,7 +1192,7 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize) 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); } } @@ -1183,7 +1200,7 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize) { // 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);