Skip to content

Commit fad23c9

Browse files
vkarehlukefromdc
authored andcommitted
screen: Remove get_current_monitor in favor of get_current_xinerama
Since xinerama already contains information on the monitor and its rectangle, there is no need to go through Gdk to get this information again.
1 parent 8abba9a commit fad23c9

File tree

4 files changed

+10
-56
lines changed

4 files changed

+10
-56
lines changed

‎src/core/screen-private.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "display-private.h"
3737
#include "screen.h"
3838
#include <X11/Xutil.h>
39-
#include <gdk/gdk.h>
4039
#include "ui.h"
4140

4241
typedef struct _MetaXineramaScreenInfo MetaXineramaScreenInfo;
@@ -194,8 +193,6 @@ void meta_screen_update_workspace_layout (MetaScreen *scree
194193
void meta_screen_update_workspace_names (MetaScreen *screen);
195194
void meta_screen_queue_workarea_recalc (MetaScreen *screen);
196195

197-
GdkMonitor* meta_screen_get_current_monitor (void);
198-
199196
Window meta_create_offscreen_window (Display *xdisplay,
200197
Window parent,
201198
long valuemask);

‎src/core/screen.c‎

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,7 @@ get_window_pixbuf (MetaWindow *window,
12241224
MetaDisplay *display;
12251225
cairo_surface_t *surface;
12261226
GdkPixbuf *pixbuf, *scaled;
1227-
GdkMonitor *monitor;
1228-
GdkRectangle rect;
1227+
const MetaXineramaScreenInfo *current;
12291228
double ratio;
12301229

12311230
display = window->display;
@@ -1248,28 +1247,19 @@ get_window_pixbuf (MetaWindow *window,
12481247
*width = gdk_pixbuf_get_width (pixbuf);
12491248
*height = gdk_pixbuf_get_height (pixbuf);
12501249

1251-
monitor = meta_screen_get_current_monitor ();
1252-
if (monitor != NULL)
1253-
{
1254-
gdk_monitor_get_geometry (monitor, &rect);
1255-
}
1256-
else
1257-
{
1258-
rect.width = window->screen->rect.width;
1259-
rect.height = window->screen->rect.height;
1260-
}
1250+
current = meta_screen_get_current_xinerama (window->screen);
12611251

12621252
/* Scale pixbuf to max dimension based on monitor size */
12631253
if (*width > *height)
12641254
{
1265-
int max_preview_width = rect.width / MAX_PREVIEW_SCALE;
1255+
int max_preview_width = current->rect.width / MAX_PREVIEW_SCALE;
12661256
ratio = ((double) *width) / max_preview_width;
12671257
*width = (int) max_preview_width;
12681258
*height = (int) (((double) *height) / ratio);
12691259
}
12701260
else
12711261
{
1272-
int max_preview_height = rect.height / MAX_PREVIEW_SCALE;
1262+
int max_preview_height = current->rect.height / MAX_PREVIEW_SCALE;
12731263
ratio = ((double) *height) / max_preview_height;
12741264
*height = (int) max_preview_height;
12751265
*width = (int) (((double) *width) / ratio);
@@ -1812,29 +1802,6 @@ meta_screen_get_current_xinerama (MetaScreen *screen)
18121802
return &screen->xinerama_infos[screen->last_xinerama_index];
18131803
}
18141804

1815-
GdkMonitor *
1816-
meta_screen_get_current_monitor ()
1817-
{
1818-
GdkDisplay *display;
1819-
GdkSeat *seat;
1820-
GdkDevice *device;
1821-
GdkMonitor *current;
1822-
gint x, y;
1823-
1824-
display = gdk_display_get_default ();
1825-
seat = gdk_display_get_default_seat (display);
1826-
device = gdk_seat_get_pointer (seat);
1827-
1828-
gdk_device_get_position (device, NULL, &x, &y);
1829-
current = gdk_display_get_monitor_at_point (display, x, y);
1830-
1831-
if (current != NULL) {
1832-
return current;
1833-
}
1834-
1835-
return gdk_display_get_primary_monitor (display);
1836-
}
1837-
18381805
#define _NET_WM_ORIENTATION_HORZ 0
18391806
#define _NET_WM_ORIENTATION_VERT 1
18401807

‎src/core/window.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7197,8 +7197,8 @@ update_move (MetaWindow *window,
71977197
* inside edge, because we don't want to force users to maximize
71987198
* windows they are placing near the top of their screens.
71997199
*
7200-
* The "current" idea of meta_window_get_work_area_current_monitor() and
7201-
* meta_screen_get_current_monitor() is slightly different: the former
7200+
* The "current" idea of meta_window_get_work_area_for_xinerama() and
7201+
* meta_screen_get_current_xinerama() is slightly different: the former
72027202
* refers to the monitor which contains the largest part of the window,
72037203
* the latter to the one where the pointer is located.
72047204
*/

‎src/ui/tabpopup.c‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -760,34 +760,24 @@ static GtkWidget*
760760
selectable_workspace_new (MetaWorkspace *workspace, int entry_count)
761761
{
762762
GtkWidget *widget;
763-
GdkMonitor *monitor;
764-
GdkRectangle rect;
763+
const MetaXineramaScreenInfo *current;
765764
int mini_workspace_width, mini_workspace_height;
766765
double mini_workspace_ratio;
767766

768767
widget = g_object_new (meta_select_workspace_get_type (), NULL);
769768

770-
monitor = meta_screen_get_current_monitor ();
771-
if (monitor != NULL)
772-
{
773-
gdk_monitor_get_geometry (monitor, &rect);
774-
}
775-
else
776-
{
777-
rect.width = workspace->screen->rect.width;
778-
rect.height = workspace->screen->rect.height;
779-
}
769+
current = meta_screen_get_current_xinerama (workspace->screen);
780770

781771
if (workspace->screen->rect.width < workspace->screen->rect.height)
782772
{
783773
mini_workspace_ratio = (double) workspace->screen->rect.width / (double) workspace->screen->rect.height;
784-
mini_workspace_height = (int) ((double) rect.height / entry_count - SELECT_OUTLINE_WIDTH * 2);
774+
mini_workspace_height = (int) ((double) current->rect.height / entry_count - SELECT_OUTLINE_WIDTH * 2);
785775
mini_workspace_width = (int) ((double) mini_workspace_height * mini_workspace_ratio);
786776
}
787777
else
788778
{
789779
mini_workspace_ratio = (double) workspace->screen->rect.height / (double) workspace->screen->rect.width;
790-
mini_workspace_width = (int) ((double) rect.width / entry_count - SELECT_OUTLINE_WIDTH * 2);
780+
mini_workspace_width = (int) ((double) current->rect.width / entry_count - SELECT_OUTLINE_WIDTH * 2);
791781
mini_workspace_height = (int) ((double) mini_workspace_width * mini_workspace_ratio);
792782
}
793783

0 commit comments

Comments
 (0)