Title: [173690] trunk/Source/WebCore
Revision
173690
Author
[email protected]
Date
2014-09-17 05:35:08 -0700 (Wed, 17 Sep 2014)

Log Message

[GTK] Add a helper function for display system deduction
https://bugs.webkit.org/show_bug.cgi?id=136849

Reviewed by Martin Robinson.

getDisplaySystemType() is a helper function that checks the type of the
default GdkDisplay object and initializes a static variable to the
corresponding value. It then returns the value of that variable.

When building with the GTK+2 API (still the case with the GTK+2 plugin
process) we default to X11.

The function is declared and implemented in GtkUtilities files.

* platform/gtk/GtkUtilities.cpp:
(WebCore::widgetIsOnscreenToplevelWindow):
(WebCore::getDisplaySystemType):
* platform/gtk/GtkUtilities.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173689 => 173690)


--- trunk/Source/WebCore/ChangeLog	2014-09-17 09:29:31 UTC (rev 173689)
+++ trunk/Source/WebCore/ChangeLog	2014-09-17 12:35:08 UTC (rev 173690)
@@ -1,3 +1,24 @@
+2014-09-17  Zan Dobersek  <[email protected]>
+
+        [GTK] Add a helper function for display system deduction
+        https://bugs.webkit.org/show_bug.cgi?id=136849
+
+        Reviewed by Martin Robinson.
+
+        getDisplaySystemType() is a helper function that checks the type of the
+        default GdkDisplay object and initializes a static variable to the
+        corresponding value. It then returns the value of that variable.
+
+        When building with the GTK+2 API (still the case with the GTK+2 plugin
+        process) we default to X11.
+
+        The function is declared and implemented in GtkUtilities files.
+
+        * platform/gtk/GtkUtilities.cpp:
+        (WebCore::widgetIsOnscreenToplevelWindow):
+        (WebCore::getDisplaySystemType):
+        * platform/gtk/GtkUtilities.h:
+
 2014-09-16  Yusuke Suzuki  <[email protected]>
 
         filterRootById accidentally clears inAdjacentChain flag

Modified: trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp (173689 => 173690)


--- trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp	2014-09-17 09:29:31 UTC (rev 173689)
+++ trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp	2014-09-17 12:35:08 UTC (rev 173690)
@@ -22,6 +22,13 @@
 #include "IntPoint.h"
 #include <gtk/gtk.h>
 
+#if PLATFORM(X11)
+#include <gdk/gdkx.h>
+#endif
+#if PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
+#include <gdk/gdkwayland.h>
+#endif
+
 namespace WebCore {
 
 IntPoint convertWidgetPointToScreenPoint(GtkWidget* widget, const IntPoint& point)
@@ -52,4 +59,26 @@
     return gtk_widget_is_toplevel(widget) && GTK_IS_WINDOW(widget) && !GTK_IS_OFFSCREEN_WINDOW(widget);
 }
 
+DisplaySystemType getDisplaySystemType()
+{
+#if defined(GTK_API_VERSION_2)
+    return DisplaySystemType::X11;
+#else
+    static DisplaySystemType type = [] {
+        GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
+#if PLATFORM(X11)
+        if (GDK_IS_X11_DISPLAY(display))
+            return DisplaySystemType::X11;
+#endif
+#if PLATFORM(WAYLAND)
+        if (GDK_IS_WAYLAND_DISPLAY(display))
+            return DisplaySystemType::Wayland;
+#endif
+        ASSERT_NOT_REACHED();
+        return DisplaySystemType::X11;
+    }();
+    return type;
+#endif
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/gtk/GtkUtilities.h (173689 => 173690)


--- trunk/Source/WebCore/platform/gtk/GtkUtilities.h	2014-09-17 09:29:31 UTC (rev 173689)
+++ trunk/Source/WebCore/platform/gtk/GtkUtilities.h	2014-09-17 12:35:08 UTC (rev 173690)
@@ -26,6 +26,13 @@
 IntPoint convertWidgetPointToScreenPoint(GtkWidget*, const IntPoint&);
 bool widgetIsOnscreenToplevelWindow(GtkWidget*);
 
+enum class DisplaySystemType {
+    X11,
+    Wayland
+};
+
+DisplaySystemType getDisplaySystemType();
+
 } // namespace WebCore
 
 #endif // GtkUtilities_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to