[gtk+/wip/matthiasc/monitor] x11: Move monitor to its own files
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/monitor] x11: Move monitor to its own files
- Date: Tue, 5 Apr 2016 11:17:50 +0000 (UTC)
commit f18e5d1ccb8b04ca78bc04d0b0f15089a0677774
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Apr 5 07:16:39 2016 -0400
x11: Move monitor to its own files
gdk/x11/Makefile.am | 3 +
gdk/x11/gdkmonitor-x11.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++
gdk/x11/gdkmonitor-x11.h | 43 +++++++++++++++++++++
gdk/x11/gdkscreen-x11.c | 93 ++-------------------------------------------
gdk/x11/gdkscreen-x11.h | 2 +
gdk/x11/gdkx.h | 1 +
gdk/x11/gdkx11monitor.h | 46 +++++++++++++++++++++++
7 files changed, 193 insertions(+), 88 deletions(-)
---
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
index c488a31..6223e7e 100644
--- a/gdk/x11/Makefile.am
+++ b/gdk/x11/Makefile.am
@@ -43,6 +43,8 @@ libgdk_x11_la_SOURCES = \
gdkglcontext-x11.h \
gdkkeys-x11.c \
gdkmain-x11.c \
+ gdkmonitor-x11.c \
+ gdkmonitor-x11.h \
gdkproperty-x11.c \
gdkscreen-x11.c \
gdkscreen-x11.h \
@@ -76,6 +78,7 @@ libgdkx11include_HEADERS = \
gdkx11dnd.h \
gdkx11glcontext.h \
gdkx11keys.h \
+ gdkx11monitor.h \
gdkx11property.h \
gdkx11screen.h \
gdkx11selection.h \
diff --git a/gdk/x11/gdkmonitor-x11.c b/gdk/x11/gdkmonitor-x11.c
new file mode 100644
index 0000000..3a13c41
--- /dev/null
+++ b/gdk/x11/gdkmonitor-x11.c
@@ -0,0 +1,93 @@
+/*
+ * 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-x11.h"
+#include "gdkscreen-x11.h"
+
+
+G_DEFINE_TYPE (GdkX11Monitor, gdk_x11_monitor, GDK_TYPE_MONITOR)
+
+static gboolean
+gdk_monitor_has_fullscreen_window (GdkMonitor *monitor)
+{
+ GdkScreen *screen = gdk_display_get_default_screen (monitor->display);
+ GList *toplevels, *l;
+ GdkWindow *window;
+ gboolean has_fullscreen;
+
+ toplevels = gdk_screen_get_toplevel_windows (screen);
+
+ has_fullscreen = FALSE;
+ for (l = toplevels; l; l = l->next)
+ {
+ window = l->data;
+
+ if ((gdk_window_get_state (window) & GDK_WINDOW_STATE_FULLSCREEN) == 0)
+ continue;
+
+ if (gdk_window_get_fullscreen_mode (window) == GDK_FULLSCREEN_ON_ALL_MONITORS ||
+ gdk_display_get_monitor_at_window (monitor->display, window) == monitor)
+ {
+ has_fullscreen = TRUE;
+ break;
+ }
+ }
+
+ g_list_free (toplevels);
+
+ return has_fullscreen;
+}
+
+static void
+gdk_x11_monitor_get_workarea (GdkMonitor *monitor,
+ GdkRectangle *dest)
+{
+ GdkScreen *screen = gdk_display_get_default_screen (monitor->display);
+ GdkRectangle workarea;
+
+ gdk_monitor_get_geometry (monitor, dest);
+
+ /* The EWMH constrains workarea to be a rectangle, so it
+ * can't adequately deal with L-shaped monitor arrangements.
+ * As a workaround, we ignore the workarea for anything
+ * but the primary monitor. Since that is where the 'desktop
+ * chrome' usually lives, this works ok in practice.
+ */
+ if (gdk_monitor_is_primary (monitor) &&
+ !gdk_monitor_has_fullscreen_window (monitor))
+ {
+ gdk_x11_screen_get_work_area (screen, &workarea);
+ if (gdk_rectangle_intersect (dest, &workarea, &workarea))
+ *dest = workarea;
+ }
+}
+
+static void
+gdk_x11_monitor_init (GdkX11Monitor *monitor)
+{
+}
+
+static void
+gdk_x11_monitor_class_init (GdkX11MonitorClass *class)
+{
+ GDK_MONITOR_CLASS (class)->get_workarea = gdk_x11_monitor_get_workarea;
+}
diff --git a/gdk/x11/gdkmonitor-x11.h b/gdk/x11/gdkmonitor-x11.h
new file mode 100644
index 0000000..de8b1dc
--- /dev/null
+++ b/gdk/x11/gdkmonitor-x11.h
@@ -0,0 +1,43 @@
+/*
+ * 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_X11_MONITOR_PRIVATE_H__
+#define __GDK_X11_MONITOR_PRIVATE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <X11/Xlib.h>
+
+#include "gdkmonitorprivate.h"
+
+#include "gdkx11monitor.h"
+
+
+struct _GdkX11Monitor
+{
+ GdkMonitor parent;
+
+ XID output;
+ guint add : 1;
+ guint remove : 1;
+};
+
+struct _GdkX11MonitorClass {
+ GdkMonitorClass parent_class;
+};
+
+#endif
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index a840182..3e608bf 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -25,7 +25,7 @@
#include "gdkdisplay-x11.h"
#include "gdkprivate-x11.h"
#include "xsettings-client.h"
-#include "gdkmonitorprivate.h"
+#include "gdkmonitor-x11.h"
#include <glib.h>
@@ -50,9 +50,6 @@ static void gdk_x11_screen_dispose (GObject *object);
static void gdk_x11_screen_finalize (GObject *object);
static void init_randr_support (GdkScreen *screen);
-static void gdk_x11_monitor_get_workarea (GdkMonitor *monitor,
- GdkRectangle *workarea);
-
enum
{
WINDOW_MANAGER_CHANGED,
@@ -71,31 +68,6 @@ struct _NetWmSupportedAtoms
gulong n_atoms;
};
-struct _GdkX11Monitor
-{
- GdkMonitor parent;
-
- XID output;
- guint add : 1;
- guint remove : 1;
-};
-
-typedef struct _GdkX11Monitor GdkX11Monitor;
-typedef GdkMonitorClass GdkX11MonitorClass;
-
-G_DEFINE_TYPE (GdkX11Monitor, gdk_x11_monitor, GDK_TYPE_MONITOR);
-
-static void
-gdk_x11_monitor_init (GdkX11Monitor *monitor)
-{
-}
-
-static void
-gdk_x11_monitor_class_init (GdkX11MonitorClass *class)
-{
- GDK_MONITOR_CLASS (class)->get_workarea = gdk_x11_monitor_get_workarea;
-}
-
static void
gdk_x11_screen_init (GdkX11Screen *screen)
{
@@ -261,9 +233,9 @@ get_current_desktop (GdkScreen *screen)
return workspace;
}
-static void
-get_work_area (GdkScreen *screen,
- GdkRectangle *area)
+void
+gdk_x11_screen_get_work_area (GdkScreen *screen,
+ GdkRectangle *area)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
Atom workarea;
@@ -337,61 +309,6 @@ out:
XFree (ret_workarea);
}
-static gboolean
-gdk_monitor_has_fullscreen_window (GdkMonitor *monitor)
-{
- GdkScreen *screen = gdk_display_get_default_screen (monitor->display);
- GList *toplevels, *l;
- GdkWindow *window;
- gboolean has_fullscreen;
-
- toplevels = gdk_screen_get_toplevel_windows (screen);
-
- has_fullscreen = FALSE;
- for (l = toplevels; l; l = l->next)
- {
- window = l->data;
-
- if ((gdk_window_get_state (window) & GDK_WINDOW_STATE_FULLSCREEN) == 0)
- continue;
-
- if (gdk_window_get_fullscreen_mode (window) == GDK_FULLSCREEN_ON_ALL_MONITORS ||
- gdk_display_get_monitor_at_window (monitor->display, window) == monitor)
- {
- has_fullscreen = TRUE;
- break;
- }
- }
-
- g_list_free (toplevels);
-
- return has_fullscreen;
-}
-
-static void
-gdk_x11_monitor_get_workarea (GdkMonitor *monitor,
- GdkRectangle *dest)
-{
- GdkScreen *screen = gdk_display_get_default_screen (monitor->display);
- GdkRectangle workarea;
-
- gdk_monitor_get_geometry (monitor, dest);
-
- /* The EWMH constrains workarea to be a rectangle, so it
- * can't adequately deal with L-shaped monitor arrangements.
- * As a workaround, we ignore the workarea for anything
- * but the primary monitor. Since that is where the 'desktop
- * chrome' usually lives, this works ok in practice.
- */
- if (gdk_monitor_is_primary (monitor) &&
- !gdk_monitor_has_fullscreen_window (monitor))
- {
- get_work_area (screen, &workarea);
- if (gdk_rectangle_intersect (dest, &workarea, &workarea))
- *dest = workarea;
- }
-}
-
static GdkVisual *
gdk_x11_screen_get_rgba_visual (GdkScreen *screen)
{
@@ -570,7 +487,7 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
monitor->remove = FALSE;
else
{
- monitor = g_object_new (gdk_x11_monitor_get_type (),
+ monitor = g_object_new (GDK_TYPE_X11_MONITOR,
"display", display,
NULL);
monitor->output = output;
diff --git a/gdk/x11/gdkscreen-x11.h b/gdk/x11/gdkscreen-x11.h
index 900218a..3b0fb35 100644
--- a/gdk/x11/gdkscreen-x11.h
+++ b/gdk/x11/gdkscreen-x11.h
@@ -119,6 +119,8 @@ void _gdk_x11_screen_get_edge_monitors (GdkScreen *screen,
gint *right);
void _gdk_x11_screen_set_window_scale (GdkX11Screen *x11_screen,
int scale);
+void gdk_x11_screen_get_work_area (GdkScreen *screen,
+ GdkRectangle *area);
G_END_DECLS
diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h
index ae05fa6..1f64bcc 100644
--- a/gdk/x11/gdkx.h
+++ b/gdk/x11/gdkx.h
@@ -45,6 +45,7 @@
#include <gdk/x11/gdkx11dnd.h>
#include <gdk/x11/gdkx11glcontext.h>
#include <gdk/x11/gdkx11keys.h>
+#include <gdk/x11/gdkx11monitor.h>
#include <gdk/x11/gdkx11property.h>
#include <gdk/x11/gdkx11screen.h>
#include <gdk/x11/gdkx11selection.h>
diff --git a/gdk/x11/gdkx11monitor.h b/gdk/x11/gdkx11monitor.h
new file mode 100644
index 0000000..e175c4a
--- /dev/null
+++ b/gdk/x11/gdkx11monitor.h
@@ -0,0 +1,46 @@
+/*
+ * gdkx11monitor.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_X11_MONITOR_H__
+#define __GDK_X11_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_X11_MONITOR (gdk_x11_monitor_get_type ())
+#define GDK_X11_MONITOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X11_MONITOR,
GdkX11Monitor))
+#define GDK_IS_X11_MONITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X11_MONITOR))
+
+typedef struct _GdkX11Monitor GdkX11Monitor;
+typedef struct _GdkX11MonitorClass GdkX11MonitorClass;
+
+GDK_AVAILABLE_IN_3_22
+GType gdk_x11_monitor_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GDK_X11_MONITOR_H__ */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]