- Replaced all free() with wfree() where appropriate
[wmaker-crm.git] / WPrefs.app / MouseSettings.c
blob83993a631d50e8cc58c40fbb0e36d0c82e19fd8e
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 "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 WMAddPopUpButtonItem(pop, buffer);
431 for (i=k+1; i<a; i++) {
432 if (array[i] == NULL)
433 continue;
434 if (strstr(array[i], tmp)) {
435 wfree(array[i]);
436 array[i]=NULL;
437 break;
440 wfree(tmp);
443 while (--a>0) {
444 if (array[a])
445 wfree(array[a]);
449 if (mapping)
450 XFreeModifiermap(mapping);
455 static void
456 createPanel(Panel *p)
458 _Panel *panel = (_Panel*)p;
459 WMScreen *scr = WMWidgetScreen(panel->win);
460 WMPixmap *icon;
461 char *buf1, *buf2;
462 int i;
463 RColor color;
464 char *path;
466 color.red = 0xaa;
467 color.green = 0xae;
468 color.blue = 0xaa;
470 panel->frame = WMCreateFrame(panel->win);
471 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
472 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
474 /**************** Mouse Speed ****************/
475 panel->speedF = WMCreateFrame(panel->frame);
476 WMResizeWidget(panel->speedF, 245, 100);
477 WMMoveWidget(panel->speedF, 15, 15);
478 WMSetFrameTitle(panel->speedF, _("Mouse Speed"));
480 panel->speedL = WMCreateLabel(panel->speedF);
481 WMResizeWidget(panel->speedL, 40, 46);
482 WMMoveWidget(panel->speedL, 15, 14);
483 WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
484 path = LocateImage(SPEED_ICON_FILE);
485 if (path) {
486 icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
487 if (icon) {
488 WMSetLabelImage(panel->speedL, icon);
489 WMReleasePixmap(icon);
490 } else {
491 wwarning(_("could not load icon %s"), path);
493 wfree(path);
496 panel->speedS = WMCreateSlider(panel->speedF);
497 WMResizeWidget(panel->speedS, 160, 15);
498 WMMoveWidget(panel->speedS, 70, 35);
499 WMSetSliderMinValue(panel->speedS, 0);
500 WMSetSliderMaxValue(panel->speedS, 40);
501 WMSetSliderContinuous(panel->speedS, False);
502 WMSetSliderAction(panel->speedS, speedChange, panel);
504 panel->acceL = WMCreateLabel(panel->speedF);
505 WMResizeWidget(panel->acceL, 70, 16);
506 WMMoveWidget(panel->acceL, 10, 67);
507 WMSetLabelTextAlignment(panel->acceL, WARight);
508 WMSetLabelText(panel->acceL, _("Acceler.:"));
510 panel->acceT = WMCreateTextField(panel->speedF);
511 WMResizeWidget(panel->acceT, 40, 20);
512 WMMoveWidget(panel->acceT, 80, 65);
513 WMAddNotificationObserver(returnPressed, panel,
514 WMTextDidEndEditingNotification, panel->acceT);
517 panel->threL = WMCreateLabel(panel->speedF);
518 WMResizeWidget(panel->threL, 80, 16);
519 WMMoveWidget(panel->threL, 120, 67);
520 WMSetLabelTextAlignment(panel->threL, WARight);
521 WMSetLabelText(panel->threL, _("Threshold:"));
523 panel->threT = WMCreateTextField(panel->speedF);
524 WMResizeWidget(panel->threT, 30, 20);
525 WMMoveWidget(panel->threT, 200, 65);
526 WMAddNotificationObserver(returnPressed, panel,
527 WMTextDidEndEditingNotification, panel->threT);
529 WMMapSubwidgets(panel->speedF);
531 /***************** Doubleclick Delay ****************/
533 panel->ddelaF = WMCreateFrame(panel->frame);
534 WMResizeWidget(panel->ddelaF, 245, 95);
535 WMMoveWidget(panel->ddelaF, 15, 125);
536 WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));
538 buf1 = wmalloc(strlen(DELAY_ICON)+2);
539 buf2 = wmalloc(strlen(DELAY_ICON_S)+2);
541 for (i = 0; i < 5; i++) {
542 panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF,
543 WBBStateChangeMask);
544 WMResizeWidget(panel->ddelaB[i], 25, 25);
545 WMMoveWidget(panel->ddelaB[i], 30+(40*i), 20);
546 WMSetButtonBordered(panel->ddelaB[i], False);
547 WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
548 WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
549 if (i>0) {
550 WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
552 sprintf(buf1, DELAY_ICON, i+1);
553 sprintf(buf2, DELAY_ICON_S, i+1);
554 path = LocateImage(buf1);
555 if (path) {
556 icon = WMCreatePixmapFromFile(scr, path);
557 if (icon) {
558 WMSetButtonImage(panel->ddelaB[i], icon);
559 WMReleasePixmap(icon);
560 } else {
561 wwarning(_("could not load icon file %s"), path);
563 wfree(path);
565 path = LocateImage(buf2);
566 if (path) {
567 icon = WMCreatePixmapFromFile(scr, path);
568 if (icon) {
569 WMSetButtonAltImage(panel->ddelaB[i], icon);
570 WMReleasePixmap(icon);
571 } else {
572 wwarning(_("could not load icon file %s"), path);
574 wfree(path);
577 wfree(buf1);
578 wfree(buf2);
580 panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
581 WMResizeWidget(panel->tester, 84, 29);
582 WMMoveWidget(panel->tester, 35, 55);
584 panel->ddelaT = WMCreateTextField(panel->ddelaF);
585 WMResizeWidget(panel->ddelaT, 40, 20);
586 WMMoveWidget(panel->ddelaT, 140, 60);
588 panel->ddelaL = WMCreateLabel(panel->ddelaF);
589 WMResizeWidget(panel->ddelaL, 40, 16);
590 WMMoveWidget(panel->ddelaL, 185, 65);
592 WMFont *font;
593 WMColor *color;
595 font = WMSystemFontOfSize(scr, 10);
596 color = WMDarkGrayColor(scr);
597 WMSetLabelTextColor(panel->ddelaL, color);
598 WMSetLabelFont(panel->ddelaL, font);
599 WMReleaseFont(font);
600 WMReleaseColor(color);
602 WMSetLabelText(panel->ddelaL, "msec");
604 WMMapSubwidgets(panel->ddelaF);
606 /* ************** Workspace Action Buttons **************** */
607 panel->menuF = WMCreateFrame(panel->frame);
608 WMResizeWidget(panel->menuF, 240, 145);
609 WMMoveWidget(panel->menuF, 270, 15);
610 WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));
612 panel->disaB = WMCreateSwitchButton(panel->menuF);
613 WMResizeWidget(panel->disaB, 205, 18);
614 WMMoveWidget(panel->disaB, 10, 20);
615 WMSetButtonText(panel->disaB, _("Disable mouse actions"));
618 panel->appL = WMCreateLabel(panel->menuF);
619 WMResizeWidget(panel->appL, 125, 16);
620 WMMoveWidget(panel->appL, 5, 45);
621 WMSetLabelTextAlignment(panel->appL, WARight);
622 WMSetLabelText(panel->appL, _("Applications menu"));
624 panel->appP = WMCreatePopUpButton(panel->menuF);
625 WMResizeWidget(panel->appP, 95, 20);
626 WMMoveWidget(panel->appP, 135, 45);
628 panel->listL = WMCreateLabel(panel->menuF);
629 WMResizeWidget(panel->listL, 125, 16);
630 WMMoveWidget(panel->listL, 5, 80);
631 WMSetLabelTextAlignment(panel->listL, WARight);
632 WMSetLabelText(panel->listL, _("Window list menu"));
634 panel->listP = WMCreatePopUpButton(panel->menuF);
635 WMResizeWidget(panel->listP, 95, 20);
636 WMMoveWidget(panel->listP, 135, 80);
639 panel->selL = WMCreateLabel(panel->menuF);
640 WMResizeWidget(panel->selL, 125, 16);
641 WMMoveWidget(panel->selL, 5, 115);
642 WMSetLabelTextAlignment(panel->selL, WARight);
643 WMSetLabelText(panel->selL, _("Select windows"));
645 panel->selP = WMCreatePopUpButton(panel->menuF);
646 WMResizeWidget(panel->selP, 95, 20);
647 WMMoveWidget(panel->selP, 135, 115);
649 for (i = 0; i < sizeof(buttonNames)/sizeof(char*); i++) {
650 WMAddPopUpButtonItem(panel->appP, buttonNames[i]);
651 WMAddPopUpButtonItem(panel->selP, buttonNames[i]);
652 WMAddPopUpButtonItem(panel->listP, buttonNames[i]);
655 WMMapSubwidgets(panel->menuF);
657 /* ************** Grab Modifier **************** */
658 panel->grabF = WMCreateFrame(panel->frame);
659 WMResizeWidget(panel->grabF, 240, 55);
660 WMMoveWidget(panel->grabF, 270, 165);
661 WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));
663 WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
664 "involve dragging windows with the mouse,\n"
665 "clicking inside the window."),
666 WMWidgetView(panel->grabF));
668 panel->grabP = WMCreatePopUpButton(panel->grabF);
669 WMResizeWidget(panel->grabP, 160, 20);
670 WMMoveWidget(panel->grabP, 40, 25);
672 fillModifierPopUp(panel->grabP);
674 WMMapSubwidgets(panel->grabF);
676 WMRealizeWidget(panel->frame);
677 WMMapSubwidgets(panel->frame);
680 showData(panel);
684 static void
685 storeCommandInScript(char *cmd, char *line)
687 char *path;
688 FILE *f;
689 char buffer[128];
691 path = wstrappend(wusergnusteppath(), "/Library/WindowMaker/autostart");
693 f = fopen(path, "r");
694 if (!f) {
695 f = fopen(path, "w");
696 if (!f) {
697 wsyserror(_("could not create %s"), path);
698 goto end;
700 fprintf(f, "#!/bin/sh\n");
701 fputs(line, f);
702 fputs("\n", f);
703 } else {
704 int len = strlen(cmd);
705 int ok = 0;
706 char *tmppath;
707 FILE *fo;
709 tmppath = wstrappend(wusergnusteppath(),
710 "/Library/WindowMaker/autostart.tmp");
711 fo = fopen(tmppath, "w");
712 if (!fo) {
713 wsyserror(_("could not create temporary file %s"), tmppath);
714 wfree(tmppath);
715 goto end;
718 while (!feof(f)) {
719 if (!fgets(buffer, 127, f)) {
720 break;
722 if (buffer[0] == '\n') {
723 /* don't write empty lines, else the file will grow
724 * indefinitely (one '\n' added at end of file on each save).
726 continue;
728 if (strncmp(buffer, cmd, len)==0) {
729 if (!ok) {
730 fputs(line, fo);
731 fputs("\n", fo);
732 ok = 1;
734 } else {
735 fputs(buffer, fo);
738 if (!ok) {
739 fputs(line, fo);
740 fputs("\n", fo);
742 fclose(fo);
744 if (rename(tmppath, path)!=0) {
745 wsyserror(_("could not rename file %s to %s\n"), tmppath, path);
747 wfree(tmppath);
749 sprintf(buffer, "chmod u+x %s", path);
750 system(buffer);
752 end:
753 wfree(path);
754 if (f)
755 fclose(f);
759 static void
760 storeData(_Panel *panel)
762 char buffer[64];
763 int i;
764 char *tmp, *p;
765 static char *button[6] = {"None", "left", "middle", "right", "Button4", "Button5"};
766 WMUserDefaults *udb = WMGetStandardUserDefaults();
768 if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) {
769 tmp = WMGetTextFieldText(panel->threT);
770 if (strlen(tmp)==0) {
771 wfree(tmp);
772 tmp = wstrdup("4");
775 sprintf(buffer, XSET" m %i/%i %s\n", (int)(panel->acceleration*10),
776 10, tmp);
777 storeCommandInScript(XSET" m", buffer);
779 wfree(tmp);
782 tmp = WMGetTextFieldText(panel->ddelaT);
783 if (sscanf(tmp, "%i", &i) == 1 && i > 0)
784 SetIntegerForKey(i, "DoubleClickTime");
786 SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions");
788 i = WMGetPopUpButtonSelectedItem(panel->appP);
789 SetStringForKey(button[i], "ApplicationMenuMouseButton");
791 i = WMGetPopUpButtonSelectedItem(panel->listP);
792 SetStringForKey(button[i], "WindowListMouseButton");
794 i = WMGetPopUpButtonSelectedItem(panel->selP);
795 SetStringForKey(button[i], "SelectWindowsMouseButton");
797 tmp = WMGetPopUpButtonItem(panel->grabP,
798 WMGetPopUpButtonSelectedItem(panel->grabP));
799 tmp = wstrdup(tmp);
800 p = strchr(tmp, ' ');
801 *p = 0;
803 SetStringForKey(tmp, "ModifierKey");
805 wfree(tmp);
809 Panel*
810 InitMouseSettings(WMScreen *scr, WMWindow *win)
812 _Panel *panel;
814 panel = wmalloc(sizeof(_Panel));
815 memset(panel, 0, sizeof(_Panel));
817 panel->sectionName = _("Mouse Preferences");
819 panel->description = _("Mouse speed/acceleration, double click delay,\n"
820 "mouse button bindings etc.");
822 panel->win = win;
824 panel->callbacks.createWidgets = createPanel;
825 panel->callbacks.updateDomain = storeData;
827 AddSection(panel, ICON_FILE);
829 return panel;