From f8dd3dc49ec764846b45f507b6e18e1fa1e7adc5 Mon Sep 17 00:00:00 2001 From: Sebastien Bauer Date: Thu, 3 Sep 2009 04:08:58 +0200 Subject: [PATCH] Add option to allow starting DockApps with a single click This patch is from the contrib directory. It adds an option to allow starting DockApps with a single click. It's a handy option that adds only a few lines to the code. It is a good feature patch example because it includes modifications to the WPrefs application so that the feature can be easily enabled or disabled. The one-click ability allows wmaker to integrate more seemlessly with programs like ROX-Filer which can be configured to use single or double click actions. The README in the contrib/ directory says, author: Sebastien Bauer John Morrissey updated for Window Maker 0.65.0 by: Daniel Richard G. updated for Window Maker 0.80.2 by: Martial Daumas update for 0.80.2+ by: steve lion and vlaad --- WPrefs.app/Expert.c | 5 ++++- src/WindowMaker.h | 1 + src/appicon.c | 5 +++++ src/defaults.c | 2 ++ src/dock.c | 15 ++++++++++----- src/icon.c | 4 ++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c index f05fd552..6d4421dc 100644 --- a/WPrefs.app/Expert.c +++ b/WPrefs.app/Expert.c @@ -49,6 +49,7 @@ static void showData(_Panel * panel) WMSetButtonSelected(panel->swi[4], GetBoolForKey("DontConfirmKill")); WMSetButtonSelected(panel->swi[5], GetBoolForKey("DisableBlinking")); WMSetButtonSelected(panel->swi[6], GetBoolForKey("AntialiasedText")); + WMSetButtonSelected(panel->swi[7], GetBoolForKey("SingleClickLaunch")); } static void createPanel(Panel * p) @@ -59,7 +60,7 @@ static void createPanel(Panel * p) panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); - for (i = 0; i < 7; i++) { + for (i = 0; i < 8; i++) { panel->swi[i] = WMCreateSwitchButton(panel->box); WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25); WMMoveWidget(panel->swi[i], 20, 20 + i * 25); @@ -73,6 +74,7 @@ static void createPanel(Panel * p) WMSetButtonText(panel->swi[4], _("Disable confirmation panel for the Kill command.")); WMSetButtonText(panel->swi[5], _("Disable selection animation for selected icons.")); WMSetButtonText(panel->swi[6], _("Smooth font edges (needs restart).")); + WMSetButtonText(panel->swi[7], _("Launch applications and restore windows with a single click.")); WMSetButtonEnabled(panel->swi[6], True); @@ -95,6 +97,7 @@ static void storeDefaults(_Panel * panel) SetBoolForKey(WMGetButtonSelected(panel->swi[4]), "DontConfirmKill"); SetBoolForKey(WMGetButtonSelected(panel->swi[5]), "DisableBlinking"); SetBoolForKey(WMGetButtonSelected(panel->swi[6]), "AntialiasedText"); + SetBoolForKey(WMGetButtonSelected(panel->swi[7]), "SingleClickLaunch"); } Panel *InitExpert(WMScreen * scr, WMWidget * parent) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 3e2035be..d295b4bf 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -471,6 +471,7 @@ typedef struct WPreferences { unsigned int workspace_border_size; /* Size in pixels of the workspace border */ char workspace_border_position; /* Where to leave a workspace border */ + char single_click; /* single click to lauch applications */ RImage *swtileImage; RImage *swbackImage[9]; diff --git a/src/appicon.c b/src/appicon.c index 05a8485d..cac85f4b 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -532,6 +532,7 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event) Bool movingSingle = False; int oldX = x; int oldY = y; + Bool hasMoved = False; if (aicon->editing || WCHECK_STATE(WSTATE_MODAL)) return; @@ -611,6 +612,7 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event) break; case MotionNotify: + hasMoved = True; if (!grabbed) { if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD || abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) { @@ -745,6 +747,9 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event) if (wPreferences.auto_arrange_icons) wArrangeIcons(scr, True); + if (wPreferences.single_click && !hasMoved) + iconDblClick(desc, event); + done = 1; break; } diff --git a/src/defaults.c b/src/defaults.c index d3176006..8fdb3990 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -474,6 +474,8 @@ WDefaultEntry optionList[] = { &wPreferences.attract, getBool, NULL}, {"DisableBlinking", "NO", NULL, &wPreferences.dont_blink, getBool, NULL}, + {"SingleClickLaunch", "NO", NULL, + &wPreferences.single_click, getBool, NULL}, /* style options */ {"MenuStyle", "normal", seMenuStyles, &wPreferences.menu_style, getEnum, setMenuStyle}, diff --git a/src/dock.c b/src/dock.c index a71c36b7..bd5b010f 100644 --- a/src/dock.c +++ b/src/dock.c @@ -3501,7 +3501,7 @@ static void handleDockMove(WDock * dock, WAppIcon * aicon, XEvent * event) #endif } -static void handleIconMove(WDock * dock, WAppIcon * aicon, XEvent * event) +static Bool handleIconMove(WDock *dock, WAppIcon *aicon, XEvent *event) { WScreen *scr = dock->screen_ptr; Window wins[2]; @@ -3518,6 +3518,7 @@ static void handleIconMove(WDock * dock, WAppIcon * aicon, XEvent * event) Bool docked; int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */ int omnipresent = aicon->omnipresent; /* this must be cached!!! */ + Bool hasMoved = False; if (wPreferences.flags.noupdates) return; @@ -3567,6 +3568,7 @@ static void handleIconMove(WDock * dock, WAppIcon * aicon, XEvent * event) break; case MotionNotify: + hasMoved = True; if (!grabbed) { if (abs(ofs_x - ev.xmotion.x) >= MOVE_THRESHOLD || abs(ofs_y - ev.xmotion.y) >= MOVE_THRESHOLD) { @@ -3712,9 +3714,10 @@ static void handleIconMove(WDock * dock, WAppIcon * aicon, XEvent * event) #ifdef DEBUG puts("End icon move"); #endif - return; + return hasMoved;; } } + return False; /* never reached */ } static int getClipButton(int px, int py) @@ -3841,9 +3844,11 @@ static void iconMouseDown(WObjDescriptor * desc, XEvent * event) handleClipChangeWorkspace(scr, event); else handleDockMove(dock, aicon, event); - } else - handleIconMove(dock, aicon, event); - + } else { + Bool hasMoved = handleIconMove(dock, aicon, event); + if (wPreferences.single_click && !hasMoved) + iconDblClick(desc, event); + } } else if (event->xbutton.button == Button2 && dock->type == WM_CLIP && aicon == scr->clip_icon) { if (!scr->clip_ws_menu) { scr->clip_ws_menu = wWorkspaceMenuMake(scr, False); diff --git a/src/icon.c b/src/icon.c index e61c11f0..30ee1fe9 100644 --- a/src/icon.c +++ b/src/icon.c @@ -814,6 +814,7 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event) int dx = event->xbutton.x, dy = event->xbutton.y; int grabbed = 0; int clickButton = event->xbutton.button; + Bool hasMoved = False; if (WCHECK_STATE(WSTATE_MODAL)) return; @@ -863,6 +864,7 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event) break; case MotionNotify: + hasMoved = True; if (!grabbed) { if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD || abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) { @@ -900,6 +902,8 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event) if (wPreferences.auto_arrange_icons) wArrangeIcons(wwin->screen_ptr, True); + if (wPreferences.single_click && !hasMoved) + miniwindowDblClick(desc, event); return; } -- 2.11.4.GIT