Bug 1421974 - refactor nsWindow::HideWindowChrome() to nsWindow::SetWindowDecoration() and share it with nsWindow::SetDrawsInTitlebar, r?jhorak
MozReview-Commit-ID: 3xEdMXq9JvJ
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -5072,47 +5072,42 @@ nsWindow::MakeFullScreen(bool aFullScree
}
NS_ASSERTION(mLastSizeMode != nsSizeMode_Fullscreen,
"mLastSizeMode should never be fullscreen");
return NS_OK;
}
void
-nsWindow::HideWindowChrome(bool aShouldHide)
+nsWindow::SetWindowDecoration(nsBorderStyle aStyle)
{
if (!mShell) {
// Pass the request to the toplevel window
GtkWidget *topWidget = GetToplevelWidget();
if (!topWidget)
return;
nsWindow *topWindow = get_window_for_gtk_widget(topWidget);
if (!topWindow)
return;
- topWindow->HideWindowChrome(aShouldHide);
+ topWindow->SetWindowDecoration(aStyle);
return;
}
// Sawfish, metacity, and presumably other window managers get
// confused if we change the window decorations while the window
// is visible.
bool wasVisible = false;
if (gdk_window_is_visible(mGdkWindow)) {
gdk_window_hide(mGdkWindow);
wasVisible = true;
}
- gint wmd;
- if (aShouldHide)
- wmd = 0;
- else
- wmd = ConvertBorderStyles(mBorderStyle);
-
+ gint wmd = ConvertBorderStyles(aStyle);
if (wmd != -1)
gdk_window_set_decorations(mGdkWindow, (GdkWMDecoration) wmd);
if (wasVisible)
gdk_window_show(mGdkWindow);
// For some window managers, adding or removing window decorations
// requires unmapping and remapping our toplevel window. Go ahead
@@ -5121,16 +5116,22 @@ nsWindow::HideWindowChrome(bool aShouldH
// and GetWindowPos is called)
#ifdef MOZ_X11
XSync(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) , False);
#else
gdk_flush ();
#endif /* MOZ_X11 */
}
+void
+nsWindow::HideWindowChrome(bool aShouldHide)
+{
+ SetWindowDecoration(aShouldHide ? eBorderStyle_none : mBorderStyle);
+}
+
bool
nsWindow::CheckForRollup(gdouble aMouseX, gdouble aMouseY,
bool aIsWheel, bool aAlwaysRollup)
{
nsIRollupListener* rollupListener = GetActiveRollupListener();
nsCOMPtr<nsIWidget> rollupWidget;
if (rollupListener) {
rollupWidget = rollupListener->GetRollupWidget();
@@ -6641,24 +6642,19 @@ nsWindow::SetNonClientMargins(LayoutDevi
void
nsWindow::SetDrawsInTitlebar(bool aState)
{
if (!mIsCSDAvailable || aState == mIsCSDEnabled)
return;
if (mShell) {
- gint wmd;
- if (aState) {
- wmd = GetCSDSupportLevel() == CSD_SUPPORT_FULL ? GDK_DECOR_BORDER : 0;
- } else {
- wmd = ConvertBorderStyles(mBorderStyle);
+ if (GetCSDSupportLevel() == CSD_SUPPORT_FULL) {
+ SetWindowDecoration(aState ? eBorderStyle_border : mBorderStyle);
}
- gdk_window_set_decorations(gtk_widget_get_window(mShell),
- (GdkWMDecoration) wmd);
}
mIsCSDEnabled = aState;
}
gint
nsWindow::GdkScaleFactor()
{
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -430,16 +430,17 @@ protected:
bool mIsX11Display;
private:
void DestroyChildWindows();
GtkWidget *GetToplevelWidget();
nsWindow *GetContainerWindow();
void SetUrgencyHint(GtkWidget *top_window, bool state);
void SetDefaultIcon(void);
+ void SetWindowDecoration(nsBorderStyle aStyle);
void InitButtonEvent(mozilla::WidgetMouseEvent& aEvent,
GdkEventButton* aGdkEvent);
bool DispatchCommandEvent(nsAtom* aCommand);
bool DispatchContentCommandEvent(mozilla::EventMessage aMsg);
bool CheckForRollup(gdouble aMouseX, gdouble aMouseY,
bool aIsWheel, bool aAlwaysRollup);
void CheckForRollupDuringGrab()
{
@@ -448,17 +449,16 @@ private:
bool GetDragInfo(mozilla::WidgetMouseEvent* aMouseEvent,
GdkWindow** aWindow, gint* aButton,
gint* aRootX, gint* aRootY);
void ClearCachedResources();
nsIWidgetListener* GetListener();
bool IsComposited() const;
-
GtkWidget *mShell;
MozContainer *mContainer;
GdkWindow *mGdkWindow;
PlatformCompositorWidgetDelegate* mCompositorWidgetDelegate;
uint32_t mHasMappedToplevel : 1,
mIsFullyObscured : 1,