1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-30 18:32:34 +01:00

Hot corners feature core

Add mouse pointer position detection to trigger the corner actions.

Screen corners can be assigned an external command to be
executed when the mouse pointer is entering those areas.

In WPrefs, "Hot Corner Shortcut Preferences" can be used
for configuration or by manually adding a "HotCorners" key
and value to "YES" in the ~/GNUstep/Defaults/WindowMaker file.

Actions are specified by the "HotCornerActions" and are defined
as a four entries list ("top left action", "top right action",
"bottom left action", "bottom right action").
A screen corner area is a cube shape defined by the "HotCornerEdge"
which is a number of pixels from 2 (by default) to 10.

To lower the risk of triggering that feature accidentally a
"HotCornerDelay" key can be used which is the time before the action
is triggered while the pointer is in one of the screen corner.
Default value is 250 ms.

Hot Corners feature is disabled by default.
This commit is contained in:
David Maciejak
2023-03-26 14:35:13 +08:00
committed by Carlos R. Mafra
parent 157d1ba85f
commit 802cbc0d75
4 changed files with 143 additions and 12 deletions

View File

@@ -151,6 +151,7 @@ static WDECallbackUpdate setSwPOptions;
static WDECallbackUpdate updateUsableArea;
static WDECallbackUpdate setModifierKeyLabels;
static WDECallbackUpdate setHotCornerActions;
static WDECallbackConvert getCursor;
static WDECallbackUpdate setCursor;
@@ -525,6 +526,14 @@ WDefaultEntry optionList[] = {
{"KeepDockOnPrimaryHead", "NO", NULL,
&wPreferences.keep_dock_on_primary_head, getBool, updateDock,
NULL, NULL},
{"HotCorners", "NO", NULL,
&wPreferences.hot_corners, getBool, NULL, NULL, NULL},
{"HotCornerDelay", "250", (void *)&wPreferences.hot_corner_delay,
&wPreferences.hot_corner_delay, getInt, NULL, NULL, NULL},
{"HotCornerEdge", "2", (void *)&wPreferences.hot_corner_edge,
&wPreferences.hot_corner_edge, getInt, NULL, NULL, NULL},
{"HotCornerActions", "(\"None\", \"None\", \"None\", \"None\")", &wPreferences,
NULL, getPropList, setHotCornerActions, NULL, NULL},
/* style options */
@@ -3461,6 +3470,43 @@ static int setModifierKeyLabels(WScreen * scr, WDefaultEntry * entry, void *tdat
return 0;
}
static int setHotCornerActions(WScreen * scr, WDefaultEntry * entry, void *tdata, void *foo)
{
WMPropList *array = tdata;
int i;
struct WPreferences *prefs = foo;
if (!WMIsPLArray(array) || WMGetPropListItemCount(array) != 4) {
wwarning(_("Value for option \"%s\" must be an array of 4 strings"), entry->key);
WMReleasePropList(array);
return 0;
}
DestroyWindowMenu(scr);
for (i = 0; i < 4; i++) {
if (prefs->hot_corner_actions[i])
wfree(prefs->hot_corner_actions[i]);
if (WMIsPLString(WMGetFromPLArray(array, i))) {
const char *val;
val = WMGetFromPLString(WMGetFromPLArray(array, i));
if (strcasecmp(val, "NONE") != 0)
prefs->hot_corner_actions[i] = wstrdup(val);
else
prefs->hot_corner_actions[i] = NULL;
} else {
wwarning(_("Invalid argument for option \"%s\" item %d"), entry->key, i);
prefs->hot_corner_actions[i] = NULL;
}
}
WMReleasePropList(array);
return 0;
}
static int setDoubleClick(WScreen *scr, WDefaultEntry *entry, void *tdata, void *foo)
{
int *value = tdata;