Commit 90262893 authored by Matthias Clasen's avatar Matthias Clasen

wayland: Port to new monitor api

parent a2f02f1c
......@@ -48,6 +48,8 @@ libgdk_wayland_la_SOURCES = \
gdkkeys-wayland.c \
gdkglcontext-wayland.c \
gdkglcontext-wayland.h \
gdkmonitor-wayland.c \
gdkmonitor-wayland.h \
gdkscreen-wayland.c \
gdkseat-wayland.h \
gdkselection-wayland.c \
......@@ -64,6 +66,7 @@ libgdkwaylandinclude_HEADERS = \
gdkwaylanddevice.h \
gdkwaylanddisplay.h \
gdkwaylandglcontext.h \
gdkwaylandmonitor.h \
gdkwaylandselection.h \
gdkwaylandwindow.h
......
......@@ -598,6 +598,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);
}
......@@ -812,6 +814,26 @@ gdk_wayland_display_pop_error_trap (GdkDisplay *display,
return 0;
}
static int
gdk_wayland_display_get_n_monitors (GdkDisplay *display)
{
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
gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
{
......@@ -863,12 +885,17 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
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
......
......@@ -103,6 +103,8 @@ struct _GdkWaylandDisplay
GdkWaylandSelection *selection;
GPtrArray *monitors;
/* egl info */
EGLDisplay egl_display;
int egl_major_version;
......
/*
* 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 "gdkprivate-wayland.h"
#include "gdkmonitor-wayland.h"
G_DEFINE_TYPE (GdkWaylandMonitor, gdk_wayland_monitor, GDK_TYPE_MONITOR)
static void
gdk_wayland_monitor_init (GdkWaylandMonitor *monitor)
{
}
static void
gdk_wayland_monitor_finalize (GObject *object)
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)object;
wl_output_destroy (monitor->output);
G_OBJECT_CLASS (gdk_wayland_monitor_parent_class)->finalize (object);
}
static void
gdk_wayland_monitor_class_init (GdkWaylandMonitorClass *class)
{
G_OBJECT_CLASS (class)->finalize = gdk_wayland_monitor_finalize;
}
/**
* gdk_wayland_monitor_get_wl_output:
* @monitor: (type GdkWaylandMonitor): a #GdkMonitor
*
* Returns the Wayland wl_output of a #GdkMonitor.
*
* Returns: (transfer none): a Wayland wl_output
* Since: 3.22
*/
struct wl_output *
gdk_wayland_monitor_get_wl_output (GdkMonitor *monitor)
{
g_return_val_if_fail (GDK_IS_WAYLAND_MONITOR (monitor), NULL);
return GDK_WAYLAND_MONITOR (monitor)->output;
}
/*
* 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_WAYLAND_MONITOR_PRIVATE_H__
#define __GDK_WAYLAND_MONITOR_PRIVATE_H__
#include <glib.h>
#include "gdkwaylandmonitor.h"
#include "gdkmonitorprivate.h"
#include "gdkprivate-wayland.h"
struct _GdkWaylandMonitor {
GdkMonitor parent;
guint32 id;
guint32 version;
struct wl_output *output;
gboolean added;
};
struct _GdkWaylandMonitorClass {
GdkMonitorClass parent_class;
};
#endif
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include <gdk/wayland/gdkwaylanddevice.h>
#include <gdk/wayland/gdkwaylanddisplay.h>
#include <gdk/wayland/gdkwaylandmonitor.h>
#include <gdk/wayland/gdkwaylandselection.h>
#include <gdk/wayland/gdkwaylandwindow.h>
#include <gdk/wayland/gdkwaylandglcontext.h>
......
/*
* gdkwaylandmonitor.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_WAYLAND_MONITOR_H__
#define __GDK_WAYLAND_MONITOR_H__
#if !defined (__GDKWAYLAND_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdkwayland.h> can be included directly."
#endif
#include <gdk/gdkmonitor.h>
G_BEGIN_DECLS
#define GDK_TYPE_WAYLAND_MONITOR (gdk_wayland_monitor_get_type ())
#define GDK_WAYLAND_MONITOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_MONITOR, GdkWaylandMonitor))
#define GDK_IS_WAYLAND_MONITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_MONITOR))
typedef struct _GdkWaylandMonitor GdkWaylandMonitor;
typedef struct _GdkWaylandMonitorClass GdkWaylandMonitorClass;
GDK_AVAILABLE_IN_3_22
GType gdk_wayland_monitor_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_22
struct wl_output *gdk_wayland_monitor_get_wl_output (GdkMonitor *monitor);
G_END_DECLS
#endif /* __GDK_WAYLAND_MONITOR_H__ */
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