Bug 1519606 - [Linux/Gtk] Compute correct margin for left titlebar buttons placement, r=dao
authorMartin Stransky <stransky@redhat.com>
Thu, 24 Jan 2019 09:22:30 +0000
changeset 515242 5797d4eee0ea2bc4b97c0eaefd3d7b579302de34
parent 515241 f4f53e83954a38a7a1cc8f2c6637f5c5d2d150e7
child 515243 4afc95f9c7ddd7e53bd8deee384c73a7778eeee3
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1519606
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519606 - [Linux/Gtk] Compute correct margin for left titlebar buttons placement, r=dao Depends on D17347 Differential Revision: https://phabricator.services.mozilla.com/D17351
widget/gtk/gtk3drawing.cpp
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -402,35 +402,43 @@ int GetGtkHeaderBarButtonLayout(WidgetNo
   GtkSettings* settings = gtk_settings_get_for_screen(gdk_screen_get_default());
   g_object_get(settings, "gtk-decoration-layout", &decorationLayout, nullptr);
 
   // Use a default layout
   if (!decorationLayout) {
     decorationLayout = "menu:minimize,maximize,close";
   }
 
+  // "minimize,maximize,close:menu" layout means buttons are on the opposite
+  // titlebar side.
+  bool reversedButtonsPlacement = strstr(decorationLayout, ":menu") != nullptr;
+
   // We support only default button order now:
-  // minimize/maximize/close
+  // minimize/maximize/close for right placement
+  // close/minimize/maximize for left placement
   int activeButtonNums = 0;
   if (aButtonLayout) {
+    if (reversedButtonsPlacement &&
+        strstr(decorationLayout, "close") != nullptr) {
+      aButtonLayout[activeButtonNums++] = MOZ_GTK_HEADER_BAR_BUTTON_CLOSE;
+    }
     if (strstr(decorationLayout, "minimize") != nullptr) {
       aButtonLayout[activeButtonNums++] = MOZ_GTK_HEADER_BAR_BUTTON_MINIMIZE;
     }
     if (strstr(decorationLayout, "maximize") != nullptr) {
       aButtonLayout[activeButtonNums++] = MOZ_GTK_HEADER_BAR_BUTTON_MAXIMIZE;
     }
-    if (strstr(decorationLayout, "close") != nullptr) {
+    if (!reversedButtonsPlacement &&
+        strstr(decorationLayout, "close") != nullptr) {
       aButtonLayout[activeButtonNums++] = MOZ_GTK_HEADER_BAR_BUTTON_CLOSE;
     }
   }
 
-  // "minimize,maximize,close:menu" layout means buttons are on the opposite
-  // titlebar side.
   if (aReversedButtonsPlacement) {
-    *aReversedButtonsPlacement = strstr(decorationLayout, ":menu") != nullptr;
+    *aReversedButtonsPlacement = reversedButtonsPlacement;
   }
 
   return activeButtonNums;
 }
 
 static void EnsureToolbarMetrics(void) {
   if (!sToolbarMetrics.initialized) {
     // Make sure we have clean cache after theme reset, etc.