summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/screen-private.h3
-rw-r--r--src/core/screen.c50
-rw-r--r--src/include/common.h4
-rw-r--r--src/ui/tabpopup.c43
-rw-r--r--src/ui/theme.c6
-rw-r--r--src/ui/ui.c31
6 files changed, 96 insertions, 41 deletions
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index c1552ab0..6cd720d7 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -36,6 +36,7 @@
#include "display-private.h"
#include "screen.h"
#include <X11/Xutil.h>
+#include <gdk/gdk.h>
#include "ui.h"
typedef struct _MetaXineramaScreenInfo MetaXineramaScreenInfo;
@@ -193,6 +194,8 @@ void meta_screen_update_workspace_layout (MetaScreen *scree
void meta_screen_update_workspace_names (MetaScreen *screen);
void meta_screen_queue_workarea_recalc (MetaScreen *screen);
+GdkMonitor* meta_screen_get_current_monitor (void);
+
Window meta_create_offscreen_window (Display *xdisplay,
Window parent,
long valuemask);
diff --git a/src/core/screen.c b/src/core/screen.c
index 4b74ed72..8e1448ec 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1214,7 +1214,7 @@ meta_screen_update_cursor (MetaScreen *screen)
XFreeCursor (screen->display->xdisplay, xcursor);
}
-#define MAX_PREVIEW_SIZE 150.0
+#define MAX_PREVIEW_SCALE 10.0
static GdkPixbuf *
get_window_pixbuf (MetaWindow *window,
@@ -1224,6 +1224,8 @@ get_window_pixbuf (MetaWindow *window,
MetaDisplay *display;
cairo_surface_t *surface;
GdkPixbuf *pixbuf, *scaled;
+ GdkMonitor *monitor;
+ GdkRectangle rect;
double ratio;
display = window->display;
@@ -1246,17 +1248,30 @@ get_window_pixbuf (MetaWindow *window,
*width = gdk_pixbuf_get_width (pixbuf);
*height = gdk_pixbuf_get_height (pixbuf);
- /* Scale pixbuf to max dimension MAX_PREVIEW_SIZE */
+ monitor = meta_screen_get_current_monitor ();
+ if (monitor != NULL)
+ {
+ gdk_monitor_get_geometry (monitor, &rect);
+ }
+ else
+ {
+ rect.width = window->screen->rect.width;
+ rect.height = window->screen->rect.height;
+ }
+
+ /* Scale pixbuf to max dimension based on monitor size */
if (*width > *height)
{
- ratio = ((double) *width) / MAX_PREVIEW_SIZE;
- *width = (int) MAX_PREVIEW_SIZE;
+ int max_preview_width = rect.width / MAX_PREVIEW_SCALE;
+ ratio = ((double) *width) / max_preview_width;
+ *width = (int) max_preview_width;
*height = (int) (((double) *height) / ratio);
}
else
{
- ratio = ((double) *height) / MAX_PREVIEW_SIZE;
- *height = (int) MAX_PREVIEW_SIZE;
+ int max_preview_height = rect.height / MAX_PREVIEW_SCALE;
+ ratio = ((double) *height) / max_preview_height;
+ *height = (int) max_preview_height;
*width = (int) (((double) *width) / ratio);
}
@@ -1797,6 +1812,29 @@ meta_screen_get_current_xinerama (MetaScreen *screen)
return &screen->xinerama_infos[screen->last_xinerama_index];
}
+GdkMonitor *
+meta_screen_get_current_monitor ()
+{
+ GdkDisplay *display;
+ GdkSeat *seat;
+ GdkDevice *device;
+ GdkMonitor *current;
+ gint x, y;
+
+ display = gdk_display_get_default ();
+ seat = gdk_display_get_default_seat (display);
+ device = gdk_seat_get_pointer (seat);
+
+ gdk_device_get_position (device, NULL, &x, &y);
+ current = gdk_display_get_monitor_at_point (display, x, y);
+
+ if (current != NULL) {
+ return current;
+ }
+
+ return gdk_display_get_primary_monitor (display);
+}
+
#define _NET_WM_ORIENTATION_HORZ 0
#define _NET_WM_ORIENTATION_VERT 1
diff --git a/src/include/common.h b/src/include/common.h
index 83b750a9..81937307 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -301,8 +301,8 @@ struct _MetaButtonLayout
};
/* should investigate changing these to whatever most apps use */
-#define META_ICON_WIDTH 32
-#define META_ICON_HEIGHT 32
+#define META_ICON_WIDTH 48
+#define META_ICON_HEIGHT 48
#define META_MINI_ICON_WIDTH 16
#define META_MINI_ICON_HEIGHT 16
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);
}