[gtk+] Add a fallback for unconverted backends
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a fallback for unconverted backends
- Date: Thu, 28 Apr 2016 03:18:44 +0000 (UTC)
commit b6c4ba0e2ad1e0a30a941594e4003399e74f5792
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Apr 25 09:07:56 2016 -0400
Add a fallback for unconverted backends
If the monitor vfuncs are not implemented in a display class,
fall back to providing a single monitor object representing
the entire screen. This is not meant to be 'good enough', it
is just to provide some implementation until all backends
implement the monitor vfuncs. When that is the case, the
fallback should be removed.
gdk/gdkdisplay.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index d932b50..f26dd7e 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -33,6 +33,7 @@
#include "gdkinternals.h"
#include "gdkmarshalers.h"
#include "gdkscreen.h"
+#include "gdkmonitorprivate.h"
#include <math.h>
#include <glib.h>
@@ -2520,9 +2521,38 @@ gdk_display_get_n_monitors (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
+ if (GDK_DISPLAY_GET_CLASS (display)->get_n_monitors == NULL)
+ return 1;
+
return GDK_DISPLAY_GET_CLASS (display)->get_n_monitors (display);
}
+static GdkMonitor *
+get_fallback_monitor (GdkDisplay *display)
+{
+ static GdkMonitor *monitor = NULL;
+ GdkScreen *screen;
+
+ if (monitor == NULL)
+ {
+ g_warning ("%s does not implement the monitor vfuncs", G_OBJECT_TYPE_NAME (display));
+ monitor = gdk_monitor_new (display);
+ gdk_monitor_set_manufacturer (monitor, "fallback");
+ gdk_monitor_set_position (monitor, 0, 0);
+ gdk_monitor_set_scale_factor (monitor, 1);
+ }
+
+ screen = gdk_display_get_default_screen (display);
+ gdk_monitor_set_size (monitor,
+ gdk_screen_get_width (screen),
+ gdk_screen_get_height (screen));
+ gdk_monitor_set_physical_size (monitor,
+ gdk_screen_get_width_mm (screen),
+ gdk_screen_get_height_mm (screen));
+
+ return monitor;
+}
+
/**
* gdk_display_get_monitor:
* @display: a #GdkDisplay
@@ -2540,6 +2570,9 @@ gdk_display_get_monitor (GdkDisplay *display,
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+ if (GDK_DISPLAY_GET_CLASS (display)->get_monitor == NULL)
+ return get_fallback_monitor (display);
+
return GDK_DISPLAY_GET_CLASS (display)->get_monitor (display, monitor_num);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]