> I use xrandr to decrease the resolution of my display when I connect
> it to my TV. When I change the resolution back to my monitor, a few
> of the icons at the bottom of my dock are deleted.
>
> I already found the place in the code where this happens and changed
> it so that any icon that I dock is never removed. I'd like to make a
> more permanent change to the code, though.
>
> First of all, is this the desired action?
>
> It seems counter-intuitive to me. If I add icons to the dock, I
> expect them to remain there until I remove them, even if the
> resolution changes. Even so, I can understand how it would be back
> for a user to get stuck with icons in the dock that can't be removed.
> (at least, from the GUI)
>
> One option is to have a checkbox in "Expert User Preferences" for
> "Crop dock to screen size (needs restart)".
I implemented this as described.
As my first Window Maker patch, please critique as desired. :)
Thank you.
(Patch is below the dotted line:)
------------------------------------------------------------
From d327fb862c03dd8a500e9658e9cf5b9366e95830 Mon Sep 17 00:00:00 2001
From: David Couzelis <[email protected]>
Date: Thu, 5 Jan 2012 23:38:09 -0500
Subject: [PATCH] Added an "Expert" config option for cropping the dock when
there are more icons than will fit on the screen. This
fixes the behaviour where a user loses docked icons when
using XRANDR to change screen resolutions.
---
WPrefs.app/Expert.c | 5 ++++-
src/WindowMaker.h | 2 ++
src/defaults.c | 2 ++
src/dock.c | 8 +++++---
src/wconfig.h.in | 4 ++--
5 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c
index e86480d..76a7451 100644
--- a/WPrefs.app/Expert.c
+++ b/WPrefs.app/Expert.c
@@ -31,7 +31,7 @@ typedef struct _Panel {
WMWidget *parent;
- WMButton *swi[13];
+ WMButton *swi[14];
} _Panel;
@@ -54,6 +54,7 @@ static void showData(_Panel * panel)
WMSetButtonSelected(panel->swi[10],
GetBoolForKey("BounceAppIconsWhenUrgent"));
WMSetButtonSelected(panel->swi[11],
GetBoolForKey("RaiseAppIconsWhenBouncing"));
WMSetButtonSelected(panel->swi[12],
GetBoolForKey("OpaqueMoveResizeKeyboard"));
+ WMSetButtonSelected(panel->swi[13],
GetBoolForKey("CropDockToScreenSize"));
}
static void createPanel(Panel * p)
@@ -97,6 +98,7 @@ static void createPanel(Panel * p)
WMSetButtonText(panel->swi[10], _("Bounce AppIcons when the
application wants attention."));
WMSetButtonText(panel->swi[11], _("Raise AppIcons when bouncing."));
WMSetButtonText(panel->swi[12], _("Opaque Move,Resize with keyboard."));
+ WMSetButtonText(panel->swi[13], _("Crop dock to screen size (needs
restart)."));
/* If the item is default true, enable the button here */
WMSetButtonEnabled(panel->swi[6], True);
@@ -129,6 +131,7 @@ static void storeDefaults(_Panel * panel)
SetBoolForKey(WMGetButtonSelected(panel->swi[10]),
"BounceAppIconsWhenUrgent");
SetBoolForKey(WMGetButtonSelected(panel->swi[11]),
"RaiseAppIconsWhenBouncing");
SetBoolForKey(WMGetButtonSelected(panel->swi[12]),
"OpaqueMoveResizeKeyboard");
+ SetBoolForKey(WMGetButtonSelected(panel->swi[13]),
"CropDockToScreenSize");
}
Panel *InitExpert(WMScreen * scr, WMWidget * parent)
diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index ccb207b..27502dc 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -425,6 +425,8 @@ typedef struct WPreferences {
int history_lines; /* history of "Run..." dialog */
char cycle_active_head_only; /* Cycle only windows on the
active head */
+ char crop_dock_to_screen_size; /* Dock icons off the screen
will be removed */
+
RImage *swtileImage;
RImage *swbackImage[9];
diff --git a/src/defaults.c b/src/defaults.c
index dab5e64..2db8786 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -386,6 +386,8 @@ WDefaultEntry optionList[] = {
&wPreferences.bounce_appicons_when_urgent, getBool, NULL, NULL,
NULL},
{"RaiseAppIconsWhenBouncing", "NO", NULL,
&wPreferences.raise_appicons_when_bouncing, getBool, NULL, NULL,
NULL},
+ {"CropDockToScreenSize", "NO", NULL,
+ &wPreferences.crop_dock_to_screen_size, getBool, NULL, NULL, NULL},
{"DoubleClickTime", "250", (void *)&wPreferences.dblclick_time,
&wPreferences.dblclick_time, getInt, setDoubleClick, NULL, NULL},
{"AlignSubmenus", "NO", NULL,
diff --git a/src/dock.c b/src/dock.c
index 9d74b49..919f95c 100644
--- a/src/dock.c
+++ b/src/dock.c
@@ -1087,10 +1087,12 @@ WDock *wDockCreate(WScreen * scr, int type)
dock = wmalloc(sizeof(WDock));
memset(dock, 0, sizeof(WDock));
- if (type == WM_CLIP)
- icon_count = CLIP_MAX_ICONS;
- else
+ if (type == WM_CLIP || !wPreferences.crop_dock_to_screen_size) {
+ icon_count = DOCK_MAX_ICONS;
+ } else {
+ /* Crop the dock to the height of the screen */
icon_count = scr->scr_height / wPreferences.icon_size;
+ }
dock->icon_array = wmalloc(sizeof(WAppIcon *) * icon_count);
memset(dock->icon_array, 0, sizeof(WAppIcon *) * icon_count);
diff --git a/src/wconfig.h.in b/src/wconfig.h.in
index 5008ac6..7054b7a 100644
--- a/src/wconfig.h.in
+++ b/src/wconfig.h.in
@@ -325,8 +325,8 @@
* Set this to zero if you want instant raise. */
#define AUTO_RAISE_DELAY 600
-/* Max. number of icons the clip can have */
-#define CLIP_MAX_ICONS 32
+/* Max. number of icons the dock or clip can have */
+#define DOCK_MAX_ICONS 32
/* blink interval when invoking a menu item */
#define MENU_BLINK_DELAY 60000
--
1.7.8.1
--
To unsubscribe, send mail to [email protected].