[gtk+/wip/matthiasc/monitor] wayland: Adapt to api change
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/monitor] wayland: Adapt to api change
- Date: Tue, 5 Apr 2016 03:36:56 +0000 (UTC)
commit 589c7dd7799b003c886c97964be8486494c00843
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Apr 4 23:02:41 2016 -0400
wayland: Adapt to api change
gdk/wayland/gdkdisplay-wayland.c | 29 ++++++++++++++++++-----
gdk/wayland/gdkdisplay-wayland.h | 2 +
gdk/wayland/gdkprivate-wayland.h | 3 --
gdk/wayland/gdkscreen-wayland.c | 47 +++++++++++++-------------------------
4 files changed, 41 insertions(+), 40 deletions(-)
---
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 270738e..75de254 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -591,6 +591,8 @@ gdk_wayland_display_finalize (GObject *object)
g_free (display_wayland->startup_notification_id);
+ g_ptr_array_free (display_wayland->monitors, TRUE);
+
G_OBJECT_CLASS (gdk_wayland_display_parent_class)->finalize (object);
}
@@ -805,12 +807,24 @@ gdk_wayland_display_pop_error_trap (GdkDisplay *display,
return 0;
}
-static GdkMonitor **
-gdk_wayland_display_get_monitors (GdkDisplay *display,
- int *n_monitors)
+static int
+gdk_wayland_display_get_n_monitors (GdkDisplay *display)
{
- return gdk_wayland_screen_get_monitors (GDK_WAYLAND_DISPLAY (display)->screen,
- n_monitors);
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
+
+ return display_wayland->monitors->len;
+}
+
+static GdkMonitor *
+gdk_wayland_display_get_monitor (GdkDisplay *display,
+ int monitor_num)
+{
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
+
+ if (monitor_num < 0 || monitor_num >= display_wayland->monitors->len)
+ return NULL;
+
+ return (GdkMonitor *)display_wayland->monitors->pdata[monitor_num];
}
static void
@@ -865,13 +879,16 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
- display_class->get_monitors = gdk_wayland_display_get_monitors;
+ display_class->get_n_monitors = gdk_wayland_display_get_n_monitors;
+ display_class->get_monitor = gdk_wayland_display_get_monitor;
}
static void
gdk_wayland_display_init (GdkWaylandDisplay *display)
{
display->xkb_context = xkb_context_new (0);
+
+ display->monitors = g_ptr_array_new_with_free_func (g_object_unref);
}
void
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index 5410cf3..486ff18 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -98,6 +98,8 @@ struct _GdkWaylandDisplay
GdkWaylandSelection *selection;
+ GPtrArray *monitors;
+
/* egl info */
EGLDisplay egl_display;
int egl_major_version;
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index 15e5843..cb2c29a 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -272,7 +272,4 @@ EGLSurface gdk_wayland_window_get_dummy_egl_surface (GdkWindow *window,
void gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
GdkCursor *cursor);
-GdkMonitor **gdk_wayland_screen_get_monitors (GdkScreen *screen,
- int *n_monitors);
-
#endif /* __GDK_PRIVATE_WAYLAND_H__ */
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index c9f67b7..ec1ac99 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -98,9 +98,6 @@ struct _GdkWaylandScreen
/* Visual Part */
GdkVisual *visual;
- /* Xinerama/RandR 1.2 */
- GPtrArray *monitors;
-
GHashTable *settings;
GsdXftSettings xft_settings;
@@ -142,8 +139,6 @@ gdk_wayland_screen_finalize (GObject *object)
g_object_unref (screen_wayland->visual);
- g_ptr_array_free (screen_wayland->monitors, TRUE);
-
g_hash_table_destroy (screen_wayland->settings);
G_OBJECT_CLASS (_gdk_wayland_screen_parent_class)->finalize (object);
@@ -875,8 +870,6 @@ _gdk_wayland_screen_new (GdkDisplay *display)
screen_wayland->visual = gdk_wayland_visual_new (screen);
- screen_wayland->monitors = g_ptr_array_new_with_free_func (g_object_unref);
-
screen_wayland->root_window =
_gdk_wayland_screen_create_root_window (screen,
screen_wayland->width,
@@ -930,6 +923,7 @@ _gdk_wayland_screen_init (GdkWaylandScreen *screen_wayland)
static void
update_screen_size (GdkWaylandScreen *screen_wayland)
{
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (screen_wayland->display);
gboolean emit_changed = FALSE;
gint width, height;
gint width_mm, height_mm;
@@ -937,9 +931,9 @@ update_screen_size (GdkWaylandScreen *screen_wayland)
width = height = 0;
width_mm = height_mm = 0;
- for (i = 0; i < screen_wayland->monitors->len; i++)
+ for (i = 0; i < display_wayland->monitors->len; i++)
{
- GdkMonitor *monitor = screen_wayland->monitors->pdata[i];
+ GdkMonitor *monitor = display_wayland->monitors->pdata[i];
/* XXX: Largely assuming here that monitor areas
* are contiguous and never overlap.
@@ -1075,7 +1069,7 @@ output_handle_done (void *data,
if (!monitor->added)
{
monitor->added = TRUE;
- g_ptr_array_add (screen_wayland->monitors, monitor);
+ g_ptr_array_add (GDK_WAYLAND_DISPLAY (display)->monitors, monitor);
gdk_display_monitor_added (display, GDK_MONITOR (monitor));
}
@@ -1157,7 +1151,7 @@ _gdk_wayland_screen_add_output (GdkScreen *screen,
if (monitor->version < OUTPUT_VERSION_WITH_DONE)
{
- g_ptr_array_add (GDK_WAYLAND_SCREEN (screen)->monitors, monitor);
+ g_ptr_array_add (GDK_WAYLAND_DISPLAY (display)->monitors, monitor);
gdk_display_monitor_added (display, GDK_MONITOR (monitor));
}
@@ -1168,10 +1162,10 @@ struct wl_output *
_gdk_wayland_screen_get_wl_output (GdkScreen *screen,
gint monitor_num)
{
- GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (GDK_WAYLAND_SCREEN (screen)->display);
GdkWaylandMonitor *monitor;
- monitor = screen_wayland->monitors->pdata[monitor_num];
+ monitor = display_wayland->monitors->pdata[monitor_num];
return monitor->output;
}
@@ -1180,11 +1174,12 @@ static GdkWaylandMonitor *
get_monitor_for_id (GdkWaylandScreen *screen_wayland,
guint32 id)
{
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (screen_wayland->display);
int i;
- for (i = 0; i < screen_wayland->monitors->len; i++)
+ for (i = 0; i < display_wayland->monitors->len; i++)
{
- GdkWaylandMonitor *monitor = screen_wayland->monitors->pdata[i];
+ GdkWaylandMonitor *monitor = display_wayland->monitors->pdata[i];
if (monitor->id == id)
return monitor;
@@ -1197,11 +1192,12 @@ static GdkWaylandMonitor *
get_monitor_for_output (GdkWaylandScreen *screen_wayland,
struct wl_output *output)
{
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (screen_wayland->display);
int i;
- for (i = 0; i < screen_wayland->monitors->len; i++)
+ for (i = 0; i < display_wayland->monitors->len; i++)
{
- GdkWaylandMonitor *monitor = screen_wayland->monitors->pdata[i];
+ GdkWaylandMonitor *monitor = display_wayland->monitors->pdata[i];
if (monitor->output == output)
return monitor;
@@ -1215,15 +1211,15 @@ _gdk_wayland_screen_remove_output (GdkScreen *screen,
guint32 id)
{
GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
- GdkDisplay *display = gdk_screen_get_display (screen);
+ GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (screen_wayland->display);
GdkWaylandMonitor *monitor;
monitor = get_monitor_for_id (screen_wayland, id);
if (monitor != NULL)
{
g_object_ref (monitor);
- g_ptr_array_remove (screen_wayland->monitors, monitor);
- gdk_display_monitor_removed (display, GDK_MONITOR (monitor));
+ g_ptr_array_remove (display_wayland->monitors, monitor);
+ gdk_display_monitor_removed (GDK_DISPLAY (display_wayland), GDK_MONITOR (monitor));
g_object_unref (monitor);
g_signal_emit_by_name (screen_wayland, "monitors-changed");
update_screen_size (screen_wayland);
@@ -1257,14 +1253,3 @@ _gdk_wayland_screen_get_output_scale (GdkScreen *screen,
return 0;
}
-
-GdkMonitor **
-gdk_wayland_screen_get_monitors (GdkScreen *screen,
- int *n_monitors)
-{
- GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
-
- *n_monitors = screen_wayland->monitors->len;
-
- return (GdkMonitor **)screen_wayland->monitors->pdata;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]