From 4e812410ccb9a2ff1c5470b463aebd9945b540e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 13 Dec 2016 10:37:11 +0800 Subject: [PATCH] monitor-manager: Move logical monitor into its own file https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/Makefile.am | 2 + src/backends/meta-backend.c | 2 +- src/backends/meta-logical-monitor.c | 36 ++++++++++ src/backends/meta-logical-monitor.h | 69 +++++++++++++++++++ src/backends/meta-monitor-manager-private.h | 46 ------------- src/backends/meta-monitor-manager.c | 13 +--- src/backends/native/meta-backend-native.c | 1 + src/backends/native/meta-renderer-native.c | 1 + .../x11/meta-monitor-manager-xrandr.c | 1 + src/backends/x11/meta-renderer-x11.c | 1 + src/compositor/meta-surface-actor-wayland.c | 1 + src/compositor/meta-window-actor.c | 1 + src/core/constraints.c | 1 + src/core/display.c | 1 + src/core/keybindings.c | 1 + src/core/place.c | 1 + src/core/screen.c | 1 + src/core/stack.c | 1 + src/core/window.c | 1 + src/core/workspace.c | 1 + src/tests/monitor-unit-tests.c | 1 + src/wayland/meta-wayland-outputs.c | 1 + .../meta-wayland-surface-role-cursor.c | 1 + src/wayland/meta-wayland-xdg-shell.c | 1 + src/wayland/meta-window-wayland.c | 1 + src/x11/window-x11.c | 1 + 26 files changed, 129 insertions(+), 59 deletions(-) create mode 100644 src/backends/meta-logical-monitor.c create mode 100644 src/backends/meta-logical-monitor.h diff --git a/src/Makefile.am b/src/Makefile.am index 15f6077d1..b2509ad0e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -101,6 +101,8 @@ libmutter_la_SOURCES = \ backends/meta-idle-monitor-dbus.h \ backends/meta-input-settings.c \ backends/meta-input-settings-private.h \ + backends/meta-logical-monitor.c \ + backends/meta-logical-monitor.h \ backends/meta-monitor-config.c \ backends/meta-monitor-config.h \ backends/meta-monitor-manager.c \ diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 68917944f..d4ec4e6b4 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -41,7 +41,7 @@ #endif #include "backends/meta-idle-monitor-private.h" - +#include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-manager-dummy.h" static MetaBackend *_backend; diff --git a/src/backends/meta-logical-monitor.c b/src/backends/meta-logical-monitor.c new file mode 100644 index 000000000..19ca43dee --- /dev/null +++ b/src/backends/meta-logical-monitor.c @@ -0,0 +1,36 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2016 Red Hat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include "config.h" + +#include "backends/meta-logical-monitor.h" + +G_DEFINE_TYPE (MetaLogicalMonitor, meta_logical_monitor, G_TYPE_OBJECT) + +static void +meta_logical_monitor_init (MetaLogicalMonitor *logical_monitor) +{ +} + +static void +meta_logical_monitor_class_init (MetaLogicalMonitorClass *klass) +{ +} diff --git a/src/backends/meta-logical-monitor.h b/src/backends/meta-logical-monitor.h new file mode 100644 index 000000000..42002bc3d --- /dev/null +++ b/src/backends/meta-logical-monitor.h @@ -0,0 +1,69 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2016 Red Hat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_LOGICAL_MONITOR_H +#define META_LOGICAL_MONITOR_H + +#include + +#include "backends/meta-monitor-manager-private.h" +#include "meta/boxes.h" + +#define META_MAX_OUTPUTS_PER_MONITOR 4 + +struct _MetaLogicalMonitor +{ + GObject parent; + + int number; + MetaRectangle rect; + /* for tiled monitors these are calculated, from untiled just copied */ + float refresh_rate; + int width_mm; + int height_mm; + gboolean is_primary; + gboolean is_presentation; /* XXX: not yet used */ + gboolean in_fullscreen; + int scale; + + /* The primary or first output for this monitor, 0 if we can't figure out. + It can be matched to a winsys_id of a MetaOutput. + + This is used as an opaque token on reconfiguration when switching from + clone to extened, to decide on what output the windows should go next + (it's an attempt to keep windows on the same monitor, and preferably on + the primary one). + */ + glong winsys_id; + + guint32 tile_group_id; + + int monitor_winsys_xid; + int n_outputs; + MetaOutput *outputs[META_MAX_OUTPUTS_PER_MONITOR]; +}; + +#define META_TYPE_LOGICAL_MONITOR (meta_logical_monitor_get_type ()) +G_DECLARE_FINAL_TYPE (MetaLogicalMonitor, meta_logical_monitor, + META, LOGICAL_MONITOR, + GObject) + +#endif /* META_LOGICAL_MONITOR_H */ diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index 16b59c6cf..53f1e4e48 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -59,11 +59,6 @@ typedef struct _MetaCrtcInfo MetaCrtcInfo; typedef struct _MetaOutputInfo MetaOutputInfo; typedef struct _MetaTileInfo MetaTileInfo; -#define META_TYPE_LOGICAL_MONITOR (meta_logical_monitor_get_type ()) -G_DECLARE_FINAL_TYPE (MetaLogicalMonitor, meta_logical_monitor, - META, LOGICAL_MONITOR, - GObject) - typedef enum { META_MONITOR_TRANSFORM_NORMAL, META_MONITOR_TRANSFORM_90, @@ -202,47 +197,6 @@ struct _MetaCrtcMode GDestroyNotify driver_notify; }; -#define META_MAX_OUTPUTS_PER_MONITOR 4 -/** - * MetaLogicalMonitor: - * - * A structure with high-level information about regions of the whole screen - * output. It corresponds to a subset of the compositor coordinate space, and - * may have one or more actual monitors associated with it. No two logical - * monitors will cover the same screen output. - */ -struct _MetaLogicalMonitor -{ - GObject parent; - - int number; - MetaRectangle rect; - /* for tiled monitors these are calculated, from untiled just copied */ - float refresh_rate; - int width_mm; - int height_mm; - gboolean is_primary; - gboolean is_presentation; /* XXX: not yet used */ - gboolean in_fullscreen; - int scale; - - /* The primary or first output for this monitor, 0 if we can't figure out. - It can be matched to a winsys_id of a MetaOutput. - - This is used as an opaque token on reconfiguration when switching from - clone to extened, to decide on what output the windows should go next - (it's an attempt to keep windows on the same monitor, and preferably on - the primary one). - */ - glong winsys_id; - - guint32 tile_group_id; - - int monitor_winsys_xid; - int n_outputs; - MetaOutput *outputs[META_MAX_OUTPUTS_PER_MONITOR]; -}; - /* * MetaCrtcInfo: * This represents the writable part of a CRTC, as deserialized from DBus diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 2f9efaa14..588c08436 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -37,11 +37,10 @@ #include #include "edid.h" #include "meta-monitor-config.h" +#include "backends/meta-logical-monitor.h" #include "backends/x11/meta-monitor-manager-xrandr.h" #include "meta-backend-private.h" -G_DEFINE_TYPE (MetaLogicalMonitor, meta_logical_monitor, G_TYPE_OBJECT) - enum { CONFIRM_DISPLAY_CHANGE, SIGNALS_LAST @@ -1756,13 +1755,3 @@ meta_monitor_manager_get_is_builtin_display_on (MetaMonitorManager *manager) return meta_monitor_config_get_is_builtin_display_on (manager->config); } - -static void -meta_logical_monitor_init (MetaLogicalMonitor *logical_monitor) -{ -} - -static void -meta_logical_monitor_class_init (MetaLogicalMonitorClass *klass) -{ -} diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index afc08459a..83060d1d2 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -37,6 +37,7 @@ #include "meta-cursor-renderer-native.h" #include "meta-launcher.h" #include "backends/meta-cursor-tracker-private.h" +#include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-manager-private.h" #include "backends/meta-pointer-constraint.h" #include "backends/meta-stage.h" diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 82c4aaa37..5b46cee61 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -50,6 +50,7 @@ #include "backends/meta-backend-private.h" #include "backends/meta-egl.h" #include "backends/meta-egl-ext.h" +#include "backends/meta-logical-monitor.h" #include "backends/meta-renderer-view.h" #include "backends/native/meta-monitor-manager-kms.h" #include "backends/native/meta-renderer-native.h" diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 8bddbe5a4..ec4ccd5fa 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -42,6 +42,7 @@ #include #include #include "meta-monitor-config.h" +#include "backends/meta-logical-monitor.h" #define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) diff --git a/src/backends/x11/meta-renderer-x11.c b/src/backends/x11/meta-renderer-x11.c index bdafc2e94..7d2080d3a 100644 --- a/src/backends/x11/meta-renderer-x11.c +++ b/src/backends/x11/meta-renderer-x11.c @@ -32,6 +32,7 @@ #include "cogl/winsys/cogl-winsys-glx-private.h" #include "cogl/winsys/cogl-winsys-egl-x11-private.h" #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include "backends/meta-renderer.h" #include "backends/meta-renderer-view.h" #include "backends/x11/meta-renderer-x11.h" diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c index cd8975929..cd38fcb70 100644 --- a/src/compositor/meta-surface-actor-wayland.c +++ b/src/compositor/meta-surface-actor-wayland.c @@ -30,6 +30,7 @@ #include #include "meta-shaped-texture-private.h" +#include "backends/meta-logical-monitor.h" #include "wayland/meta-wayland-buffer.h" #include "wayland/meta-wayland-private.h" #include "wayland/meta-window-wayland.h" diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 658a1779d..6b1b3c3fa 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -29,6 +29,7 @@ #include "meta-window-actor-private.h" #include "meta-texture-rectangle.h" #include "region-utils.h" +#include "backends/meta-logical-monitor.h" #include "meta-monitor-manager-private.h" #include "meta-cullable.h" diff --git a/src/core/constraints.c b/src/core/constraints.c index 2aa27648f..281fdddb8 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -28,6 +28,7 @@ #include "place.h" #include #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-manager-private.h" #include diff --git a/src/core/display.c b/src/core/display.c index 998fbae41..a71be5944 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -50,6 +50,7 @@ #include "meta-idle-monitor-dbus.h" #include "meta-cursor-tracker-private.h" #include +#include "backends/meta-logical-monitor.h" #include "backends/native/meta-backend-native.h" #include "backends/x11/meta-backend-x11.h" #include "backends/meta-stage.h" diff --git a/src/core/keybindings.c b/src/core/keybindings.c index b73c79469..b7853e238 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -44,6 +44,7 @@ #define KEY_GRAVE 0x29 /* assume the use of xf86-input-keyboard */ #endif +#include "backends/meta-logical-monitor.h" #include "backends/x11/meta-backend-x11.h" #include "x11/window-x11.h" diff --git a/src/core/place.c b/src/core/place.c index 357184f22..9a584667a 100644 --- a/src/core/place.c +++ b/src/core/place.c @@ -27,6 +27,7 @@ #include "boxes-private.h" #include "place.h" #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include #include #include diff --git a/src/core/screen.c b/src/core/screen.c index 123a7e8ef..67ec51f77 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -45,6 +45,7 @@ #include "meta-cursor-tracker-private.h" #include "boxes-private.h" #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include #include diff --git a/src/core/stack.c b/src/core/stack.c index a9f6d1dac..5895b8980 100644 --- a/src/core/stack.c +++ b/src/core/stack.c @@ -33,6 +33,7 @@ #include #include #include +#include "backends/meta-logical-monitor.h" #include diff --git a/src/core/window.c b/src/core/window.c index a8def44f4..82a8f852f 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -63,6 +63,7 @@ #endif #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" /* Windows that unmaximize to a size bigger than that fraction of the workarea * will be scaled down to that size (while maintaining aspect ratio). diff --git a/src/core/workspace.c b/src/core/workspace.c index 7f56b622e..f6d3c9619 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -33,6 +33,7 @@ #include #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include "screen-private.h" #include #include "workspace-private.h" diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index ade1d914a..9d5a75ab5 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -22,6 +22,7 @@ #include "tests/monitor-unit-tests.h" #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include "tests/meta-monitor-manager-test.h" #define ALL_TRANSFORMS ((1 << (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)) - 1) diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c index 0a74619cb..fd6832dee 100644 --- a/src/wayland/meta-wayland-outputs.c +++ b/src/wayland/meta-wayland-outputs.c @@ -27,6 +27,7 @@ #include "meta-wayland-outputs.h" #include "meta-wayland-private.h" +#include "backends/meta-logical-monitor.h" #include "meta-monitor-manager-private.h" #include diff --git a/src/wayland/meta-wayland-surface-role-cursor.c b/src/wayland/meta-wayland-surface-role-cursor.c index 5b5f9d6c0..6b6c0a002 100644 --- a/src/wayland/meta-wayland-surface-role-cursor.c +++ b/src/wayland/meta-wayland-surface-role-cursor.c @@ -29,6 +29,7 @@ #include "screen-private.h" #include "meta-wayland-private.h" #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" typedef struct _MetaWaylandSurfaceRoleCursorPrivate MetaWaylandSurfaceRoleCursorPrivate; diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index aa355da4a..f26f3be9e 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -25,6 +25,7 @@ #include "wayland/meta-wayland-xdg-shell.h" +#include "backends/meta-logical-monitor.h" #include "core/window-private.h" #include "wayland/meta-wayland.h" #include "wayland/meta-wayland-popup.h" diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 04d3c1ff8..a5bf469b8 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -36,6 +36,7 @@ #include "meta-wayland-surface.h" #include "meta-wayland-xdg-shell.h" #include "backends/meta-backend-private.h" +#include "backends/meta-logical-monitor.h" #include "compositor/meta-surface-actor-wayland.h" struct _MetaWindowWayland diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index b46033c02..fafa9296d 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -50,6 +50,7 @@ #include "session.h" #include "workspace-private.h" +#include "backends/meta-logical-monitor.h" #include "backends/x11/meta-backend-x11.h" struct _MetaWindowX11Class