Bug 1511951 - [Wayland/EGL] HiDPI - Set scale to EGL window, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Wed, 05 Dec 2018 19:53:33 +0000
changeset 508729 32b8595b7c207bec915e39450d565ada6f50bc48
parent 508728 c6467f04bcd9b1b538bf355ded9e100bda485403
child 508730 17e2efc3d047c9a3510abfda46b2ac163975abd5
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1511951
milestone65.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 1511951 - [Wayland/EGL] HiDPI - Set scale to EGL window, r=jhorak - Wayland - Set proper scale to wl_egl_window when it's created and resized - Wayland - Remove unused gtk_widget_set_app_paintable() Differential Revision: https://phabricator.services.mozilla.com/D13725
widget/gtk/mozcontainer.cpp
widget/gtk/nsWindow.cpp
--- a/widget/gtk/mozcontainer.cpp
+++ b/widget/gtk/mozcontainer.cpp
@@ -184,18 +184,31 @@ static void moz_container_map_wayland(Mo
                            container);
 }
 
 static void moz_container_unmap_wayland(MozContainer *container) {
   g_clear_pointer(&container->eglwindow, wl_egl_window_destroy);
   g_clear_pointer(&container->subsurface, wl_subsurface_destroy);
   g_clear_pointer(&container->surface, wl_surface_destroy);
   g_clear_pointer(&container->frame_callback_handler, wl_callback_destroy);
+
   container->ready_to_draw = false;
 }
+
+static gint moz_container_get_scale(MozContainer *container) {
+    static auto sGdkWindowGetScaleFactorPtr = (gint(*)(GdkWindow *))dlsym(
+        RTLD_DEFAULT, "gdk_window_get_scale_factor");
+
+    if (sGdkWindowGetScaleFactorPtr) {
+      GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(container));
+      return (*sGdkWindowGetScaleFactorPtr)(window);
+    }
+
+    return 1;
+}
 #endif
 
 void moz_container_map(GtkWidget *widget) {
   MozContainer *container;
   GList *tmp_list;
   GtkWidget *tmp_child;
 
   g_return_if_fail(IS_MOZ_CONTAINER(widget));
@@ -316,18 +329,20 @@ void moz_container_size_allocate(GtkWidg
   // when offset changes (GdkWindow is maximized for instance).
   // see gtk-clutter-embed.c for reference.
   if (container->subsurface) {
     gint x, y;
     gdk_window_get_position(gtk_widget_get_window(widget), &x, &y);
     wl_subsurface_set_position(container->subsurface, x, y);
   }
   if (container->eglwindow) {
-    wl_egl_window_resize(container->eglwindow, allocation->width,
-                         allocation->height, 0, 0);
+    gint scale = moz_container_get_scale(container);
+    wl_egl_window_resize(container->eglwindow,
+                         allocation->width * scale,
+                         allocation->height * scale, 0, 0);
   }
 #endif
 }
 
 void moz_container_remove(GtkContainer *container, GtkWidget *child_widget) {
   MozContainerChild *child;
   MozContainer *moz_container;
   GdkWindow *parent_window;
@@ -453,37 +468,35 @@ struct wl_surface *moz_container_get_wl_
     wl_subsurface_set_desync(container->subsurface);
 
     // Route input to parent wl_surface owned by Gtk+ so we get input
     // events from Gtk+.
     wl_region *region = wl_compositor_create_region(compositor);
     wl_surface_set_input_region(container->surface, region);
     wl_region_destroy(region);
 
-    static auto sGdkWindowGetScaleFactorPtr = (gint(*)(GdkWindow *))dlsym(
-        RTLD_DEFAULT, "gdk_window_get_scale_factor");
-    if (sGdkWindowGetScaleFactorPtr) {
-      gint scaleFactor = (*sGdkWindowGetScaleFactorPtr)(window);
-      wl_surface_set_buffer_scale(container->surface, scaleFactor);
-    }
+    wl_surface_set_buffer_scale(container->surface,
+                                moz_container_get_scale(container));
   }
 
   return container->surface;
 }
 
 struct wl_egl_window *moz_container_get_wl_egl_window(MozContainer *container) {
   if (!container->eglwindow) {
     wl_surface *surface = moz_container_get_wl_surface(container);
     if (!surface) {
       return nullptr;
     }
 
     GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(container));
+    gint scale = moz_container_get_scale(container);
     container->eglwindow = wl_egl_window_create(
-        surface, gdk_window_get_width(window), gdk_window_get_height(window));
+        surface, gdk_window_get_width(window) * scale,
+                 gdk_window_get_height(window) * scale);
   }
   return container->eglwindow;
 }
 
 gboolean moz_container_has_wl_egl_window(MozContainer *container) {
   return container->eglwindow ? true : false;
 }
 
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3619,20 +3619,16 @@ nsresult nsWindow::Create(nsIWidget *aPa
         SetCursor(eCursor_standard);
 
         if (aInitData->mNoAutoHide) {
           gint wmd = ConvertBorderStyles(mBorderStyle);
           if (wmd != -1)
             gdk_window_set_decorations(mGdkWindow, (GdkWMDecoration)wmd);
         }
 
-        if (!mIsX11Display) {
-          gtk_widget_set_app_paintable(mShell, TRUE);
-        }
-
         // If the popup ignores mouse events, set an empty input shape.
         if (aInitData->mMouseTransparent) {
           cairo_rectangle_int_t rect = {0, 0, 0, 0};
           cairo_region_t *region = cairo_region_create_rectangle(&rect);
 
           gdk_window_input_shape_combine_region(mGdkWindow, region, 0, 0);
           cairo_region_destroy(region);
         }