Commit 044109c8 authored by Matthias Clasen's avatar Matthias Clasen

broadway: Port to new monitor api

parent 90262893
......@@ -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 \
......
......@@ -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__
......
/*
* 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__ */
......@@ -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;
}
......@@ -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
......
/*
* 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)
{
}
/*
* 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
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment