Skip to content

Commit 8abba9a

Browse files
vkarehlukefromdc
authored andcommitted
Increase icon size on tab and workspace popups
Alt+Tab and Workspace popups should be sized relative to the monitor size. This way they look nice and large regardless of the display resolution. Also, given much larger modern resolutions, icon sizes should be larger by default.
1 parent a931b08 commit 8abba9a

File tree

6 files changed

+96
-41
lines changed

6 files changed

+96
-41
lines changed

‎src/core/screen-private.h‎

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

4142
typedef struct _MetaXineramaScreenInfo MetaXineramaScreenInfo;
@@ -193,6 +194,8 @@ void meta_screen_update_workspace_layout (MetaScreen *scree
193194
void meta_screen_update_workspace_names (MetaScreen *screen);
194195
void meta_screen_queue_workarea_recalc (MetaScreen *screen);
195196

197+
GdkMonitor* meta_screen_get_current_monitor (void);
198+
196199
Window meta_create_offscreen_window (Display *xdisplay,
197200
Window parent,
198201
long valuemask);

‎src/core/screen.c‎

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ meta_screen_update_cursor (MetaScreen *screen)
12141214
XFreeCursor (screen->display->xdisplay, xcursor);
12151215
}
12161216

1217-
#define MAX_PREVIEW_SIZE 150.0
1217+
#define MAX_PREVIEW_SCALE 10.0
12181218

12191219
static GdkPixbuf *
12201220
get_window_pixbuf (MetaWindow *window,
@@ -1224,6 +1224,8 @@ get_window_pixbuf (MetaWindow *window,
12241224
MetaDisplay *display;
12251225
cairo_surface_t *surface;
12261226
GdkPixbuf *pixbuf, *scaled;
1227+
GdkMonitor *monitor;
1228+
GdkRectangle rect;
12271229
double ratio;
12281230

12291231
display = window->display;
@@ -1246,17 +1248,30 @@ get_window_pixbuf (MetaWindow *window,
12461248
*width = gdk_pixbuf_get_width (pixbuf);
12471249
*height = gdk_pixbuf_get_height (pixbuf);
12481250

1249-
/* Scale pixbuf to max dimension MAX_PREVIEW_SIZE */
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+
}
1261+
1262+
/* Scale pixbuf to max dimension based on monitor size */
12501263
if (*width > *height)
12511264
{
1252-
ratio = ((double) *width) / MAX_PREVIEW_SIZE;
1253-
*width = (int) MAX_PREVIEW_SIZE;
1265+
int max_preview_width = rect.width / MAX_PREVIEW_SCALE;
1266+
ratio = ((double) *width) / max_preview_width;
1267+
*width = (int) max_preview_width;
12541268
*height = (int) (((double) *height) / ratio);
12551269
}
12561270
else
12571271
{
1258-
ratio = ((double) *height) / MAX_PREVIEW_SIZE;
1259-
*height = (int) MAX_PREVIEW_SIZE;
1272+
int max_preview_height = rect.height / MAX_PREVIEW_SCALE;
1273+
ratio = ((double) *height) / max_preview_height;
1274+
*height = (int) max_preview_height;
12601275
*width = (int) (((double) *width) / ratio);
12611276
}
12621277

@@ -1797,6 +1812,29 @@ meta_screen_get_current_xinerama (MetaScreen *screen)
17971812
return &screen->xinerama_infos[screen->last_xinerama_index];
17981813
}
17991814

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+
18001838
#define _NET_WM_ORIENTATION_HORZ 0
18011839
#define _NET_WM_ORIENTATION_VERT 1
18021840

‎src/include/common.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ struct _MetaButtonLayout
301301
};
302302

303303
/* should investigate changing these to whatever most apps use */
304-
#define META_ICON_WIDTH 32
305-
#define META_ICON_HEIGHT 32
304+
#define META_ICON_WIDTH 48
305+
#define META_ICON_HEIGHT 48
306306
#define META_MINI_ICON_WIDTH 16
307307
#define META_MINI_ICON_HEIGHT 16
308308

‎src/ui/tabpopup.c‎

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf);
6868
static void select_image (GtkWidget *widget);
6969
static void unselect_image (GtkWidget *widget);
7070

71-
static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace);
71+
static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace,
72+
int entry_count);
7273
static void select_workspace (GtkWidget *widget);
7374
static void unselect_workspace (GtkWidget *widget);
7475

@@ -361,7 +362,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries,
361362
}
362363
else
363364
{
364-
image = selectable_workspace_new ((MetaWorkspace *) te->key);
365+
image = selectable_workspace_new ((MetaWorkspace *) te->key, entry_count);
365366
}
366367

367368
te->widget = image;
@@ -753,23 +754,47 @@ struct _MetaSelectWorkspaceClass
753754
static GType meta_select_workspace_get_type (void) G_GNUC_CONST;
754755

755756
#define SELECT_OUTLINE_WIDTH 2
756-
#define MINI_WORKSPACE_WIDTH 48
757+
#define MINI_WORKSPACE_SCALE 2
757758

758759
static GtkWidget*
759-
selectable_workspace_new (MetaWorkspace *workspace)
760+
selectable_workspace_new (MetaWorkspace *workspace, int entry_count)
760761
{
761762
GtkWidget *widget;
762-
double screen_aspect;
763+
GdkMonitor *monitor;
764+
GdkRectangle rect;
765+
int mini_workspace_width, mini_workspace_height;
766+
double mini_workspace_ratio;
763767

764768
widget = g_object_new (meta_select_workspace_get_type (), NULL);
765769

766-
screen_aspect = (double) workspace->screen->rect.height /
767-
(double) workspace->screen->rect.width;
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+
}
780+
781+
if (workspace->screen->rect.width < workspace->screen->rect.height)
782+
{
783+
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);
785+
mini_workspace_width = (int) ((double) mini_workspace_height * mini_workspace_ratio);
786+
}
787+
else
788+
{
789+
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);
791+
mini_workspace_height = (int) ((double) mini_workspace_width * mini_workspace_ratio);
792+
}
768793

769794
/* account for select rect */
770795
gtk_widget_set_size_request (widget,
771-
MINI_WORKSPACE_WIDTH + SELECT_OUTLINE_WIDTH * 2,
772-
MINI_WORKSPACE_WIDTH * screen_aspect + SELECT_OUTLINE_WIDTH * 2);
796+
mini_workspace_width / MINI_WORKSPACE_SCALE,
797+
mini_workspace_height / MINI_WORKSPACE_SCALE);
773798

774799
META_SELECT_WORKSPACE (widget)->workspace = workspace;
775800

‎src/ui/theme.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5341,20 +5341,24 @@ meta_theme_load_image (MetaTheme *theme,
53415341
GError **error)
53425342
{
53435343
GdkPixbuf *pixbuf;
5344+
int scale;
53445345

53455346
pixbuf = g_hash_table_lookup (theme->images_by_filename,
53465347
filename);
53475348

5349+
scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
5350+
53485351
if (pixbuf == NULL)
53495352
{
53505353

53515354
if (g_str_has_prefix (filename, "theme:") &&
53525355
META_THEME_ALLOWS (theme, META_THEME_IMAGES_FROM_ICON_THEMES))
53535356
{
5354-
pixbuf = gtk_icon_theme_load_icon (
5357+
pixbuf = gtk_icon_theme_load_icon_for_scale (
53555358
gtk_icon_theme_get_default (),
53565359
filename+6,
53575360
size_of_theme_icons,
5361+
scale,
53585362
0,
53595363
error);
53605364
if (pixbuf == NULL) return NULL;

‎src/ui/ui.c‎

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ meta_ui_pop_delay_exposes (MetaUI *ui)
569569
}
570570

571571
static GdkPixbuf *
572-
load_default_window_icon (int size)
572+
load_default_window_icon (int size, int scale)
573573
{
574574
GtkIconTheme *theme = gtk_icon_theme_get_default ();
575575
const char *icon_name;
@@ -579,17 +579,19 @@ load_default_window_icon (int size)
579579
else
580580
icon_name = "image-missing";
581581

582-
return gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL);
582+
return gtk_icon_theme_load_icon_for_scale (theme, icon_name, size, scale, 0, NULL);
583583
}
584584

585585
GdkPixbuf*
586586
meta_ui_get_default_window_icon (MetaUI *ui)
587587
{
588588
static GdkPixbuf *default_icon = NULL;
589+
int scale;
589590

590591
if (default_icon == NULL)
591592
{
592-
default_icon = load_default_window_icon (META_ICON_WIDTH);
593+
scale = gtk_widget_get_scale_factor (GTK_WIDGET (ui->frames));
594+
default_icon = load_default_window_icon (META_ICON_WIDTH, scale);
593595
g_assert (default_icon);
594596
}
595597

@@ -602,29 +604,12 @@ GdkPixbuf*
602604
meta_ui_get_default_mini_icon (MetaUI *ui)
603605
{
604606
static GdkPixbuf *default_icon = NULL;
607+
int scale;
605608

606609
if (default_icon == NULL)
607610
{
608-
GtkIconTheme *theme;
609-
gboolean icon_exists;
610-
611-
theme = gtk_icon_theme_get_default ();
612-
613-
icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);
614-
615-
if (icon_exists)
616-
default_icon = gtk_icon_theme_load_icon (theme,
617-
META_DEFAULT_ICON_NAME,
618-
META_MINI_ICON_WIDTH,
619-
0,
620-
NULL);
621-
else
622-
default_icon = gtk_icon_theme_load_icon (theme,
623-
"image-missing",
624-
META_MINI_ICON_WIDTH,
625-
0,
626-
NULL);
627-
611+
scale = gtk_widget_get_scale_factor (GTK_WIDGET (ui->frames));
612+
default_icon = load_default_window_icon (META_MINI_ICON_WIDTH, scale);
628613
g_assert (default_icon);
629614
}
630615

0 commit comments

Comments
 (0)