1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
diff -ur WindowMaker-0.91.0/WINGs/wlist.c WindowMaker-0.91.0-test/WINGs/wlist.c
--- WindowMaker-0.91.0/WINGs/wlist.c 2004-10-12 14:36:42.000000000 -0400
+++ WindowMaker-0.91.0-test/WINGs/wlist.c 2005-03-13 13:37:39.914633856 -0500
@@ -4,6 +4,8 @@
#include "WINGsP.h"
+#include <X11/keysym.h>
+
char *WMListDidScrollNotification = "WMListDidScrollNotification";
char *WMListSelectionDidChangeNotification = "WMListSelectionDidChangeNotification";
@@ -44,6 +46,7 @@
unsigned int redrawPending:1;
unsigned int buttonPressed:1;
unsigned int buttonWasPressed:1;
+ unsigned int focused:1;
} flags;
} List;
@@ -141,10 +144,10 @@
lPtr->view->delegate = &_ListViewDelegate;
WMCreateEventHandler(lPtr->view, ExposureMask|StructureNotifyMask
- |ClientMessageMask, handleEvents, lPtr);
+ |FocusChangeMask|ClientMessageMask, handleEvents, lPtr);
WMCreateEventHandler(lPtr->view, ButtonPressMask|ButtonReleaseMask
- |EnterWindowMask|LeaveWindowMask|ButtonMotionMask,
+ |EnterWindowMask|LeaveWindowMask|ButtonMotionMask|KeyPressMask,
handleActionEvents, lPtr);
lPtr->itemHeight = WMFontHeight(scrPtr->normalFont) + 1;
@@ -1044,6 +1047,11 @@
int topItem = lPtr->topItem;
static int lastClicked = -1, prevItem = -1;
+ /* for arrow keys handling */
+ char buffer[64];
+ KeySym ksym;
+ int count, row;
+
CHECK_CLASS(data, WC_List);
switch (event->type) {
@@ -1096,6 +1104,10 @@
case ButtonPress:
if (event->xbutton.x <= WMWidgetWidth(lPtr->vScroller))
break;
+ /* need focus for keyboard events */
+ if (!lPtr->flags.focused);
+ WMSetFocusToWidget(lPtr);
+
if (event->xbutton.button == WINGsConfiguration.mouseWheelDown ||
event->xbutton.button == WINGsConfiguration.mouseWheelUp) {
int amount = 0;
@@ -1202,6 +1214,34 @@
prevItem = tmp;
}
break;
+ case KeyPress:
+ /* handle arrow keys, space and return */
+ count = XLookupString(&event->xkey, buffer, 63, &ksym, NULL);
+ buffer[count] = '\0';
+ switch(ksym) {
+ case XK_Up:
+ row = WMGetListSelectedItemRow(lPtr);
+ WMSelectListItem(lPtr, row - 1);
+ if (row <= topItem)
+ scrollByAmount(lPtr, -1);
+ break;
+ case XK_Down:
+ row = WMGetListSelectedItemRow(lPtr);
+ WMSelectListItem(lPtr, row + 1);
+ if (row - topItem >= lPtr->fullFitLines)
+ scrollByAmount(lPtr, 1);
+ break;
+ case XK_space:
+ if (lPtr->action)
+ (*lPtr->action)(lPtr, lPtr->clientData);
+ break;
+ case XK_Return:
+ if (lPtr->doubleAction)
+ (*lPtr->doubleAction)(lPtr, lPtr->clientData);
+ break;
+ }
+ break;
+
}
if (lPtr->topItem != topItem)
WMPostNotificationName(WMListDidScrollNotification, lPtr, NULL);
Only in WindowMaker-0.91.0-test/WINGs: wlist.c.orig
|