@@ -68,7 +68,8 @@ static GtkWidget* selectable_image_new (GdkPixbuf *pixbuf);
6868static void select_image (GtkWidget * widget );
6969static 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 );
7273static void select_workspace (GtkWidget * widget );
7374static 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
753754static 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
758759static 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
0 commit comments