[mutter] Add API for getting work area given a logical monitor
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Add API for getting work area given a logical monitor
- Date: Wed, 25 Jan 2017 08:30:42 +0000 (UTC)
commit 79fd91ec350677553ca1a678dc72468cbf759ed8
Author: Jonas Ådahl <jadahl gmail com>
Date: Tue Nov 29 11:48:52 2016 +0800
Add API for getting work area given a logical monitor
To complement the current API which takes an index referencing a
logical monitor in the logical monitor array, add API that takes a
direct reference to the logical monitor itself. The intention is to
replace the usage of the index based API with one that doesn't rely on
internal implementation details.
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/core/window-private.h | 4 ++++
src/core/window.c | 39 +++++++++++++++++++--------------------
src/core/workspace-private.h | 4 ++++
src/core/workspace.c | 10 ++++++++++
4 files changed, 37 insertions(+), 20 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 776ecca..51d2a5a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -630,6 +630,10 @@ gboolean meta_window_handle_mouse_grab_op_event (MetaWindow *window,
GList* meta_window_get_workspaces (MetaWindow *window);
+void meta_window_get_work_area_for_logical_monitor (MetaWindow *window,
+ MetaLogicalMonitor *logical_monitor,
+ MetaRectangle *area);
+
int meta_window_get_current_tile_monitor_number (MetaWindow *window);
void meta_window_get_current_tile_area (MetaWindow *window,
MetaRectangle *tile_area);
diff --git a/src/core/window.c b/src/core/window.c
index 5013609..be31191 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -6095,32 +6095,25 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
}
}
-static void
-get_work_area_monitor (MetaWindow *window,
- MetaRectangle *area,
- int which_monitor)
+void
+meta_window_get_work_area_for_logical_monitor (MetaWindow *window,
+ MetaLogicalMonitor *logical_monitor,
+ MetaRectangle *area)
{
- MetaBackend *backend = meta_get_backend ();
- MetaMonitorManager *monitor_manager =
- meta_backend_get_monitor_manager (backend);
- MetaLogicalMonitor *logical_monitors;
GList *tmp;
- g_assert (which_monitor >= 0);
-
- logical_monitors = meta_monitor_manager_get_logical_monitors (monitor_manager,
- NULL);
+ g_assert (logical_monitor);
/* Initialize to the whole monitor */
- *area = logical_monitors[which_monitor].rect;
+ *area = logical_monitor->rect;
tmp = meta_window_get_workspaces (window);
while (tmp != NULL)
{
MetaRectangle workspace_work_area;
- meta_workspace_get_work_area_for_monitor (tmp->data,
- which_monitor,
- &workspace_work_area);
+ meta_workspace_get_work_area_for_logical_monitor (tmp->data,
+ logical_monitor,
+ &workspace_work_area);
meta_rectangle_intersect (area,
&workspace_work_area,
area);
@@ -6129,7 +6122,7 @@ get_work_area_monitor (MetaWindow *window,
meta_topic (META_DEBUG_WORKAREA,
"Window %s monitor %d has work area %d,%d %d x %d\n",
- window->desc, which_monitor,
+ window->desc, logical_monitor->number,
area->x, area->y, area->width, area->height);
}
@@ -6163,11 +6156,17 @@ meta_window_get_work_area_for_monitor (MetaWindow *window,
int which_monitor,
MetaRectangle *area)
{
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend);
+ MetaLogicalMonitor *logical_monitor;
+
g_return_if_fail (which_monitor >= 0);
- get_work_area_monitor (window,
- area,
- which_monitor);
+ logical_monitor =
+ meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
+ which_monitor);
+
+ meta_window_get_work_area_for_logical_monitor (window, logical_monitor, area);
}
/**
diff --git a/src/core/workspace-private.h b/src/core/workspace-private.h
index e75c926..594b563 100644
--- a/src/core/workspace-private.h
+++ b/src/core/workspace-private.h
@@ -82,6 +82,10 @@ void meta_workspace_remove_window (MetaWorkspace *workspace,
void meta_workspace_relocate_windows (MetaWorkspace *workspace,
MetaWorkspace *new_home);
+void meta_workspace_get_work_area_for_logical_monitor (MetaWorkspace *workspace,
+ MetaLogicalMonitor *logical_monitor,
+ MetaRectangle *area);
+
void meta_workspace_invalidate_work_area (MetaWorkspace *workspace);
GList* meta_workspace_get_onscreen_region (MetaWorkspace *workspace);
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 5ea817b..1633c80 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -1006,6 +1006,16 @@ meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
meta_workspace_invalidate_work_area (workspace);
}
+void
+meta_workspace_get_work_area_for_logical_monitor (MetaWorkspace *workspace,
+ MetaLogicalMonitor *logical_monitor,
+ MetaRectangle *area)
+{
+ meta_workspace_get_work_area_for_monitor (workspace,
+ logical_monitor->number,
+ area);
+}
+
/**
* meta_workspace_get_work_area_for_monitor:
* @workspace: a #MetaWorkspace
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]