std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay() { #if PLATFORM(GTK) #if defined(GTK_API_VERSION_2) return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(gdk_display_get_default())); #else GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); #if PLATFORM(X11) if (GDK_IS_X11_DISPLAY(display)) return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(display)); #endif #if PLATFORM(WAYLAND) if (GDK_IS_WAYLAND_DISPLAY(display)) return std::make_unique<PlatformDisplayWayland>(gdk_wayland_display_get_wl_display(display)); #endif #endif #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) return std::make_unique<PlatformDisplayX11>(static_cast<Display*>(ecore_x_display_get())); #elif PLATFORM(WIN) return std::make_unique<PlatformDisplayWin>(); #endif #if PLATFORM(X11) return std::make_unique<PlatformDisplayX11>(); #endif ASSERT_NOT_REACHED(); return nullptr; }
static void test_unset_display (void) { if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) { GdkDisplayManager *manager; g_unsetenv ("DISPLAY"); g_assert (!gdk_init_check (NULL, NULL)); manager = gdk_display_manager_get (); g_assert (manager != NULL); g_assert (gdk_display_manager_get_default_display (manager) == NULL); exit (0); } g_test_trap_assert_passed (); if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) { g_unsetenv ("DISPLAY"); gdk_init (NULL, NULL); exit (0); } g_test_trap_assert_failed (); g_test_trap_assert_stderr ("*cannot open display*"); }
static PassOwnPtr<WidgetBackingStore> createBackingStore(GtkWidget* widget, const IntSize& size) { #ifdef GDK_WINDOWING_X11 GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); if (GDK_IS_X11_DISPLAY(display)) return WebCore::WidgetBackingStoreGtkX11::create(widget, size); #endif return WebCore::WidgetBackingStoreCairo::create(widget, size); }
static OwnPtr<WidgetBackingStore> createBackingStoreForGTK(GtkWidget* widget, const IntSize& size, float deviceScaleFactor) { #if PLATFORM(X11) && defined(GDK_WINDOWING_X11) GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); if (GDK_IS_X11_DISPLAY(display)) return WebCore::WidgetBackingStoreGtkX11::create(widget, size, deviceScaleFactor); #endif return WebCore::WidgetBackingStoreCairo::create(widget, size, deviceScaleFactor); }
static void gdk_display_manager_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { case PROP_DEFAULT_DISPLAY: g_value_set_object (value, gdk_display_manager_get_default_display (GDK_DISPLAY_MANAGER (object))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
std::unique_ptr<PlatformDisplay> PlatformDisplay::createPlatformDisplay() { #if PLATFORM(GTK) #if defined(GTK_API_VERSION_2) return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(gdk_display_get_default())); #else GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get()); #if PLATFORM(X11) if (GDK_IS_X11_DISPLAY(display)) return std::make_unique<PlatformDisplayX11>(GDK_DISPLAY_XDISPLAY(display)); #endif #if PLATFORM(WAYLAND) if (GDK_IS_WAYLAND_DISPLAY(display)) return std::make_unique<PlatformDisplayWayland>(gdk_wayland_display_get_wl_display(display)); #endif #endif #elif PLATFORM(EFL) && defined(HAVE_ECORE_X) return std::make_unique<PlatformDisplayX11>(static_cast<Display*>(ecore_x_display_get())); #elif PLATFORM(WIN) return std::make_unique<PlatformDisplayWin>(); #endif #if PLATFORM(WAYLAND) if (auto platformDisplay = PlatformDisplayWayland::create()) return platformDisplay; #endif #if PLATFORM(X11) if (auto platformDisplay = PlatformDisplayX11::create()) return platformDisplay; #endif // If at this point we still don't have a display, just create a fake display with no native. #if PLATFORM(WAYLAND) return std::make_unique<PlatformDisplayWayland>(nullptr); #endif #if PLATFORM(X11) return std::make_unique<PlatformDisplayX11>(nullptr); #endif ASSERT_NOT_REACHED(); return nullptr; }
/** * gdk_display_get_default: * * Gets the default #GdkDisplay. This is a convenience * function for * <literal>gdk_display_manager_get_default_display (gdk_display_manager_get ())</literal>. * * Returns: (transfer none): a #GdkDisplay, or %NULL if there is no default * display. * * Since: 2.2 */ GdkDisplay * gdk_display_get_default (void) { return gdk_display_manager_get_default_display (gdk_display_manager_get ()); }