// the frame that is currently active (i.e. its child has focus). It is
// used to generate wxActivateEvents
-static wxTopLevelWindowGTK *g_activeFrame = (wxTopLevelWindowGTK*) NULL;
-static wxTopLevelWindowGTK *g_lastActiveFrame = (wxTopLevelWindowGTK*) NULL;
+static wxTopLevelWindowGTK *g_activeFrame = NULL;
+static wxTopLevelWindowGTK *g_lastActiveFrame = NULL;
// if we detect that the app has got/lost the focus, we set this variable to
// either TRUE or FALSE and an activate event will be sent during the next
wxTopLevelWindow *win )
{
const bool wasIconized = win->IsIconized();
-
win->SetIconizeState(false);
-
if (wasIconized)
{
// Because GetClientSize() returns (0,0) when IsIconized() is true,
win->m_oldClientWidth = 0;
gtk_widget_queue_resize(win->m_wxwindow);
}
-
+ // it is possible for m_isShown to be false here, see bug #9909
+ if (win->wxWindowBase::Show(true))
+ {
+ wxShowEvent eventShow(win->GetId(), true);
+ eventShow.SetEventObject(win);
+ win->GetEventHandler()->ProcessEvent(eventShow);
+ }
return false;
}
}
void wxTopLevelWindowGTK::Init()
{
- m_mainWidget = (GtkWidget*) NULL;
+ m_mainWidget = NULL;
m_isIconized = false;
m_fsIsShowing = false;
m_themeEnabled = true;
m_gdkFunc = 0;
m_grabbed = false;
m_deferShow = true;
+ m_deferShowAllowed = true;
+ m_updateDecorSize = true;
m_urgency_hint = -2;
}
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
// m_wxwindow is the client area
- m_wxwindow = wxPizza::New();
+ m_wxwindow = wxPizza::New(0,this);
gtk_widget_show( m_wxwindow );
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
RemoveGrab();
}
- m_isBeingDeleted = true;
+ SendDestroyEvent();
// it may also be GtkScrolledWindow in the case of an MDI child
if (GTK_IS_WINDOW(m_widget))
// overridden wxWindow methods
// ----------------------------------------------------------------------------
+void wxTopLevelWindowGTK::Refresh( bool WXUNUSED(eraseBackground), const wxRect *WXUNUSED(rect) )
+{
+ wxCHECK_RET( m_widget, wxT("invalid frame") );
+
+ gtk_widget_queue_draw( m_widget );
+
+ if (m_wxwindow && m_wxwindow->window)
+ gdk_window_invalidate_rect( m_wxwindow->window, NULL, TRUE );
+}
+
bool wxTopLevelWindowGTK::Show( bool show )
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
- bool deferShow = show && m_deferShow && !m_isShown;
+ bool deferShow = show && !m_isShown && m_deferShow && m_deferShowAllowed;
if (deferShow)
{
- m_deferShow =
- deferShow = !GTK_WIDGET_REALIZED(m_widget) &&
- gdk_x11_screen_supports_net_wm_hint(
- gtk_widget_get_screen(m_widget),
- gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false)) &&
+ deferShow = false;
+ if (!GTK_WIDGET_REALIZED(m_widget) &&
g_signal_handler_find(m_widget,
GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET),
- 0, NULL, NULL, this);
+ 0, NULL, NULL, this))
+ {
+ if (gdk_x11_screen_supports_net_wm_hint(
+ gtk_widget_get_screen(m_widget),
+ gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false)))
+ {
+ deferShow = true;
+ }
+ else
+ {
+ // Don't allow changes to m_decorSize, it breaks saving/restoring
+ // window size with GetSize()/SetSize() because it makes window
+ // bigger between each restore and save.
+ m_updateDecorSize = false;
+ }
+ }
+ m_deferShow = deferShow;
}
if (deferShow)
{
{
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;
void wxTopLevelWindowGTK::DoSetClientSize(int width, int height)
{
- if (m_deferShow && !m_isShown)
- // Since client size is being explicitly set, don't change it later
- m_deferShow = false;
+ // Since client size is being explicitly set, don't change it later
+ m_deferShowAllowed = false;
+
wxTopLevelWindowBase::DoSetClientSize(width, height);
}
{
if (!IsMaximized() && !IsFullScreen())
GetCachedDecorSize() = decorSize;
- if (m_decorSize != decorSize)
+ if (m_updateDecorSize && m_decorSize != decorSize)
{
const wxSize diff = decorSize - m_decorSize;
m_decorSize = decorSize;
bool new_hint_value = false;
// FIXME: This is a workaround to focus handling problem
- // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle hasn't
- // yet been processed, and the internal focus system is not up to date yet.
- // wxYieldIfNeeded ensures the processing of it, but can have unwanted side effects - MR
- ::wxYieldIfNeeded();
+ // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle
+ // hasn't yet been processed, and the internal focus system is not up to date yet.
+ // YieldFor(wxEVT_CATEGORY_UI) ensures the processing of it (hopefully it
+ // won't have side effects) - MR
+ wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
if(m_urgency_hint >= 0)
g_source_remove(m_urgency_hint);