- Made all changes for moving WINGs headers in the WINGs subdirectory.
[wmaker-crm.git] / WPrefs.app / MouseSettings.c
blobf8b1ed6ad6695ec150ac7b9dbf2317afdf01fc5b
2 /* MouseSettings.c- mouse options (some are equivalent to xset)
3 *
4 * WPrefs - Window Maker Preferences Program
5 *
6 * Copyright (c) 1998 Alfredo K. Kojima
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * USA.
25 #include "WPrefs.h"
27 #include <X11/Xutil.h>
29 #include <math.h>
31 /* double-click tester */
32 #include "double.h"
36 #define XSET "xset"
40 typedef struct _Panel {
41 WMFrame *frame;
43 char *sectionName;
45 char *description;
47 CallbackRec callbacks;
49 WMWindow *win;
51 WMFrame *speedF;
52 WMLabel *speedL;
53 WMSlider *speedS;
54 WMLabel *acceL;
55 WMTextField *acceT;
56 WMLabel *threL;
57 WMTextField *threT;
59 WMFrame *ddelaF;
60 WMButton *ddelaB[5];
61 WMTextField *ddelaT;
62 WMLabel *ddelaL;
63 DoubleTest *tester;
65 WMFrame *menuF;
66 WMLabel *listL;
67 WMLabel *appL;
68 WMLabel *selL;
69 WMPopUpButton *listP;
70 WMPopUpButton *appP;
71 WMPopUpButton *selP;
73 WMButton *disaB;
75 WMFrame *grabF;
76 WMPopUpButton *grabP;
78 /**/
79 int maxThreshold;
80 float acceleration;
81 } _Panel;
84 #define ICON_FILE "mousesettings"
86 #define SPEED_ICON_FILE "mousespeed"
88 #define DELAY_ICON "timer%i"
89 #define DELAY_ICON_S "timer%is"
92 /* need access to the double click variables */
93 #include <WINGs/WINGsP.h>
97 static char *modifierNames[] = {
98 "Shift",
99 "Lock",
100 "Control",
101 "Mod1",
102 "Mod2",
103 "Mod3",
104 "Mod4",
105 "Mod5"
109 static char *buttonNames[] = {
110 "None",
111 "Btn1 (left)",
112 "Btn2 (middle)",
113 "Btn3 (right)",
114 "Btn4",
115 "Btn5"
119 #define DELAY(i) ((i)*75+170)
122 int ModifierFromKey(Display *dpy, char *key);
125 static void
126 setMouseAccel(WMScreen *scr, float accel, int threshold)
128 int n, d;
130 d = 10;
131 n = accel*d;
133 XChangePointerControl(WMScreenDisplay(scr), True, True, n, d, threshold);
137 static void
138 speedChange(WMWidget *w, void *data)
140 _Panel *panel = (_Panel*)data;
141 int i;
142 char buffer[64];
143 int threshold;
144 char *tmp;
146 if (w == NULL) {
147 float accel;
149 tmp = WMGetTextFieldText(panel->acceT);
150 if (sscanf(tmp, "%f", &accel)!=1 || accel < 0) {
151 WMRunAlertPanel(WMWidgetScreen(panel->acceT), GetWindow(panel),
152 _("Error"),
153 _("Invalid mouse acceleration value. Must be a positive real value."),
154 _("OK"), NULL, NULL);
155 wfree(tmp);
156 return;
158 panel->acceleration = accel;
159 wfree(tmp);
160 } else {
161 i = (int)WMGetSliderValue(panel->speedS);
163 panel->acceleration = 0.25+(i*0.25);
165 sprintf(buffer, "%.2f", 0.25+(i*0.25));
166 WMSetTextFieldText(panel->acceT, buffer);
169 tmp = WMGetTextFieldText(panel->threT);
170 if (sscanf(tmp, "%i", &threshold)!=1 || threshold < 0
171 || threshold > panel->maxThreshold) {
172 WMRunAlertPanel(WMWidgetScreen(panel->win), GetWindow(panel), _("Error"),
173 _("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."),
174 _("OK"), NULL, NULL);
175 } else {
176 setMouseAccel(WMWidgetScreen(panel->win), panel->acceleration,
177 threshold);
179 wfree(tmp);
183 static void
184 returnPressed(void *observerData, WMNotification *notification)
186 _Panel *panel = (_Panel*)observerData;
188 speedChange(NULL, panel);
192 static void
193 doubleClick(WMWidget *w, void *data)
195 _Panel *panel = (_Panel*)data;
196 int i;
197 extern _WINGsConfiguration WINGsConfiguration;
198 char buffer[32];
200 for (i=0; i<5; i++) {
201 if (panel->ddelaB[i]==w)
202 break;
204 WINGsConfiguration.doubleClickDelay = DELAY(i);
206 sprintf(buffer, "%i", DELAY(i));
207 WMSetTextFieldText(panel->ddelaT, buffer);
213 getbutton(char *str)
215 if (!str)
216 return -2;
218 if (strcasecmp(str, "none")==0)
219 return 0;
220 else if (strcasecmp(str, "left")==0)
221 return 1;
222 else if (strcasecmp(str, "middle")==0)
223 return 2;
224 else if (strcasecmp(str, "right")==0)
225 return 3;
226 else if (strcasecmp(str, "button1")==0)
227 return 1;
228 else if (strcasecmp(str, "button2")==0)
229 return 2;
230 else if (strcasecmp(str, "button3")==0)
231 return 3;
232 else if (strcasecmp(str, "button4")==0)
233 return 4;
234 else if (strcasecmp(str, "button5")==0) {
235 return 5;
236 } else {
237 return -1;
242 static void
243 getMouseParameters(Display *dpy, float *accel, int *thre)
245 int n, d;
247 XGetPointerControl(dpy, &n, &d, thre);
249 *accel = (float)n/(float)d;
254 static void
255 showData(_Panel *panel)
257 char *str;
258 int i;
259 int a=-1, b=-1, c=-1;
260 float accel;
261 char buffer[32];
262 Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->win));
264 str = GetStringForKey("SelectWindowsMouseButton");
265 if (str) {
266 i = getbutton(str);
267 if (i==-1) {
268 a = 1;
269 wwarning(_("bad value %s for option %s"),str, "SelectWindowsMouseButton");
270 } else if (i>=0) {
271 a = i;
273 } else {
274 a = 0;
276 WMSetPopUpButtonSelectedItem(panel->selP, a);
278 str = GetStringForKey("WindowListMouseButton");
279 if (str) {
280 i = getbutton(str);
281 if (i==-1) {
282 b = 2;
283 wwarning(_("bad value %s for option %s"), str, "WindowListMouseButton");
284 } else if (i>=0) {
285 b = i;
287 } else {
288 b = 0;
290 WMSetPopUpButtonSelectedItem(panel->listP, b);
292 str = GetStringForKey("ApplicationMenuMouseButton");
293 if (str) {
294 i = getbutton(str);
295 if (i==-1) {
296 c = 3;
297 wwarning(_("bad value %s for option %s"), str, "ApplicationMenuMouseButton");
298 } else if (i>=0) {
299 c = i;
301 } else {
302 c = 0;
304 WMSetPopUpButtonSelectedItem(panel->appP, c);
306 WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions"));
308 /**/
309 getMouseParameters(dpy, &accel, &a);
310 panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy));
311 if (a > panel->maxThreshold) {
312 panel->maxThreshold = a;
314 sprintf(buffer, "%i", a);
315 WMSetTextFieldText(panel->threT, buffer);
317 WMSetSliderValue(panel->speedS, (accel - 0.25)/0.25);
319 panel->acceleration = accel;
320 sprintf(buffer, "%.2f", accel);
321 WMSetTextFieldText(panel->acceT, buffer);
323 /**/
324 b = GetIntegerForKey("DoubleClickTime");
325 /* find best match */
326 a = -1;
327 for (i=0; i<5; i++) {
328 if (DELAY(i) == b)
329 a = i;
331 if (a >= 0)
332 WMPerformButtonClick(panel->ddelaB[a]);
333 sprintf(buffer, "%i", b);
334 WMSetTextFieldText(panel->ddelaT, buffer);
336 /**/
337 str = GetStringForKey("ModifierKey");
338 if (!str)
339 str = "mod1";
340 a = ModifierFromKey(dpy, str);
342 if (a != -1) {
343 str = modifierNames[a];
345 a = 0;
346 for (i=0; i<WMGetPopUpButtonNumberOfItems(panel->grabP); i++) {
347 if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) {
348 WMSetPopUpButtonSelectedItem(panel->grabP, i);
349 a = 1;
350 break;
355 if (a < 1) {
356 sscanf(WMGetPopUpButtonItem(panel->grabP, 0), "%s", buffer);
357 WMSetPopUpButtonSelectedItem(panel->grabP, 0);
358 wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"),
359 str, buffer);
365 static void
366 fillModifierPopUp(WMPopUpButton *pop)
368 XModifierKeymap *mapping;
369 Display *dpy = WMScreenDisplay(WMWidgetScreen(pop));
370 int i, j;
371 char *str;
372 char buffer[64];
375 mapping = XGetModifierMapping(dpy);
377 if (!mapping || mapping->max_keypermod==0) {
378 WMAddPopUpButtonItem(pop, "Mod1");
379 WMAddPopUpButtonItem(pop, "Mod2");
380 WMAddPopUpButtonItem(pop, "Mod3");
381 WMAddPopUpButtonItem(pop, "Mod4");
382 WMAddPopUpButtonItem(pop, "Mod5");
383 wwarning(_("could not retrieve keyboard modifier mapping"));
384 return;
388 for (j=0; j<8; j++) {
389 int idx;
390 char *array[8];
391 int a;
392 KeySym ksym;
393 int k;
394 char *ptr;
395 char *tmp;
397 a = 0;
398 memset(array, 0, sizeof(char*)*8);
399 for (i=0; i < mapping->max_keypermod; i++) {
400 idx = i+j*mapping->max_keypermod;
401 if (mapping->modifiermap[idx]!=0) {
402 int l;
403 for (l=0; l<4; l++) {
404 ksym = XKeycodeToKeysym(dpy, mapping->modifiermap[idx], l);
405 if (ksym!=NoSymbol)
406 break;
408 if (ksym!=NoSymbol)
409 str = XKeysymToString(ksym);
410 else
411 str = NULL;
412 if (str && !strstr(str, "_Lock") && !strstr(str, "Shift")
413 && !strstr(str, "Control")) {
414 array[a++] = wstrdup(str);
419 for (k=0; k<a; k++) {
420 if (array[k]==NULL)
421 continue;
422 tmp = wstrdup(array[k]);
423 ptr = strstr(tmp, "_L");
424 if (ptr)
425 *ptr = 0;
426 ptr = strstr(tmp, "_R");
427 if (ptr)
428 *ptr = 0;
429 sprintf(buffer, "%s (%s)", modifierNames[j], tmp);
430 /*sprintf(buffer, "%s", tmp);*/
431 WMAddPopUpButtonItem(pop, buffer);
432 for (i=k+1; i<a; i++) {
433 if (array[i] == NULL)
434 continue;
435 if (strstr(array[i], tmp)) {
436 wfree(array[i]);
437 array[i]=NULL;
438 break;
441 wfree(tmp);
444 while (--a>0) {
445 if (array[a])
446 wfree(array[a]);
450 if (mapping)
451 XFreeModifiermap(mapping);
456 static void
457 createPanel(Panel *p)
459 _Panel *panel = (_Panel*)p;
460 WMScreen *scr = WMWidgetScreen(panel->win);
461 WMPixmap *icon;
462 char *buf1, *buf2;
463 int i;
464 RColor color;
465 char *path;
467 color.red = 0xaa;
468 color.green = 0xae;
469 color.blue = 0xaa;
471 panel->frame = WMCreateFrame(panel->win);
472 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
473 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
475 /**************** Mouse Speed ****************/
476 panel->speedF = WMCreateFrame(panel->frame);
477 WMResizeWidget(panel->speedF, 245, 100);
478 WMMoveWidget(panel->speedF, 15, 15);
479 WMSetFrameTitle(panel->speedF, _("Mouse Speed"));
481 panel->speedL = WMCreateLabel(panel->speedF);
482 WMResizeWidget(panel->speedL, 40, 46);
483 WMMoveWidget(panel->speedL, 15, 14);
484 WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
485 path = LocateImage(SPEED_ICON_FILE);
486 if (path) {
487 icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
488 if (icon) {
489 WMSetLabelImage(panel->speedL, icon);
490 WMReleasePixmap(icon);
491 } else {
492 wwarning(_("could not load icon %s"), path);
494 wfree(path);
497 panel->speedS = WMCreateSlider(panel->speedF);
498 WMResizeWidget(panel->speedS, 160, 15);
499 WMMoveWidget(panel->speedS, 70, 35);
500 WMSetSliderMinValue(panel->speedS, 0);
501 WMSetSliderMaxValue(panel->speedS, 40);
502 WMSetSliderContinuous(panel->speedS, False);
503 WMSetSliderAction(panel->speedS, speedChange, panel);
505 panel->acceL = WMCreateLabel(panel->speedF);
506 WMResizeWidget(panel->acceL, 70, 16);
507 WMMoveWidget(panel->acceL, 10, 67);
508 WMSetLabelTextAlignment(panel->acceL, WARight);
509 WMSetLabelText(panel->acceL, _("Acceler.:"));
511 panel->acceT = WMCreateTextField(panel->speedF);
512 WMResizeWidget(panel->acceT, 40, 20);
513 WMMoveWidget(panel->acceT, 80, 65);
514 WMAddNotificationObserver(returnPressed, panel,
515 WMTextDidEndEditingNotification, panel->acceT);
518 panel->threL = WMCreateLabel(panel->speedF);
519 WMResizeWidget(panel->threL, 80, 16);
520 WMMoveWidget(panel->threL, 120, 67);
521 WMSetLabelTextAlignment(panel->threL, WARight);
522 WMSetLabelText(panel->threL, _("Threshold:"));
524 panel->threT = WMCreateTextField(panel->speedF);
525 WMResizeWidget(panel->threT, 30, 20);
526 WMMoveWidget(panel->threT, 200, 65);
527 WMAddNotificationObserver(returnPressed, panel,
528 WMTextDidEndEditingNotification, panel->threT);
530 WMMapSubwidgets(panel->speedF);
532 /***************** Doubleclick Delay ****************/
534 panel->ddelaF = WMCreateFrame(panel->frame);
535 WMResizeWidget(panel->ddelaF, 245, 95);
536 WMMoveWidget(panel->ddelaF, 15, 125);
537 WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));
539 buf1 = wmalloc(strlen(DELAY_ICON)+2);
540 buf2 = wmalloc(strlen(DELAY_ICON_S)+2);
542 for (i = 0; i < 5; i++) {
543 panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF,
544 WBBStateChangeMask);
545 WMResizeWidget(panel->ddelaB[i], 25, 25);
546 WMMoveWidget(panel->ddelaB[i], 30+(40*i), 20);
547 WMSetButtonBordered(panel->ddelaB[i], False);
548 WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
549 WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
550 if (i>0) {
551 WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
553 sprintf(buf1, DELAY_ICON, i+1);
554 sprintf(buf2, DELAY_ICON_S, i+1);
555 path = LocateImage(buf1);
556 if (path) {
557 icon = WMCreatePixmapFromFile(scr, path);
558 if (icon) {
559 WMSetButtonImage(panel->ddelaB[i], icon);
560 WMReleasePixmap(icon);
561 } else {
562 wwarning(_("could not load icon file %s"), path);
564 wfree(path);
566 path = LocateImage(buf2);
567 if (path) {
568 icon = WMCreatePixmapFromFile(scr, path);
569 if (icon) {
570 WMSetButtonAltImage(panel->ddelaB[i], icon);
571 WMReleasePixmap(icon);
572 } else {
573 wwarning(_("could not load icon file %s"), path);
575 wfree(path);
578 wfree(buf1);
579 wfree(buf2);
581 panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
582 WMResizeWidget(panel->tester, 84, 29);
583 WMMoveWidget(panel->tester, 35, 55);
585 panel->ddelaT = WMCreateTextField(panel->ddelaF);
586 WMResizeWidget(panel->ddelaT, 40, 20);
587 WMMoveWidget(panel->ddelaT, 140, 60);
589 panel->ddelaL = WMCreateLabel(panel->ddelaF);
590 WMResizeWidget(panel->ddelaL, 40, 16);
591 WMMoveWidget(panel->ddelaL, 185, 65);
593 WMFont *font;
594 WMColor *color;
596 font = WMSystemFontOfSize(scr, 10);
597 color = WMDarkGrayColor(scr);
598 WMSetLabelTextColor(panel->ddelaL, color);
599 WMSetLabelFont(panel->ddelaL, font);
600 WMReleaseFont(font);
601 WMReleaseColor(color);
603 WMSetLabelText(panel->ddelaL, "msec");
605 WMMapSubwidgets(panel->ddelaF);
607 /* ************** Workspace Action Buttons **************** */
608 panel->menuF = WMCreateFrame(panel->frame);
609 WMResizeWidget(panel->menuF, 240, 145);
610 WMMoveWidget(panel->menuF, 270, 15);
611 WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));
613 panel->disaB = WMCreateSwitchButton(panel->menuF);
614 WMResizeWidget(panel->disaB, 205, 18);
615 WMMoveWidget(panel->disaB, 10, 20);
616 WMSetButtonText(panel->disaB, _("Disable mouse actions"));
619 panel->appL = WMCreateLabel(panel->menuF);
620 WMResizeWidget(panel->appL, 125, 16);
621 WMMoveWidget(panel->appL, 5, 45);
622 WMSetLabelTextAlignment(panel->appL, WARight);
623 WMSetLabelText(panel->appL, _("Applications menu"));
625 panel->appP = WMCreatePopUpButton(panel->menuF);
626 WMResizeWidget(panel->appP, 95, 20);
627 WMMoveWidget(panel->appP, 135, 45);
629 panel->listL = WMCreateLabel(panel->menuF);
630 WMResizeWidget(panel->listL, 125, 16);
631 WMMoveWidget(panel->listL, 5, 80);
632 WMSetLabelTextAlignment(panel->listL, WARight);
633 WMSetLabelText(panel->listL, _("Window list menu"));
635 panel->listP = WMCreatePopUpButton(panel->menuF);
636 WMResizeWidget(panel->listP, 95, 20);
637 WMMoveWidget(panel->listP, 135, 80);
640 panel->selL = WMCreateLabel(panel->menuF);
641 WMResizeWidget(panel->selL, 125, 16);
642 WMMoveWidget(panel->selL, 5, 115);
643 WMSetLabelTextAlignment(panel->selL, WARight);
644 WMSetLabelText(panel->selL, _("Select windows"));
646 panel->selP = WMCreatePopUpButton(panel->menuF);
647 WMResizeWidget(panel->selP, 95, 20);
648 WMMoveWidget(panel->selP, 135, 115);
650 for (i = 0; i < sizeof(buttonNames)/sizeof(char*); i++) {
651 WMAddPopUpButtonItem(panel->appP, buttonNames[i]);
652 WMAddPopUpButtonItem(panel->selP, buttonNames[i]);
653 WMAddPopUpButtonItem(panel->listP, buttonNames[i]);
656 WMMapSubwidgets(panel->menuF);
658 /* ************** Grab Modifier **************** */
659 panel->grabF = WMCreateFrame(panel->frame);
660 WMResizeWidget(panel->grabF, 240, 55);
661 WMMoveWidget(panel->grabF, 270, 165);
662 WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));
664 WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
665 "involve dragging windows with the mouse,\n"
666 "clicking inside the window."),
667 WMWidgetView(panel->grabF));
669 panel->grabP = WMCreatePopUpButton(panel->grabF);
670 WMResizeWidget(panel->grabP, 160, 20);
671 WMMoveWidget(panel->grabP, 40, 25);
673 fillModifierPopUp(panel->grabP);
675 WMMapSubwidgets(panel->grabF);
677 WMRealizeWidget(panel->frame);
678 WMMapSubwidgets(panel->frame);
681 showData(panel);
685 static void
686 storeCommandInScript(char *cmd, char *line)
688 char *path;
689 FILE *f;
690 char buffer[128];
692 path = wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart");
694 f = fopen(path, "r");
695 if (!f) {
696 f = fopen(path, "w");
697 if (!f) {
698 wsyserror(_("could not create %s"), path);
699 goto end;
701 fprintf(f, "#!/bin/sh\n");
702 fputs(line, f);
703 fputs("\n", f);
704 } else {
705 int len = strlen(cmd);
706 int ok = 0;
707 char *tmppath;
708 FILE *fo;
710 tmppath = wstrconcat(wusergnusteppath(),
711 "/Library/WindowMaker/autostart.tmp");
712 fo = fopen(tmppath, "w");
713 if (!fo) {
714 wsyserror(_("could not create temporary file %s"), tmppath);
715 wfree(tmppath);
716 goto end;
719 while (!feof(f)) {
720 if (!fgets(buffer, 127, f)) {
721 break;
723 if (buffer[0] == '\n') {
724 /* don't write empty lines, else the file will grow
725 * indefinitely (one '\n' added at end of file on each save).
727 continue;
729 if (strncmp(buffer, cmd, len)==0) {
730 if (!ok) {
731 fputs(line, fo);
732 fputs("\n", fo);
733 ok = 1;
735 } else {
736 fputs(buffer, fo);
739 if (!ok) {
740 fputs(line, fo);
741 fputs("\n", fo);
743 fclose(fo);
745 if (rename(tmppath, path)!=0) {
746 wsyserror(_("could not rename file %s to %s\n"), tmppath, path);
748 wfree(tmppath);
750 sprintf(buffer, "chmod u+x %s", path);
751 system(buffer);
753 end:
754 wfree(path);
755 if (f)
756 fclose(f);
760 static void
761 storeData(_Panel *panel)
763 char buffer[64];
764 int i;
765 char *tmp, *p;
766 static char *button[6] = {"None", "left", "middle", "right", "Button4", "Button5"};
767 WMUserDefaults *udb = WMGetStandardUserDefaults();
769 if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) {
770 tmp = WMGetTextFieldText(panel->threT);
771 if (strlen(tmp)==0) {
772 wfree(tmp);
773 tmp = wstrdup("4");
776 sprintf(buffer, XSET" m %i/%i %s\n", (int)(panel->acceleration*10),
777 10, tmp);
778 storeCommandInScript(XSET" m", buffer);
780 wfree(tmp);
783 tmp = WMGetTextFieldText(panel->ddelaT);
784 if (sscanf(tmp, "%i", &i) == 1 && i > 0)
785 SetIntegerForKey(i, "DoubleClickTime");
787 SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions");
789 i = WMGetPopUpButtonSelectedItem(panel->appP);
790 SetStringForKey(button[i], "ApplicationMenuMouseButton");
792 i = WMGetPopUpButtonSelectedItem(panel->listP);
793 SetStringForKey(button[i], "WindowListMouseButton");
795 i = WMGetPopUpButtonSelectedItem(panel->selP);
796 SetStringForKey(button[i], "SelectWindowsMouseButton");
798 tmp = WMGetPopUpButtonItem(panel->grabP,
799 WMGetPopUpButtonSelectedItem(panel->grabP));
800 tmp = wstrdup(tmp);
801 p = strchr(tmp, ' ');
802 *p = 0;
804 SetStringForKey(tmp, "ModifierKey");
806 wfree(tmp);
810 Panel*
811 InitMouseSettings(WMScreen *scr, WMWindow *win)
813 _Panel *panel;
815 panel = wmalloc(sizeof(_Panel));
816 memset(panel, 0, sizeof(_Panel));
818 panel->sectionName = _("Mouse Preferences");
820 panel->description = _("Mouse speed/acceleration, double click delay,\n"
821 "mouse button bindings etc.");
823 panel->win = win;
825 panel->callbacks.createWidgets = createPanel;
826 panel->callbacks.updateDomain = storeData;
828 AddSection(panel, ICON_FILE);
830 return panel;