[gtk+] broadway: Port to new monitor api



commit 044109c8c73f5c1d9eb470c857112c08a005b0ae
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 2 23:42:40 2016 -0400

    broadway: Port to new monitor api

 gdk/broadway/Makefile.am           |    3 ++
 gdk/broadway/gdkbroadway.h         |    1 +
 gdk/broadway/gdkbroadwaymonitor.h  |   46 ++++++++++++++++++++++++++
 gdk/broadway/gdkdisplay-broadway.c |   39 ++++++++++++++++++++++
 gdk/broadway/gdkdisplay-broadway.h |    3 ++
 gdk/broadway/gdkmonitor-broadway.c |   37 +++++++++++++++++++++
 gdk/broadway/gdkmonitor-broadway.h |   38 ++++++++++++++++++++++
 gdk/broadway/gdkscreen-broadway.c  |   62 +++--------------------------------
 8 files changed, 173 insertions(+), 56 deletions(-)
---
diff --git a/gdk/broadway/Makefile.am b/gdk/broadway/Makefile.am
index 2f8457e..59dc5d0 100644
--- a/gdk/broadway/Makefile.am
+++ b/gdk/broadway/Makefile.am
@@ -28,6 +28,7 @@ libgdkbroadwayinclude_HEADERS =       \
        gdkbroadwaydisplay.h            \
        gdkbroadwaywindow.h             \
        gdkbroadwaycursor.h             \
+       gdkbroadwaymonitor.h            \
        gdkbroadwayvisual.h
 
 EXTRA_DIST += toarray.pl
@@ -64,6 +65,8 @@ libgdk_broadway_la_SOURCES =          \
        gdkeventsource.h        \
        gdkglobals-broadway.c   \
        gdkkeys-broadway.c      \
+       gdkmonitor-broadway.c   \
+       gdkmonitor-broadway.h   \
        gdkproperty-broadway.c  \
        gdkscreen-broadway.c    \
        gdkscreen-broadway.h    \
diff --git a/gdk/broadway/gdkbroadway.h b/gdk/broadway/gdkbroadway.h
index 6c64658..89086c4 100644
--- a/gdk/broadway/gdkbroadway.h
+++ b/gdk/broadway/gdkbroadway.h
@@ -32,6 +32,7 @@
 #include <gdk/broadway/gdkbroadwaydisplay.h>
 #include <gdk/broadway/gdkbroadwaywindow.h>
 #include <gdk/broadway/gdkbroadwaycursor.h>
+#include <gdk/broadway/gdkbroadwaymonitor.h>
 #include <gdk/broadway/gdkbroadwayvisual.h>
 
 #undef __GDKBROADWAY_H_INSIDE__
diff --git a/gdk/broadway/gdkbroadwaymonitor.h b/gdk/broadway/gdkbroadwaymonitor.h
new file mode 100644
index 0000000..2021c0c
--- /dev/null
+++ b/gdk/broadway/gdkbroadwaymonitor.h
@@ -0,0 +1,46 @@
+/*
+ * gdkbroadwaymonitor.h
+ *
+ * Copyright 2016 Red Hat, Inc.
+ *
+ * Matthias Clasen <mclasen redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_BROADWAY_MONITOR_H__
+#define __GDK_BROADWAY_MONITOR_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdkmonitor.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_BROADWAY_MONITOR           (gdk_broadway_monitor_get_type ())
+#define GDK_BROADWAY_MONITOR(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), 
GDK_TYPE_BROADWAY_MONITOR, GdkBroadwayMonitor))
+#define GDK_IS_BROADWAY_MONITOR(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), 
GDK_TYPE_BROADWAY_MONITOR))
+
+typedef struct _GdkBroadwayMonitor      GdkBroadwayMonitor;
+typedef struct _GdkBroadwayMonitorClass GdkBroadwayMonitorClass;
+
+GDK_AVAILABLE_IN_3_22
+GType             gdk_broadway_monitor_get_type            (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif  /* __GDK_BROADWAY_MONITOR_H__ */
+
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 2aa56c6..54a1fa8 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -28,6 +28,7 @@
 #include "gdkeventsource.h"
 #include "gdkscreen.h"
 #include "gdkscreen-broadway.h"
+#include "gdkmonitor-broadway.h"
 #include "gdkinternals.h"
 #include "gdkdeviceprivate.h"
 #include "gdkdevicemanager-broadway.h"
@@ -55,6 +56,12 @@ static void
 gdk_broadway_display_init (GdkBroadwayDisplay *display)
 {
   display->id_ht = g_hash_table_new (NULL, NULL);
+
+  display->monitor = g_object_new (GDK_TYPE_BROADWAY_MONITOR,
+                                   "display", display,
+                                   NULL);
+  gdk_monitor_set_manufacturer (display->monitor, "browser");
+  gdk_monitor_set_model (display->monitor, "0");
 }
 
 static void
@@ -200,6 +207,8 @@ gdk_broadway_display_finalize (GObject *object)
   g_object_unref (broadway_display->screens[0]);
   g_free (broadway_display->screens);
 
+  g_object_unref (broadway_display->monitor);
+
   G_OBJECT_CLASS (gdk_broadway_display_parent_class)->finalize (object);
 }
 
@@ -281,6 +290,32 @@ gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display)
   _gdk_broadway_server_set_show_keyboard (display->server, FALSE);
 }
 
+static int
+gdk_broadway_display_get_n_monitors (GdkDisplay *display)
+{
+  return 1;
+}
+
+static GdkMonitor *
+gdk_broadway_display_get_monitor (GdkDisplay *display,
+                                  int         monitor_num)
+{
+  GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
+
+  if (monitor_num == 0)
+    return broadway_display->monitor;
+
+  return NULL;
+}
+
+static GdkMonitor *
+gdk_broadway_display_get_primary_monitor (GdkDisplay *display)
+{
+  GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
+
+  return broadway_display->monitor;
+}
+
 static void
 gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
 {
@@ -328,5 +363,9 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
   display_class->convert_selection = _gdk_broadway_display_convert_selection;
   display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
   display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
+
+  display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
+  display_class->get_monitor = gdk_broadway_display_get_monitor;
+  display_class->get_primary_monitor = gdk_broadway_display_get_primary_monitor;
 }
 
diff --git a/gdk/broadway/gdkdisplay-broadway.h b/gdk/broadway/gdkdisplay-broadway.h
index fe2080a..38a9968 100644
--- a/gdk/broadway/gdkdisplay-broadway.h
+++ b/gdk/broadway/gdkdisplay-broadway.h
@@ -30,6 +30,7 @@
 #include "gdkinternals.h"
 #include "gdkmain.h"
 #include "gdkbroadway-server.h"
+#include "gdkmonitorprivate.h"
 
 G_BEGIN_DECLS
 
@@ -56,6 +57,8 @@ struct _GdkBroadwayDisplay
   GdkBroadwayServer *server;
 
   gpointer move_resize_data;
+
+  GdkMonitor *monitor;
 };
 
 struct _GdkBroadwayDisplayClass
diff --git a/gdk/broadway/gdkmonitor-broadway.c b/gdk/broadway/gdkmonitor-broadway.c
new file mode 100644
index 0000000..aebc280
--- /dev/null
+++ b/gdk/broadway/gdkmonitor-broadway.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2016 Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "gdkmonitor-broadway.h"
+#include "gdkscreen-broadway.h"
+
+
+G_DEFINE_TYPE (GdkBroadwayMonitor, gdk_broadway_monitor, GDK_TYPE_MONITOR)
+
+static void
+gdk_broadway_monitor_init (GdkBroadwayMonitor *monitor)
+{
+}
+
+static void
+gdk_broadway_monitor_class_init (GdkBroadwayMonitorClass *class)
+{
+}
diff --git a/gdk/broadway/gdkmonitor-broadway.h b/gdk/broadway/gdkmonitor-broadway.h
new file mode 100644
index 0000000..96b1751
--- /dev/null
+++ b/gdk/broadway/gdkmonitor-broadway.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2016 Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GDK_BROADWAY_MONITOR_PRIVATE_H__
+#define __GDK_BROADWAY_MONITOR_PRIVATE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "gdkmonitorprivate.h"
+
+#include "gdkbroadwaymonitor.h"
+
+
+struct _GdkBroadwayMonitor
+{
+  GdkMonitor parent;
+};
+
+struct _GdkBroadwayMonitorClass {
+  GdkMonitorClass parent_class;
+};
+
+#endif
diff --git a/gdk/broadway/gdkscreen-broadway.c b/gdk/broadway/gdkscreen-broadway.c
index 51ee140..c123d98 100644
--- a/gdk/broadway/gdkscreen-broadway.c
+++ b/gdk/broadway/gdkscreen-broadway.c
@@ -91,6 +91,7 @@ _gdk_broadway_screen_size_changed (GdkScreen                       *screen,
                                    BroadwayInputScreenResizeNotify *msg)
 {
   GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
+  GdkMonitor *monitor;
   gint width, height;
   GList *toplevels, *l;
 
@@ -104,6 +105,11 @@ _gdk_broadway_screen_size_changed (GdkScreen                       *screen,
       height == gdk_screen_get_height (screen))
     return;
 
+  monitor = GDK_BROADWAY_DISPLAY (broadway_screen->display)->monitor;
+
+  gdk_monitor_set_size (monitor, msg->width, msg->height);
+  gdk_monitor_set_physical_size (monitor, msg->width * 25.4 / 96, msg->height * 25.4 / 96);
+
   g_signal_emit_by_name (screen, "size-changed");
   toplevels = gdk_screen_get_toplevel_windows (screen);
   for (l = toplevels; l != NULL; l = l->next)
@@ -146,55 +152,6 @@ gdk_broadway_screen_finalize (GObject *object)
   G_OBJECT_CLASS (gdk_broadway_screen_parent_class)->finalize (object);
 }
 
-static gint
-gdk_broadway_screen_get_n_monitors (GdkScreen *screen)
-{
-  return 1;
-}
-
-static gint
-gdk_broadway_screen_get_primary_monitor (GdkScreen *screen)
-{
-  return 0;
-}
-
-static gint
-gdk_broadway_screen_get_monitor_width_mm (GdkScreen *screen,
-                                         gint       monitor_num)
-{
-  return gdk_screen_get_width_mm (screen);
-}
-
-static gint
-gdk_broadway_screen_get_monitor_height_mm (GdkScreen *screen,
-                                          gint       monitor_num)
-{
-  return gdk_screen_get_height_mm (screen);
-}
-
-static gchar *
-gdk_broadway_screen_get_monitor_plug_name (GdkScreen *screen,
-                                          gint       monitor_num)
-{
-  return g_strdup ("browser");
-}
-
-static void
-gdk_broadway_screen_get_monitor_geometry (GdkScreen    *screen,
-                                         gint          monitor_num,
-                                         GdkRectangle *dest)
-{
-  GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
-
-  if (dest)
-    {
-      dest->x = 0;
-      dest->y = 0;
-      dest->width = broadway_screen->width;
-      dest->height = broadway_screen->height;
-    }
-}
-
 static GdkVisual *
 gdk_broadway_screen_get_rgba_visual (GdkScreen *screen)
 {
@@ -290,13 +247,6 @@ gdk_broadway_screen_class_init (GdkBroadwayScreenClass *klass)
   screen_class->get_height_mm = gdk_broadway_screen_get_height_mm;
   screen_class->get_number = gdk_broadway_screen_get_number;
   screen_class->get_root_window = gdk_broadway_screen_get_root_window;
-  screen_class->get_n_monitors = gdk_broadway_screen_get_n_monitors;
-  screen_class->get_primary_monitor = gdk_broadway_screen_get_primary_monitor;
-  screen_class->get_monitor_width_mm = gdk_broadway_screen_get_monitor_width_mm;
-  screen_class->get_monitor_height_mm = gdk_broadway_screen_get_monitor_height_mm;
-  screen_class->get_monitor_plug_name = gdk_broadway_screen_get_monitor_plug_name;
-  screen_class->get_monitor_geometry = gdk_broadway_screen_get_monitor_geometry;
-  screen_class->get_monitor_workarea = gdk_broadway_screen_get_monitor_geometry;
   screen_class->is_composited = gdk_broadway_screen_is_composited;
   screen_class->make_display_name = gdk_broadway_screen_make_display_name;
   screen_class->get_active_window = gdk_broadway_screen_get_active_window;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]