[mutter] screen: Add new public meta_screen_get_current_monitor API



commit 45952093463e5d354e4f0d7c4ded6ab0d601d959
Author: Tim L <tim feathertop org>
Date:   Fri Jun 8 18:21:10 2012 +1000

    screen: Add new public meta_screen_get_current_monitor API
    
    Similar to meta_screen_get_primary_monitor, this returns a monitor index.
    The monitor that the pointer is on. The previous private implementation
    has been renamed to meta_screen_get_current_monitor_info.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=642591

 src/core/place.c          |    6 +++---
 src/core/screen-private.h |    2 +-
 src/core/screen.c         |   20 ++++++++++++++++++--
 src/core/window.c         |    4 ++--
 src/meta/screen.h         |    1 +
 5 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/src/core/place.c b/src/core/place.c
index 7f21f6f..7a5eb09 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -137,7 +137,7 @@ find_next_cascade (MetaWindow *window,
    */
 
   current = meta_screen_get_current_monitor (window->screen);
-  meta_window_get_work_area_for_monitor (window, current->number, &work_area);
+  meta_window_get_work_area_for_monitor (window, current, &work_area);
 
   cascade_x = MAX (0, work_area.x);
   cascade_y = MAX (0, work_area.y);
@@ -815,7 +815,7 @@ meta_window_place (MetaWindow        *window,
       int w, h;
 
       /* Warning, this function is a round trip! */
-      xi = meta_screen_get_current_monitor (window->screen);
+      xi = meta_screen_get_current_monitor_info (window->screen);
 
       w = xi->rect.width;
       h = xi->rect.height;
@@ -860,7 +860,7 @@ meta_window_place (MetaWindow        *window,
   }
 
   /* Warning, this is a round trip! */
-  xi = meta_screen_get_current_monitor (window->screen);
+  xi = meta_screen_get_current_monitor_info (window->screen);
   
   /* "Origin" placement algorithm */
   x = xi->rect.x;
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index bd1917b..4576f28 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -184,7 +184,7 @@ void          meta_screen_tile_preview_hide            (MetaScreen    *screen);
 MetaWindow*   meta_screen_get_mouse_window     (MetaScreen                 *screen,
                                                 MetaWindow                 *not_this_one);
 
-const MetaMonitorInfo* meta_screen_get_current_monitor    (MetaScreen    *screen);
+const MetaMonitorInfo* meta_screen_get_current_monitor_info   (MetaScreen    *screen);
 const MetaMonitorInfo* meta_screen_get_monitor_for_rect   (MetaScreen    *screen,
                                                            MetaRectangle *rect);
 const MetaMonitorInfo* meta_screen_get_monitor_for_window (MetaScreen    *screen,
diff --git a/src/core/screen.c b/src/core/screen.c
index 328328f..ec61694 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -2054,7 +2054,7 @@ meta_screen_get_natural_monitor_list (MetaScreen *screen,
       visited[i] = FALSE;
     }
 
-  current = meta_screen_get_current_monitor (screen);
+  current = meta_screen_get_current_monitor_info (screen);
   monitor_queue = g_queue_new ();
   g_queue_push_tail (monitor_queue, (gpointer) current);
   visited[current->number] = TRUE;
@@ -2121,6 +2121,22 @@ meta_screen_get_natural_monitor_list (MetaScreen *screen,
 }
 
 const MetaMonitorInfo*
+meta_screen_get_current_monitor_info (MetaScreen *screen)
+{
+    int monitor_index;
+    monitor_index = meta_screen_get_current_monitor (screen);
+    return &screen->monitor_infos[monitor_index];
+}
+
+/**
+ * meta_screen_get_current_monitor:
+ * @screen: a #MetaScreen
+ *
+ * Gets the index of the monitor that currently has the mouse pointer.
+ *
+ * Return value: a monitor index
+ */
+int
 meta_screen_get_current_monitor (MetaScreen *screen)
 {
   if (screen->n_monitor_infos == 1)
@@ -2166,7 +2182,7 @@ meta_screen_get_current_monitor (MetaScreen *screen)
                   screen->last_monitor_index);
     }
 
-  return &screen->monitor_infos[screen->last_monitor_index];
+  return screen->last_monitor_index;
 }
 
 /**
diff --git a/src/core/window.c b/src/core/window.c
index b033024..8da7d72 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -3682,7 +3682,7 @@ meta_window_can_tile_side_by_side (MetaWindow *window)
     return FALSE;
 
   monitor = meta_screen_get_current_monitor (window->screen);
-  meta_window_get_work_area_for_monitor (window, monitor->number, &tile_area);
+  meta_window_get_work_area_for_monitor (window, monitor, &tile_area);
 
   /* Do not allow tiling in portrait orientation */
   if (tile_area.height > tile_area.width)
@@ -8620,7 +8620,7 @@ update_move (MetaWindow  *window,
        * refers to the monitor which contains the largest part of the window,
        * the latter to the one where the pointer is located.
        */
-      monitor = meta_screen_get_current_monitor (window->screen);
+      monitor = meta_screen_get_current_monitor_info (window->screen);
       meta_window_get_work_area_for_monitor (window,
                                              monitor->number,
                                              &work_area);
diff --git a/src/meta/screen.h b/src/meta/screen.h
index 06297cc..4fd2391 100644
--- a/src/meta/screen.h
+++ b/src/meta/screen.h
@@ -77,6 +77,7 @@ MetaWorkspace * meta_screen_get_active_workspace (MetaScreen *screen);
 
 int  meta_screen_get_n_monitors       (MetaScreen    *screen);
 int  meta_screen_get_primary_monitor  (MetaScreen    *screen);
+int  meta_screen_get_current_monitor  (MetaScreen    *screen);
 void meta_screen_get_monitor_geometry (MetaScreen    *screen,
                                        int            monitor,
                                        MetaRectangle *geometry);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]