delay setting the window shape until it is realized (slightly modified patch 1935497)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -107,6 +107,9 @@ public:
|
|||||||
// size of WM decorations
|
// size of WM decorations
|
||||||
wxSize m_decorSize;
|
wxSize m_decorSize;
|
||||||
|
|
||||||
|
// shape of the frame
|
||||||
|
wxRegion m_shape;
|
||||||
|
|
||||||
// private gtk_timeout_add result for mimicing wxUSER_ATTENTION_INFO and
|
// private gtk_timeout_add result for mimicing wxUSER_ATTENTION_INFO and
|
||||||
// wxUSER_ATTENTION_ERROR difference, -2 for no hint, -1 for ERROR hint, rest for GtkTimeout handle.
|
// wxUSER_ATTENTION_ERROR difference, -2 for no hint, -1 for ERROR hint, rest for GtkTimeout handle.
|
||||||
int m_urgency_hint;
|
int m_urgency_hint;
|
||||||
|
@@ -107,7 +107,6 @@ public:
|
|||||||
void OnMouseMove(wxMouseEvent& evt);
|
void OnMouseMove(wxMouseEvent& evt);
|
||||||
void OnExit(wxMouseEvent& evt);
|
void OnExit(wxMouseEvent& evt);
|
||||||
void OnPaint(wxPaintEvent& evt);
|
void OnPaint(wxPaintEvent& evt);
|
||||||
void OnWindowCreate(wxWindowCreateEvent& evt);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_hasShape;
|
bool m_hasShape;
|
||||||
@@ -290,12 +289,7 @@ BEGIN_EVENT_TABLE(ShapedFrame, wxFrame)
|
|||||||
EVT_LEFT_UP(ShapedFrame::OnLeftUp)
|
EVT_LEFT_UP(ShapedFrame::OnLeftUp)
|
||||||
EVT_MOTION(ShapedFrame::OnMouseMove)
|
EVT_MOTION(ShapedFrame::OnMouseMove)
|
||||||
EVT_RIGHT_UP(ShapedFrame::OnExit)
|
EVT_RIGHT_UP(ShapedFrame::OnExit)
|
||||||
|
|
||||||
EVT_PAINT(ShapedFrame::OnPaint)
|
EVT_PAINT(ShapedFrame::OnPaint)
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
EVT_WINDOW_CREATE(ShapedFrame::OnWindowCreate)
|
|
||||||
#endif
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@@ -314,14 +308,7 @@ ShapedFrame::ShapedFrame(wxFrame *parent)
|
|||||||
m_bmp = wxBitmap(_T("star.png"), wxBITMAP_TYPE_PNG);
|
m_bmp = wxBitmap(_T("star.png"), wxBITMAP_TYPE_PNG);
|
||||||
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
|
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
|
||||||
SetToolTip(wxT("Right-click to close"));
|
SetToolTip(wxT("Right-click to close"));
|
||||||
|
|
||||||
#ifndef __WXGTK__
|
|
||||||
// On wxGTK we can't do this yet because the window hasn't been created
|
|
||||||
// yet so we wait until the EVT_WINDOW_CREATE event happens. On wxMSW and
|
|
||||||
// wxMac the window has been created at this point so we go ahead and set
|
|
||||||
// the shape now.
|
|
||||||
SetWindowShape();
|
SetWindowShape();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapedFrame::SetWindowShape()
|
void ShapedFrame::SetWindowShape()
|
||||||
@@ -381,11 +368,6 @@ void ShapedFrame::OnPaint(wxPaintEvent& WXUNUSED(evt))
|
|||||||
dc.DrawBitmap(m_bmp, 0, 0, true);
|
dc.DrawBitmap(m_bmp, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapedFrame::OnWindowCreate(wxWindowCreateEvent& WXUNUSED(evt))
|
|
||||||
{
|
|
||||||
SetWindowShape();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// see-through frame
|
// see-through frame
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -324,6 +324,9 @@ gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget),
|
|||||||
win->SetIcon( wxNullIcon );
|
win->SetIcon( wxNullIcon );
|
||||||
win->SetIcons( iconsOld );
|
win->SetIcons( iconsOld );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (win->HasFlag(wxFRAME_SHAPED))
|
||||||
|
win->SetShape(win->m_shape); // it will really set the window shape now
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1164,13 +1167,22 @@ bool wxTopLevelWindowGTK::SetShape(const wxRegion& region)
|
|||||||
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
|
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
|
||||||
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
|
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
|
||||||
|
|
||||||
GdkWindow *window = NULL;
|
if ( GTK_WIDGET_REALIZED(m_widget) )
|
||||||
if (m_wxwindow)
|
|
||||||
{
|
{
|
||||||
|
if ( m_wxwindow )
|
||||||
do_shape_combine_region(m_wxwindow->window, region);
|
do_shape_combine_region(m_wxwindow->window, region);
|
||||||
|
|
||||||
|
return do_shape_combine_region(m_widget->window, region);
|
||||||
|
}
|
||||||
|
else // not realized yet
|
||||||
|
{
|
||||||
|
// store the shape to set, it will be really set once we're realized
|
||||||
|
m_shape = region;
|
||||||
|
|
||||||
|
// we don't know if we're going to succeed or fail, be optimistic by
|
||||||
|
// default
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
window = m_widget->window;
|
|
||||||
return do_shape_combine_region(window, region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowGTK::IsActive()
|
bool wxTopLevelWindowGTK::IsActive()
|
||||||
|
Reference in New Issue
Block a user