Bug 1550721 - Fix GTK title bar for tiled windows. r=stransky,dao

Differential Revision: https://phabricator.services.mozilla.com/D45500

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marius Gedminas 2019-09-17 12:05:00 +00:00
Родитель 2bef84930b
Коммит 1fee916641
7 изменённых файлов: 41 добавлений и 7 удалений

Просмотреть файл

@ -278,12 +278,14 @@ window:not([chromehidden~="toolbar"]) #nav-bar[nonemptyoverflow] > .overflow-but
}
%ifdef MOZ_WIDGET_GTK
@media (-moz-gtk-csd-reversed-placement: 0) {
:root:not([sizemode=normal]) .titlebar-spacer[type="pre-tabs"] {
:root:not([sizemode=normal]) .titlebar-spacer[type="pre-tabs"],
:root[gtktiledwindow=true] .titlebar-spacer[type="pre-tabs"] {
display: none;
}
}
@media (-moz-gtk-csd-reversed-placement) {
:root:not([sizemode=normal]) .titlebar-spacer[type="post-tabs"] {
:root:not([sizemode=normal]) .titlebar-spacer[type="post-tabs"],
:root[gtktiledwindow=true] .titlebar-spacer[type="post-tabs"] {
display: none;
}
}

Просмотреть файл

@ -488,7 +488,7 @@ notification[value="translation"] menulist > .menulist-dropmarker {
:root[tabsintitlebar] > #navigator-toolbox > #titlebar {
-moz-appearance: -moz-window-titlebar-maximized;
}
:root[tabsintitlebar][sizemode="normal"] > #navigator-toolbox > #titlebar {
:root[tabsintitlebar][sizemode="normal"]:not([gtktiledwindow="true"]) > #navigator-toolbox > #titlebar {
-moz-appearance: -moz-window-titlebar;
}
:root[tabsintitlebar]:not([inDOMFullscreen]) > #navigator-toolbox > #titlebar:-moz-lwtheme {

Просмотреть файл

@ -177,6 +177,10 @@ typedef enum {
} GdkAnchorHints;
#endif
#if !GTK_CHECK_VERSION(3, 10, 0)
# define GDK_WINDOW_STATE_TILED (1 << 8)
#endif
/* utility functions */
static bool is_mouse_in_window(GdkWindow* aWindow, gdouble aMouseX,
gdouble aMouseY);
@ -3227,8 +3231,10 @@ void nsWindow::OnVisibilityNotifyEvent(GdkEventVisibility* aEvent) {
void nsWindow::OnWindowStateEvent(GtkWidget* aWidget,
GdkEventWindowState* aEvent) {
LOG(("nsWindow::OnWindowStateEvent [%p] changed %d new_window_state %d\n",
(void*)this, aEvent->changed_mask, aEvent->new_window_state));
LOG(
("nsWindow::OnWindowStateEvent [%p] for %p changed 0x%x new_window_state "
"0x%x\n",
(void*)this, aWidget, aEvent->changed_mask, aEvent->new_window_state));
if (IS_MOZ_CONTAINER(aWidget)) {
// This event is notifying the container widget of changes to the
@ -3246,6 +3252,7 @@ void nsWindow::OnWindowStateEvent(GtkWidget* aWidget,
if (mHasMappedToplevel != mapped) {
SetHasMappedToplevel(mapped);
}
LOG(("\tquick return because IS_MOZ_CONTAINER(aWidget) is true\n"));
return;
}
// else the widget is a shell widget.
@ -3306,7 +3313,8 @@ void nsWindow::OnWindowStateEvent(GtkWidget* aWidget,
if (!waylandWasIconified &&
(aEvent->changed_mask &
(GDK_WINDOW_STATE_ICONIFIED | GDK_WINDOW_STATE_MAXIMIZED |
GDK_WINDOW_STATE_FULLSCREEN)) == 0) {
GDK_WINDOW_STATE_TILED | GDK_WINDOW_STATE_FULLSCREEN)) == 0) {
LOG(("\tearly return because no interesting bits changed\n"));
return;
}
@ -3333,6 +3341,14 @@ void nsWindow::OnWindowStateEvent(GtkWidget* aWidget,
#endif // ACCESSIBILITY
}
if (aEvent->new_window_state & GDK_WINDOW_STATE_TILED) {
LOG(("\tTiled\n"));
mIsTiled = true;
} else {
LOG(("\tNot tiled\n"));
mIsTiled = false;
}
if (mWidgetListener) {
mWidgetListener->SizeModeChanged(mSizeState);
if (aEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {

Просмотреть файл

@ -168,6 +168,7 @@ nsBaseWidget::nsBaseWidget()
mOriginalBounds(nullptr),
mClipRectCount(0),
mSizeMode(nsSizeMode_Normal),
mIsTiled(false),
mPopupLevel(ePopupLevelTop),
mPopupType(ePopupTypeAny),
mHasRemoteContent(false),

Просмотреть файл

@ -167,6 +167,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
virtual void SetSizeMode(nsSizeMode aMode) override;
virtual nsSizeMode SizeMode() override { return mSizeMode; }
virtual bool IsTiled() const override { return mIsTiled; }
virtual bool IsFullyOccluded() const override { return mIsFullyOccluded; }
@ -691,6 +692,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
mozilla::UniquePtr<LayoutDeviceIntRect[]> mClipRects;
uint32_t mClipRectCount;
nsSizeMode mSizeMode;
bool mIsTiled;
nsPopupLevel mPopupLevel;
nsPopupType mPopupType;
SizeConstraints mSizeConstraints;

Просмотреть файл

@ -836,6 +836,11 @@ class nsIWidget : public nsISupports {
*/
virtual nsSizeMode SizeMode() = 0;
/**
* Ask whether the window is tiled.
*/
virtual bool IsTiled() const = 0;
/**
* Ask wether the widget is fully occluded
*/

Просмотреть файл

@ -81,6 +81,7 @@ using dom::AutoNoJSAPI;
#define WIDTH_ATTRIBUTE NS_LITERAL_STRING("width")
#define HEIGHT_ATTRIBUTE NS_LITERAL_STRING("height")
#define MODE_ATTRIBUTE NS_LITERAL_STRING("sizemode")
#define TILED_ATTRIBUTE NS_LITERAL_STRING("gtktiledwindow")
#define ZLEVEL_ATTRIBUTE NS_LITERAL_STRING("zlevel")
//*****************************************************************************
@ -1295,7 +1296,7 @@ bool nsXULWindow::UpdateWindowStateFromMiscXULAttributes() {
// If we are told to ignore the size mode attribute, force
// normal sizemode.
if (mIgnoreXULSizeMode) {
windowElement->SetAttribute(MODE_ATTRIBUTE, NS_LITERAL_STRING("normal"),
windowElement->SetAttribute(MODE_ATTRIBUTE, SIZEMODE_NORMAL,
IgnoreErrors());
} else {
// Otherwise, read sizemode from DOM and, if the window is resizable,
@ -1783,6 +1784,13 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes() {
Unused << SetPersistentValue(nsGkAtoms::sizemode, sizeString);
}
}
bool tiled = mWindow->IsTiled();
if (tiled) {
sizeString.Assign(NS_LITERAL_STRING("true"));
} else {
sizeString.Assign(NS_LITERAL_STRING("false"));
}
docShellElement->SetAttribute(TILED_ATTRIBUTE, sizeString, rv);
if (persistString.Find("zlevel") >= 0) {
uint32_t zLevel;
nsCOMPtr<nsIWindowMediator> mediator(