Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 403679
Collapse All | Expand All

(-)WindowMaker-0.95.2.orig/src/appicon.c (+2 lines)
Lines 168-173 void wAppIconDestroy(WAppIcon * aicon) Link Here
168
	if (aicon->dnd_command)
168
	if (aicon->dnd_command)
169
		wfree(aicon->dnd_command);
169
		wfree(aicon->dnd_command);
170
#endif
170
#endif
171
	if (aicon->keyboard_shortcut)
172
		wfree(aicon->keyboard_shortcut);
171
	if (aicon->wm_instance)
173
	if (aicon->wm_instance)
172
		wfree(aicon->wm_instance);
174
		wfree(aicon->wm_instance);
173
	if (aicon->wm_class)
175
	if (aicon->wm_class)
(-)WindowMaker-0.95.2.orig/src/appicon.h (+4 lines)
Lines 50-55 typedef struct WAppIcon { Link Here
50
50
51
    char *paste_command;	       /* command to run when something is pasted */
51
    char *paste_command;	       /* command to run when something is pasted */
52
52
53
    char *keyboard_shortcut;           /* keyboard shortcut to launch app */
54
    int modifier;
55
    KeyCode keycode;
56
53
    char *wm_class;
57
    char *wm_class;
54
    char *wm_instance;
58
    char *wm_instance;
55
    pid_t pid;			       /* for apps launched from the dock */
59
    pid_t pid;			       /* for apps launched from the dock */
(-)WindowMaker-0.95.2.orig/src/dock.c (+144 lines)
Lines 79-84 static WMPropList *dPasteCommand = NULL; Link Here
79
#ifdef XDND			/* XXX was OFFIX */
79
#ifdef XDND			/* XXX was OFFIX */
80
static WMPropList *dDropCommand = NULL;
80
static WMPropList *dDropCommand = NULL;
81
#endif
81
#endif
82
static WMPropList *dKeyboardShortcut = NULL;
82
static WMPropList *dAutoLaunch, *dLock;
83
static WMPropList *dAutoLaunch, *dLock;
83
static WMPropList *dName, *dForced, *dBuggyApplication, *dYes, *dNo;
84
static WMPropList *dName, *dForced, *dBuggyApplication, *dYes, *dNo;
84
static WMPropList *dHost, *dDock, *dClip;
85
static WMPropList *dHost, *dDock, *dClip;
Lines 131-136 static void make_keys(void) Link Here
131
#ifdef XDND
132
#ifdef XDND
132
	dDropCommand = WMRetainPropList(WMCreatePLString("DropCommand"));
133
	dDropCommand = WMRetainPropList(WMCreatePLString("DropCommand"));
133
#endif
134
#endif
135
	dKeyboardShortcut = WMRetainPropList(WMCreatePLString("Shortcut"));
134
	dLock = WMRetainPropList(WMCreatePLString("Lock"));
136
	dLock = WMRetainPropList(WMCreatePLString("Lock"));
135
	dAutoLaunch = WMRetainPropList(WMCreatePLString("AutoLaunch"));
137
	dAutoLaunch = WMRetainPropList(WMCreatePLString("AutoLaunch"));
136
	dName = WMRetainPropList(WMCreatePLString("Name"));
138
	dName = WMRetainPropList(WMCreatePLString("Name"));
Lines 1241-1246 static WMPropList *make_icon_state(WAppI Link Here
1241
			WMReleasePropList(command);
1243
			WMReleasePropList(command);
1242
		}
1244
		}
1243
1245
1246
		if (btn->keyboard_shortcut) {
1247
			command = WMCreatePLString(btn->keyboard_shortcut);
1248
			WMPutInPLDictionary(node, dKeyboardShortcut, command);
1249
			WMReleasePropList(command);
1250
		}
1251
1244
		if (btn->client_machine && btn->remote_start) {
1252
		if (btn->client_machine && btn->remote_start) {
1245
			host = WMCreatePLString(btn->client_machine);
1253
			host = WMCreatePLString(btn->client_machine);
1246
			WMPutInPLDictionary(node, dHost, host);
1254
			WMPutInPLDictionary(node, dHost, host);
Lines 1435-1440 static WAppIcon *restore_icon_state(WScr Link Here
1435
		aicon->dnd_command = wstrdup(WMGetFromPLString(cmd));
1443
		aicon->dnd_command = wstrdup(WMGetFromPLString(cmd));
1436
#endif
1444
#endif
1437
1445
1446
	cmd = WMGetFromPLDictionary(info, dKeyboardShortcut);
1447
	if (cmd) {
1448
		if(addDockShortcut(WMGetFromPLString(cmd), aicon))
1449
			aicon->keyboard_shortcut = wstrdup(WMGetFromPLString(cmd));
1450
	}
1451
1438
	cmd = WMGetFromPLDictionary(info, dPasteCommand);
1452
	cmd = WMGetFromPLDictionary(info, dPasteCommand);
1439
	if (cmd)
1453
	if (cmd)
1440
		aicon->paste_command = wstrdup(WMGetFromPLString(cmd));
1454
		aicon->paste_command = wstrdup(WMGetFromPLString(cmd));
Lines 1704-1709 WDock *wDockRestoreState(WScreen *scr, W Link Here
1704
	if (type == WM_DOCK)
1718
	if (type == WM_DOCK)
1705
		dock->icon_count = 0;
1719
		dock->icon_count = 0;
1706
1720
1721
	dock->screen_ptr->flags.dock_changed_shortcuts = 0;
1722
1707
	for (i = 0; i < count; i++) {
1723
	for (i = 0; i < count; i++) {
1708
		if (dock->icon_count >= dock->max_icons) {
1724
		if (dock->icon_count >= dock->max_icons) {
1709
			wwarning(_("there are too many icons stored in dock. Ignoring what doesn't fit"));
1725
			wwarning(_("there are too many icons stored in dock. Ignoring what doesn't fit"));
Lines 1736-1741 WDock *wDockRestoreState(WScreen *scr, W Link Here
1736
			dock->icon_count++;
1752
			dock->icon_count++;
1737
	}
1753
	}
1738
1754
1755
	if(dock->screen_ptr->flags.dock_changed_shortcuts)
1756
	{
1757
		rebind_key_grabs(dock->screen_ptr);
1758
		dock->screen_ptr->flags.dock_changed_shortcuts = 0;
1759
	}
1760
1739
	/* if the first icon is not defined, use the default */
1761
	/* if the first icon is not defined, use the default */
1740
	if (dock->icon_array[0] == NULL) {
1762
	if (dock->icon_array[0] == NULL) {
1741
		/* update default icon */
1763
		/* update default icon */
Lines 4034-4036 int wClipMakeIconOmnipresent(WAppIcon *a Link Here
4034
4056
4035
	return status;
4057
	return status;
4036
}
4058
}
4059
4060
Bool
4061
addDockShortcut(char *shortcutDefinition, WAppIcon *icon)
4062
{
4063
	int modifier = 0;
4064
	KeyCode keycode;
4065
	KeySym ksym;
4066
	char *k;
4067
	char buf[128], *b;
4068
	
4069
	strcpy(buf, shortcutDefinition);
4070
	b = (char*)buf;
4071
4072
	/* get modifiers */
4073
	while((k = strchr(b, '+'))!=NULL) {
4074
		int mod;
4075
4076
		*k = 0;
4077
		mod = wXModifierFromKey(b);
4078
		if(mod < 0) {
4079
			wwarning(_("invalid key modifier \"%s\""), b);
4080
			return False;
4081
		}
4082
		modifier |= mod;
4083
4084
		b = k+1;
4085
	}
4086
4087
	/* get key */
4088
	ksym = XStringToKeysym(b);
4089
4090
	if (ksym==NoSymbol) {
4091
		wwarning(_("invalid kbd shortcut specification \"%s\""), shortcutDefinition);
4092
		return False;
4093
	}
4094
4095
	keycode = XKeysymToKeycode(dpy, ksym);
4096
	if (keycode==0) {
4097
		wwarning(_("invalid key in shortcut \"%s\""), shortcutDefinition);
4098
		return False;
4099
	}
4100
	icon->modifier = modifier;
4101
	icon->keycode = keycode;
4102
	if(icon->dock && icon->dock->screen_ptr)
4103
		icon->dock->screen_ptr->flags.dock_changed_shortcuts = 1;
4104
	return True;
4105
}
4106
4107
static Bool
4108
wDockPerformShortcut(WDock *dock, XEvent *event)
4109
{
4110
	int i;
4111
	int modifiers;
4112
	int done = 0;
4113
4114
	if(!dock) return done;
4115
	modifiers = event->xkey.state & ValidModMask;
4116
	for(i=(dock->type==WM_DOCK ? 0 : 1); i<dock->max_icons; i++) {
4117
		WAppIcon *btn = dock->icon_array[i];
4118
4119
		if(!btn || btn->attracted)
4120
			continue;
4121
	
4122
		if(btn->keycode==event->xkey.keycode && (btn->modifier==modifiers)) {
4123
			launchDockedApplication(btn, False);
4124
			done = True;
4125
			break;
4126
		}
4127
4128
	}
4129
	return done;
4130
}
4131
4132
Bool
4133
wDockAndClipPerformShortcut(WScreen *scr, XEvent *event)
4134
{
4135
	int done = 0;
4136
	int i;
4137
	if(!(done = wDockPerformShortcut(scr->dock, event))) {
4138
		for(i=0; i < scr->workspace_count; i++)	{
4139
			if(done = wDockPerformShortcut(scr->workspaces[i]->clip, event)) break;
4140
		}
4141
	}
4142
	return done;
4143
}
4144
4145
static void
4146
wDockBindShortcuts(Window window, WDock* dock)
4147
{
4148
	int i;
4149
	if(!dock) return;
4150
	for(i=(dock->type==WM_DOCK ? 0 : 1); i<dock->max_icons; i++) {
4151
		WAppIcon *btn = dock->icon_array[i];
4152
4153
		if(!btn || btn->attracted)
4154
			continue;
4155
	
4156
		if(btn->keyboard_shortcut)
4157
		{
4158
			if(btn->keyboard_shortcut && btn->modifier!=AnyModifier) {
4159
				XGrabKey(dpy, btn->keycode, btn->modifier|LockMask,
4160
					window, True, GrabModeAsync, GrabModeAsync);
4161
#ifdef NUMLOCK_HACK
4162
				wHackedGrabKey(btn->keycode, btn->modifier,
4163
					window, True, GrabModeAsync, GrabModeAsync);	    
4164
#endif
4165
			}
4166
			XGrabKey(dpy, btn->keycode, btn->modifier, window, True, 
4167
				GrabModeAsync, GrabModeAsync);
4168
		}
4169
	}
4170
}
4171
4172
void
4173
wDockAndClipBindShortcuts(Window window, WScreen *scr)
4174
{
4175
	int i;
4176
	wDockBindShortcuts(window, scr->dock);
4177
	for(i=0; i < scr->workspace_count; i++ ) {
4178
		wDockBindShortcuts(window, scr->workspaces[i]->clip);
4179
	}
4180
}
(-)WindowMaker-0.95.2.orig/src/dockedapp.c (-1 / +136 lines)
Lines 23-28 Link Here
23
23
24
#include <X11/Xlib.h>
24
#include <X11/Xlib.h>
25
#include <X11/Xutil.h>
25
#include <X11/Xutil.h>
26
#include <X11/keysym.h>
26
#include <stdlib.h>
27
#include <stdlib.h>
27
#include <string.h>
28
#include <string.h>
28
29
Lines 60-65 typedef struct _AppSettingsPanel { Link Here
60
	WMTextField *pasteCommandField;
61
	WMTextField *pasteCommandField;
61
	WMLabel *pasteCommandLabel;
62
	WMLabel *pasteCommandLabel;
62
63
64
	WMFrame *keyboardShortcutFrame;
65
	WMTextField *keyboardShortcutField;
66
	WMButton *keyboardShortcutCaptureBtn;
67
63
	WMFrame *iconFrame;
68
	WMFrame *iconFrame;
64
	WMTextField *iconField;
69
	WMTextField *iconField;
65
	WMButton *browseBtn;
70
	WMButton *browseBtn;
Lines 75-80 typedef struct _AppSettingsPanel { Link Here
75
	/* kluge */
80
	/* kluge */
76
	unsigned int destroyed:1;
81
	unsigned int destroyed:1;
77
	unsigned int choosingIcon:1;
82
	unsigned int choosingIcon:1;
83
	unsigned int capturing:1;
78
} AppSettingsPanel;
84
} AppSettingsPanel;
79
85
80
void DestroyDockAppSettingsPanel(AppSettingsPanel * panel);
86
void DestroyDockAppSettingsPanel(AppSettingsPanel * panel);
Lines 105-110 static void updatePasteCommand(WAppIcon Link Here
105
	icon->paste_command = command;
111
	icon->paste_command = command;
106
}
112
}
107
113
114
static char*
115
trimstr(char *str)
116
{
117
	char *p = str;
118
	int i;
119
120
	while (isspace(*p)) p++;
121
	p = wstrdup(p);
122
	i = strlen(p);
123
	while (isspace(p[i]) && i>0) {
124
		p[i]=0;
125
		i--;
126
	}
127
128
	return p;
129
}
130
131
static void
132
updateKeyboardShortcut(WAppIcon *icon, char *shortcut)
133
{
134
	char *str = NULL;
135
	if(icon->keyboard_shortcut)
136
		wfree(icon->keyboard_shortcut);
137
	if(shortcut) {
138
		str = trimstr(shortcut);
139
		if(!strlen(str)) {
140
			wfree(str);
141
			str = NULL;
142
		}
143
	}
144
	icon->keyboard_shortcut = str;
145
	icon->modifier = 0;
146
	icon->keycode = 0;
147
	if(str) addDockShortcut(str, icon);
148
	rebind_key_grabs(icon->dock->screen_ptr);
149
}
150
108
#ifdef XDND
151
#ifdef XDND
109
static void updateDNDCommand(WAppIcon * icon, char *command)
152
static void updateDNDCommand(WAppIcon * icon, char *command)
110
{
153
{
Lines 242-247 static void panelBtnCallback(WMWidget * Link Here
242
		text = WMGetTextFieldText(panel->pasteCommandField);
285
		text = WMGetTextFieldText(panel->pasteCommandField);
243
		updatePasteCommand(panel->editedIcon, text);
286
		updatePasteCommand(panel->editedIcon, text);
244
287
288
		text = WMGetTextFieldText(panel->keyboardShortcutField);
289
		updateKeyboardShortcut(panel->editedIcon, text);
290
245
		panel->editedIcon->auto_launch = WMGetButtonSelected(panel->autoLaunchBtn);
291
		panel->editedIcon->auto_launch = WMGetButtonSelected(panel->autoLaunchBtn);
246
292
247
		panel->editedIcon->lock = WMGetButtonSelected(panel->lockBtn);
293
		panel->editedIcon->lock = WMGetButtonSelected(panel->lockBtn);
Lines 251-258 static void panelBtnCallback(WMWidget * Link Here
251
		DestroyDockAppSettingsPanel(panel);
297
		DestroyDockAppSettingsPanel(panel);
252
}
298
}
253
299
300
static char*
301
captureShortcut(Display *dpy, AppSettingsPanel *panel)
302
{
303
	XEvent ev;
304
	KeySym ksym, lksym, uksym;
305
	char buffer[64];
306
	char *key = NULL;
307
308
	while (panel->capturing) {
309
		XAllowEvents(dpy, AsyncKeyboard, CurrentTime);
310
		WMNextEvent(dpy, &ev);
311
		if (ev.type==KeyPress && ev.xkey.keycode!=0) {
312
			ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0);
313
			if (!IsModifierKey(ksym)) {
314
				XConvertCase(ksym, &lksym, &uksym);
315
				key=XKeysymToString(uksym);
316
				panel->capturing = 0;
317
				break;
318
			}
319
		}
320
		WMHandleEvent(&ev);
321
	}
322
	if (!key)
323
		return NULL;
324
325
	buffer[0] = 0;
326
	if (ev.xkey.state & ControlMask) {
327
		strcat(buffer, "Control+");
328
	}   
329
        if (ev.xkey.state & ShiftMask) {
330
		strcat(buffer, "Shift+");
331
	}   
332
	if (ev.xkey.state & Mod1Mask) {
333
		strcat(buffer, "Mod1+");
334
	}   
335
	if (ev.xkey.state & Mod2Mask) {
336
		strcat(buffer, "Mod2+");
337
	}   
338
	if (ev.xkey.state & Mod3Mask) {
339
		strcat(buffer, "Mod3+");
340
	}
341
	if (ev.xkey.state & Mod4Mask) {
342
		strcat(buffer, "Mod4+");
343
	}
344
	if (ev.xkey.state & Mod5Mask) {
345
		strcat(buffer, "Mod5+");
346
	}
347
	strcat(buffer, key);
348
349
	return wstrdup(buffer);
350
}
351
352
static void
353
captureClick(WMWidget *w, void *data)
354
{
355
	AppSettingsPanel *panel = (AppSettingsPanel*)data;
356
	char *shortcut;
357
358
	if(!panel->capturing) {
359
		panel->capturing = 1;
360
		WMSetButtonText(w, _("Cancel"));
361
	        XGrabKeyboard(dpy, WMWidgetXID(panel->win), True, GrabModeAsync,
362
				GrabModeAsync, CurrentTime);
363
		shortcut = captureShortcut(dpy, panel);
364
		if (shortcut) {
365
			WMSetTextFieldText(panel->keyboardShortcutField, shortcut);
366
			wfree(shortcut);
367
		}
368
	}
369
	panel->capturing = 0;
370
	WMSetButtonText(w, _("Capture"));
371
	XUngrabKeyboard(dpy, CurrentTime);
372
}
373
254
#define PWIDTH	295
374
#define PWIDTH	295
255
#define PHEIGHT	430
375
#define PHEIGHT	490
256
376
257
void ShowDockAppSettingsPanel(WAppIcon * aicon)
377
void ShowDockAppSettingsPanel(WAppIcon * aicon)
258
{
378
{
Lines 352-357 void ShowDockAppSettingsPanel(WAppIcon * Link Here
352
#endif
472
#endif
353
	WMMapSubwidgets(panel->dndCommandFrame);
473
	WMMapSubwidgets(panel->dndCommandFrame);
354
474
475
	panel->keyboardShortcutFrame = WMCreateFrame(vbox);
476
	WMSetFrameTitle(panel->keyboardShortcutFrame, _("Keyboard shortcut"));
477
	WMAddBoxSubview(vbox, WMWidgetView(panel->keyboardShortcutFrame), False, True,
478
		    50, 50, 10);
479
	panel->keyboardShortcutField = WMCreateTextField(panel->keyboardShortcutFrame);
480
	WMResizeWidget(panel->keyboardShortcutField, 176, 20);
481
	WMMoveWidget(panel->keyboardShortcutField, 10, 20);
482
	WMSetTextFieldText(panel->keyboardShortcutField, aicon->keyboard_shortcut);
483
	panel->keyboardShortcutCaptureBtn = WMCreateCommandButton(panel->keyboardShortcutFrame);
484
	WMSetButtonText(panel->keyboardShortcutCaptureBtn, _("Capture"));
485
	WMResizeWidget(panel->keyboardShortcutCaptureBtn, 70, 24);
486
	WMMoveWidget(panel->keyboardShortcutCaptureBtn, 195, 18);
487
	WMSetButtonAction(panel->keyboardShortcutCaptureBtn, captureClick, panel);
488
	WMMapSubwidgets(panel->keyboardShortcutFrame);
489
355
	panel->iconFrame = WMCreateFrame(vbox);
490
	panel->iconFrame = WMCreateFrame(vbox);
356
	WMSetFrameTitle(panel->iconFrame, _("Icon Image"));
491
	WMSetFrameTitle(panel->iconFrame, _("Icon Image"));
357
	WMAddBoxSubview(vbox, WMWidgetView(panel->iconFrame), False, True, 50, 50, 10);
492
	WMAddBoxSubview(vbox, WMWidgetView(panel->iconFrame), False, True, 50, 50, 10);
(-)WindowMaker-0.95.2.orig/src/event.c (-1 / +1 lines)
Lines 1363-1369 static void handleKeyPress(XEvent * even Link Here
1363
1363
1364
	if (command < 0) {
1364
	if (command < 0) {
1365
1365
1366
		if (!wRootMenuPerformShortcut(event)) {
1366
		if (!wRootMenuPerformShortcut(event) && !wDockAndClipPerformShortcut(scr, event)) {
1367
			static int dontLoop = 0;
1367
			static int dontLoop = 0;
1368
1368
1369
			if (dontLoop > 10) {
1369
			if (dontLoop > 10) {
(-)WindowMaker-0.95.2.orig/src/screen.h (+1 lines)
Lines 279-284 typedef struct _WScreen { Link Here
279
        unsigned int regenerate_icon_textures:1;
279
        unsigned int regenerate_icon_textures:1;
280
        unsigned int dnd_data_convertion_status:1;
280
        unsigned int dnd_data_convertion_status:1;
281
        unsigned int root_menu_changed_shortcuts:1;
281
        unsigned int root_menu_changed_shortcuts:1;
282
	unsigned int dock_changed_shortcuts:1;
282
        unsigned int added_workspace_menu:1;
283
        unsigned int added_workspace_menu:1;
283
        unsigned int added_windows_menu:1;
284
        unsigned int added_windows_menu:1;
284
        unsigned int startup2:1;       /* startup phase 2 */
285
        unsigned int startup2:1;       /* startup phase 2 */
(-)WindowMaker-0.95.2.orig/src/window.c (+1 lines)
Lines 2540-2545 void wWindowSetKeyGrabs(WWindow * wwin) Link Here
2540
	}
2540
	}
2541
2541
2542
	wRootMenuBindShortcuts(wwin->frame->core->window);
2542
	wRootMenuBindShortcuts(wwin->frame->core->window);
2543
	wDockAndClipBindShortcuts(wwin->frame->core->window, wwin->screen_ptr);
2543
}
2544
}
2544
2545
2545
void wWindowResetMouseGrabs(WWindow * wwin)
2546
void wWindowResetMouseGrabs(WWindow * wwin)

Return to bug 403679