diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/tabpopup.c | 43 | ||||
-rw-r--r-- | src/ui/theme.c | 6 | ||||
-rw-r--r-- | src/ui/ui.c | 31 |
3 files changed, 47 insertions, 33 deletions
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c index 8cfeb3ec..49524d80 100644 --- a/src/ui/tabpopup.c +++ b/src/ui/tabpopup.c @@ -68,7 +68,8 @@ static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf); static void select_image (GtkWidget *widget); static void unselect_image (GtkWidget *widget); -static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace); +static GtkWidget* selectable_workspace_new (MetaWorkspace *workspace, + int entry_count); static void select_workspace (GtkWidget *widget); static void unselect_workspace (GtkWidget *widget); @@ -361,7 +362,7 @@ meta_ui_tab_popup_new (const MetaTabEntry *entries, } else { - image = selectable_workspace_new ((MetaWorkspace *) te->key); + image = selectable_workspace_new ((MetaWorkspace *) te->key, entry_count); } te->widget = image; @@ -753,23 +754,47 @@ struct _MetaSelectWorkspaceClass static GType meta_select_workspace_get_type (void) G_GNUC_CONST; #define SELECT_OUTLINE_WIDTH 2 -#define MINI_WORKSPACE_WIDTH 48 +#define MINI_WORKSPACE_SCALE 2 static GtkWidget* -selectable_workspace_new (MetaWorkspace *workspace) +selectable_workspace_new (MetaWorkspace *workspace, int entry_count) { GtkWidget *widget; - double screen_aspect; + GdkMonitor *monitor; + GdkRectangle rect; + int mini_workspace_width, mini_workspace_height; + double mini_workspace_ratio; widget = g_object_new (meta_select_workspace_get_type (), NULL); - screen_aspect = (double) workspace->screen->rect.height / - (double) workspace->screen->rect.width; + monitor = meta_screen_get_current_monitor (); + if (monitor != NULL) + { + gdk_monitor_get_geometry (monitor, &rect); + } + else + { + rect.width = workspace->screen->rect.width; + rect.height = workspace->screen->rect.height; + } + + if (workspace->screen->rect.width < workspace->screen->rect.height) + { + mini_workspace_ratio = (double) workspace->screen->rect.width / (double) workspace->screen->rect.height; + mini_workspace_height = (int) ((double) rect.height / entry_count - SELECT_OUTLINE_WIDTH * 2); + mini_workspace_width = (int) ((double) mini_workspace_height * mini_workspace_ratio); + } + else + { + mini_workspace_ratio = (double) workspace->screen->rect.height / (double) workspace->screen->rect.width; + mini_workspace_width = (int) ((double) rect.width / entry_count - SELECT_OUTLINE_WIDTH * 2); + mini_workspace_height = (int) ((double) mini_workspace_width * mini_workspace_ratio); + } /* account for select rect */ gtk_widget_set_size_request (widget, - MINI_WORKSPACE_WIDTH + SELECT_OUTLINE_WIDTH * 2, - MINI_WORKSPACE_WIDTH * screen_aspect + SELECT_OUTLINE_WIDTH * 2); + mini_workspace_width / MINI_WORKSPACE_SCALE, + mini_workspace_height / MINI_WORKSPACE_SCALE); META_SELECT_WORKSPACE (widget)->workspace = workspace; diff --git a/src/ui/theme.c b/src/ui/theme.c index fee9948c..b97b0118 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -5341,20 +5341,24 @@ meta_theme_load_image (MetaTheme *theme, GError **error) { GdkPixbuf *pixbuf; + int scale; pixbuf = g_hash_table_lookup (theme->images_by_filename, filename); + scale = gdk_window_get_scale_factor (gdk_get_default_root_window ()); + if (pixbuf == NULL) { if (g_str_has_prefix (filename, "theme:") && META_THEME_ALLOWS (theme, META_THEME_IMAGES_FROM_ICON_THEMES)) { - pixbuf = gtk_icon_theme_load_icon ( + pixbuf = gtk_icon_theme_load_icon_for_scale ( gtk_icon_theme_get_default (), filename+6, size_of_theme_icons, + scale, 0, error); if (pixbuf == NULL) return NULL; diff --git a/src/ui/ui.c b/src/ui/ui.c index 5cb03a88..b3f40062 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -569,7 +569,7 @@ meta_ui_pop_delay_exposes (MetaUI *ui) } static GdkPixbuf * -load_default_window_icon (int size) +load_default_window_icon (int size, int scale) { GtkIconTheme *theme = gtk_icon_theme_get_default (); const char *icon_name; @@ -579,17 +579,19 @@ load_default_window_icon (int size) else icon_name = "image-missing"; - return gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL); + return gtk_icon_theme_load_icon_for_scale (theme, icon_name, size, scale, 0, NULL); } GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui) { static GdkPixbuf *default_icon = NULL; + int scale; if (default_icon == NULL) { - default_icon = load_default_window_icon (META_ICON_WIDTH); + scale = gtk_widget_get_scale_factor (GTK_WIDGET (ui->frames)); + default_icon = load_default_window_icon (META_ICON_WIDTH, scale); g_assert (default_icon); } @@ -602,29 +604,12 @@ GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui) { static GdkPixbuf *default_icon = NULL; + int scale; if (default_icon == NULL) { - GtkIconTheme *theme; - gboolean icon_exists; - - theme = gtk_icon_theme_get_default (); - - icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME); - - if (icon_exists) - default_icon = gtk_icon_theme_load_icon (theme, - META_DEFAULT_ICON_NAME, - META_MINI_ICON_WIDTH, - 0, - NULL); - else - default_icon = gtk_icon_theme_load_icon (theme, - "image-missing", - META_MINI_ICON_WIDTH, - 0, - NULL); - + scale = gtk_widget_get_scale_factor (GTK_WIDGET (ui->frames)); + default_icon = load_default_window_icon (META_MINI_ICON_WIDTH, scale); g_assert (default_icon); } |