>
> From: Rodolfo García Peñas (kix) <[email protected]>
> Date: Tue, 17 Jan 2012 21:43:58 +0100
> Subject: [PATCH] WPrefs: Removed duplicated function captureShortcut
>
You need the following patch on top of yours to make things work. You
missed a 'else' in the convert_case 'if', so that you don't call
XKeysymToString(usym) -- note the usym -- when you don't convert the
case.
Another thing is that _Panel is different on those two files, and in one
'capturing' is Bool and in the other it is char.
So instead of passing the whole structure pass just the relevant field
(capture_shortcut() does not care about the others).
If it's ok for you I'll simply fold my fix on top of your patch, but
please next time test your patch :-)
diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c
index a519ce0..083cd00 100644
--- a/WPrefs.app/KeyboardShortcuts.c
+++ b/WPrefs.app/KeyboardShortcuts.c
@@ -52,7 +52,7 @@ typedef struct _Panel {
WMColor *gray;
WMFont *font;
- /**/ char capturing;
+ Bool capturing;
char **shortcuts;
int actionCount;
} _Panel;
@@ -230,24 +230,27 @@ static void XConvertCase(register KeySym sym, KeySym *
lower, KeySym * upper)
}
#endif
-char *capture_shortcut(Display *dpy, _Panel *panel, int convert_case)
+char *capture_shortcut(Display *dpy, Bool *capturing, int convert_case)
{
XEvent ev;
KeySym ksym, lksym, uksym;
char buffer[64];
char *key = NULL;
- while (panel->capturing) {
+ while (*capturing) {
XAllowEvents(dpy, AsyncKeyboard, CurrentTime);
WMNextEvent(dpy, &ev);
if (ev.type == KeyPress && ev.xkey.keycode != 0) {
ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0);
if (!IsModifierKey(ksym)) {
- if (convert_case)
+ if (convert_case) {
XConvertCase(ksym, &lksym, &uksym);
- key = XKeysymToString(uksym);
+ key = XKeysymToString(uksym);
+ } else {
+ key = XKeysymToString(ksym);
+ }
- panel->capturing = 0;
+ *capturing = 0;
break;
}
}
@@ -297,7 +300,7 @@ static void captureClick(WMWidget * w, void *data)
WMSetLabelText(panel->instructionsL,
_("Press the desired shortcut key(s) or click
Cancel to stop capturing."));
XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True,
GrabModeAsync, GrabModeAsync, CurrentTime);
- shortcut = capture_shortcut(dpy, panel, 1);
+ shortcut = capture_shortcut(dpy, &panel->capturing, 1);
if (shortcut) {
int row = WMGetListSelectedItemRow(panel->actLs);
diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c
index 2991aa3..cc7dbfc 100644
--- a/WPrefs.app/Menu.c
+++ b/WPrefs.app/Menu.c
@@ -176,7 +176,7 @@ static Bool shouldRemoveItem(struct WEditMenuDelegate
*delegate, WEditMenu * men
static void freeItemData(ItemData * data);
-extern char *capture_shortcut(Display *dpy, _Panel *panel, int convert_case);
+extern char *capture_shortcut(Display *dpy, Bool *capturing, int convert_case);
static WEditMenuDelegate menuDelegate = {
NULL,
@@ -272,7 +272,7 @@ static void sgrabClicked(WMWidget * w, void *data)
panel->capturing = 1;
WMSetButtonText(w, _("Cancel"));
XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True,
GrabModeAsync, GrabModeAsync, CurrentTime);
- shortcut = capture_shortcut(dpy, panel, 0);
+ shortcut = capture_shortcut(dpy, &panel->capturing, 0);
if (shortcut) {
WMSetTextFieldText(panel->shortT, shortcut);
updateMenuItem(panel, panel->currentItem,
panel->shortT);
--
To unsubscribe, send mail to [email protected].