Fixed compile problems.
[wmaker-crm.git] / WPrefs.app / MouseSettings.c
blobda293fa10ebbbc7bc690f41ce5e1199bbfb5d231
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 free(tmp);
156 return;
158 panel->acceleration = accel;
159 free(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 free(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, "left")==0)
219 return 1;
220 else if (strcasecmp(str, "middle")==0)
221 return 2;
222 else if (strcasecmp(str, "right")==0)
223 return 3;
224 else if (strcasecmp(str, "button1")==0)
225 return 1;
226 else if (strcasecmp(str, "button2")==0)
227 return 2;
228 else if (strcasecmp(str, "button3")==0)
229 return 3;
230 else if (strcasecmp(str, "button4")==0)
231 return 4;
232 else if (strcasecmp(str, "button5")==0) {
233 return 5;
234 } else {
235 return -1;
240 static void
241 getMouseParameters(Display *dpy, float *accel, int *thre)
243 int n, d;
245 XGetPointerControl(dpy, &n, &d, thre);
247 *accel = (float)n/(float)d;
252 static void
253 showData(_Panel *panel)
255 char *str;
256 int i;
257 int a=-1, b=-1, c=-1;
258 float accel;
259 char buffer[32];
260 Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->win));
262 str = GetStringForKey("SelectWindowsMouseButton");
263 if (str) {
264 i = getbutton(str);
265 if (i==-1) {
266 a = 1;
267 wwarning(_("bad value %s for option %s"),str, "SelectWindowsMouseButton");
268 } else if (i>=0) {
269 a = i;
271 } else {
272 a = 0;
274 WMSetPopUpButtonSelectedItem(panel->selP, a);
276 str = GetStringForKey("WindowListMouseButton");
277 if (str) {
278 i = getbutton(str);
279 if (i==-1) {
280 b = 2;
281 wwarning(_("bad value %s for option %s"), str, "WindowListMouseButton");
282 } else if (i>=0) {
283 b = i;
285 } else {
286 b = 0;
288 WMSetPopUpButtonSelectedItem(panel->listP, b);
290 str = GetStringForKey("ApplicationMenuMouseButton");
291 if (str) {
292 i = getbutton(str);
293 if (i==-1) {
294 c = 3;
295 wwarning(_("bad value %s for option %s"), str, "ApplicationMenuMouseButton");
296 } else if (i>=0) {
297 c = i;
299 } else {
300 c = 0;
302 WMSetPopUpButtonSelectedItem(panel->appP, c);
304 WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions"));
306 /**/
307 getMouseParameters(dpy, &accel, &a);
308 panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy));
309 if (a > panel->maxThreshold) {
310 panel->maxThreshold = a;
312 sprintf(buffer, "%i", a);
313 WMSetTextFieldText(panel->threT, buffer);
315 WMSetSliderValue(panel->speedS, (accel - 0.25)/0.25);
317 panel->acceleration = accel;
318 sprintf(buffer, "%.2f", accel);
319 WMSetTextFieldText(panel->acceT, buffer);
321 /**/
322 b = GetIntegerForKey("DoubleClickTime");
323 /* find best match */
324 a = -1;
325 for (i=0; i<5; i++) {
326 if (DELAY(i) == b)
327 a = i;
329 if (a >= 0)
330 WMPerformButtonClick(panel->ddelaB[a]);
331 sprintf(buffer, "%i", b);
332 WMSetTextFieldText(panel->ddelaT, buffer);
334 /**/
335 str = GetStringForKey("ModifierKey");
336 if (!str)
337 str = "mod1";
338 a = ModifierFromKey(dpy, str);
340 if (a != -1) {
341 str = modifierNames[a];
343 a = 0;
344 for (i=0; i<WMGetPopUpButtonNumberOfItems(panel->grabP); i++) {
345 if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) {
346 WMSetPopUpButtonSelectedItem(panel->grabP, i);
347 a = 1;
348 break;
353 if (a < 1) {
354 sscanf(WMGetPopUpButtonItem(panel->grabP, 0), "%s", buffer);
355 WMSetPopUpButtonSelectedItem(panel->grabP, 0);
356 wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"),
357 str, buffer);
363 static void
364 fillModifierPopUp(WMPopUpButton *pop)
366 XModifierKeymap *mapping;
367 Display *dpy = WMScreenDisplay(WMWidgetScreen(pop));
368 int i, j;
369 char *str;
370 char buffer[64];
373 mapping = XGetModifierMapping(dpy);
375 if (!mapping || mapping->max_keypermod==0) {
376 WMAddPopUpButtonItem(pop, "Mod1");
377 WMAddPopUpButtonItem(pop, "Mod2");
378 WMAddPopUpButtonItem(pop, "Mod3");
379 WMAddPopUpButtonItem(pop, "Mod4");
380 WMAddPopUpButtonItem(pop, "Mod5");
381 wwarning(_("could not retrieve keyboard modifier mapping"));
382 return;
386 for (j=0; j<8; j++) {
387 int idx;
388 char *array[8];
389 int a;
390 KeySym ksym;
391 int k;
392 char *ptr;
393 char *tmp;
395 a = 0;
396 memset(array, 0, sizeof(char*)*8);
397 for (i=0; i < mapping->max_keypermod; i++) {
398 idx = i+j*mapping->max_keypermod;
399 if (mapping->modifiermap[idx]!=0) {
400 int l;
401 for (l=0; l<4; l++) {
402 ksym = XKeycodeToKeysym(dpy, mapping->modifiermap[idx], l);
403 if (ksym!=NoSymbol)
404 break;
406 if (ksym!=NoSymbol)
407 str = XKeysymToString(ksym);
408 else
409 str = NULL;
410 if (str && !strstr(str, "_Lock") && !strstr(str, "Shift")
411 && !strstr(str, "Control")) {
412 array[a++] = wstrdup(str);
417 for (k=0; k<a; k++) {
418 if (array[k]==NULL)
419 continue;
420 tmp = wstrdup(array[k]);
421 ptr = strstr(tmp, "_L");
422 if (ptr)
423 *ptr = 0;
424 ptr = strstr(tmp, "_R");
425 if (ptr)
426 *ptr = 0;
427 sprintf(buffer, "%s (%s)", modifierNames[j], tmp);
428 WMAddPopUpButtonItem(pop, buffer);
429 for (i=k+1; i<a; i++) {
430 if (array[i] == NULL)
431 continue;
432 if (strstr(array[i], tmp)) {
433 free(array[i]);
434 array[i]=NULL;
435 break;
438 free(tmp);
441 while (--a>0) {
442 if (array[a])
443 free(array[a]);
447 if (mapping)
448 XFreeModifiermap(mapping);
453 static void
454 createPanel(Panel *p)
456 _Panel *panel = (_Panel*)p;
457 WMScreen *scr = WMWidgetScreen(panel->win);
458 WMPixmap *icon;
459 char *buf1, *buf2;
460 int i;
461 RColor color;
462 char *path;
464 color.red = 0xaa;
465 color.green = 0xae;
466 color.blue = 0xaa;
468 panel->frame = WMCreateFrame(panel->win);
469 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
470 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
472 /**************** Mouse Speed ****************/
473 panel->speedF = WMCreateFrame(panel->frame);
474 WMResizeWidget(panel->speedF, 245, 100);
475 WMMoveWidget(panel->speedF, 15, 15);
476 WMSetFrameTitle(panel->speedF, _("Mouse Speed"));
478 panel->speedL = WMCreateLabel(panel->speedF);
479 WMResizeWidget(panel->speedL, 40, 46);
480 WMMoveWidget(panel->speedL, 15, 14);
481 WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
482 path = LocateImage(SPEED_ICON_FILE);
483 if (path) {
484 icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
485 if (icon) {
486 WMSetLabelImage(panel->speedL, icon);
487 WMReleasePixmap(icon);
488 } else {
489 wwarning(_("could not load icon %s"), path);
491 free(path);
494 panel->speedS = WMCreateSlider(panel->speedF);
495 WMResizeWidget(panel->speedS, 160, 15);
496 WMMoveWidget(panel->speedS, 70, 35);
497 WMSetSliderMinValue(panel->speedS, 0);
498 WMSetSliderMaxValue(panel->speedS, 40);
499 WMSetSliderContinuous(panel->speedS, False);
500 WMSetSliderAction(panel->speedS, speedChange, panel);
502 panel->acceL = WMCreateLabel(panel->speedF);
503 WMResizeWidget(panel->acceL, 70, 16);
504 WMMoveWidget(panel->acceL, 10, 67);
505 WMSetLabelTextAlignment(panel->acceL, WARight);
506 WMSetLabelText(panel->acceL, _("Acceler.:"));
508 panel->acceT = WMCreateTextField(panel->speedF);
509 WMResizeWidget(panel->acceT, 40, 20);
510 WMMoveWidget(panel->acceT, 80, 65);
511 WMAddNotificationObserver(returnPressed, panel,
512 WMTextDidEndEditingNotification, panel->acceT);
515 panel->threL = WMCreateLabel(panel->speedF);
516 WMResizeWidget(panel->threL, 80, 16);
517 WMMoveWidget(panel->threL, 120, 67);
518 WMSetLabelTextAlignment(panel->threL, WARight);
519 WMSetLabelText(panel->threL, _("Threshold:"));
521 panel->threT = WMCreateTextField(panel->speedF);
522 WMResizeWidget(panel->threT, 30, 20);
523 WMMoveWidget(panel->threT, 200, 65);
524 WMAddNotificationObserver(returnPressed, panel,
525 WMTextDidEndEditingNotification, panel->threT);
527 WMMapSubwidgets(panel->speedF);
529 /***************** Doubleclick Delay ****************/
531 panel->ddelaF = WMCreateFrame(panel->frame);
532 WMResizeWidget(panel->ddelaF, 245, 95);
533 WMMoveWidget(panel->ddelaF, 15, 125);
534 WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));
536 buf1 = wmalloc(strlen(DELAY_ICON)+2);
537 buf2 = wmalloc(strlen(DELAY_ICON_S)+2);
539 for (i = 0; i < 5; i++) {
540 panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF,
541 WBBStateChangeMask);
542 WMResizeWidget(panel->ddelaB[i], 25, 25);
543 WMMoveWidget(panel->ddelaB[i], 30+(40*i), 20);
544 WMSetButtonBordered(panel->ddelaB[i], False);
545 WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
546 WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
547 if (i>0) {
548 WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
550 sprintf(buf1, DELAY_ICON, i+1);
551 sprintf(buf2, DELAY_ICON_S, i+1);
552 path = LocateImage(buf1);
553 if (path) {
554 icon = WMCreatePixmapFromFile(scr, path);
555 if (icon) {
556 WMSetButtonImage(panel->ddelaB[i], icon);
557 WMReleasePixmap(icon);
558 } else {
559 wwarning(_("could not load icon file %s"), path);
561 free(path);
563 path = LocateImage(buf2);
564 if (path) {
565 icon = WMCreatePixmapFromFile(scr, path);
566 if (icon) {
567 WMSetButtonAltImage(panel->ddelaB[i], icon);
568 WMReleasePixmap(icon);
569 } else {
570 wwarning(_("could not load icon file %s"), path);
572 free(path);
575 free(buf1);
576 free(buf2);
578 panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
579 WMResizeWidget(panel->tester, 84, 29);
580 WMMoveWidget(panel->tester, 35, 55);
582 panel->ddelaT = WMCreateTextField(panel->ddelaF);
583 WMResizeWidget(panel->ddelaT, 40, 20);
584 WMMoveWidget(panel->ddelaT, 140, 60);
586 panel->ddelaL = WMCreateLabel(panel->ddelaF);
587 WMResizeWidget(panel->ddelaL, 40, 16);
588 WMMoveWidget(panel->ddelaL, 185, 65);
590 WMFont *font;
591 WMColor *color;
593 font = WMSystemFontOfSize(scr, 10);
594 color = WMDarkGrayColor(scr);
595 WMSetLabelTextColor(panel->ddelaL, color);
596 WMSetLabelFont(panel->ddelaL, font);
597 WMReleaseFont(font);
598 WMReleaseColor(color);
600 WMSetLabelText(panel->ddelaL, "msec");
602 WMMapSubwidgets(panel->ddelaF);
604 /* ************** Workspace Action Buttons **************** */
605 panel->menuF = WMCreateFrame(panel->frame);
606 WMResizeWidget(panel->menuF, 240, 145);
607 WMMoveWidget(panel->menuF, 270, 15);
608 WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));
610 panel->disaB = WMCreateSwitchButton(panel->menuF);
611 WMResizeWidget(panel->disaB, 205, 18);
612 WMMoveWidget(panel->disaB, 10, 20);
613 WMSetButtonText(panel->disaB, _("Disable mouse actions"));
616 panel->appL = WMCreateLabel(panel->menuF);
617 WMResizeWidget(panel->appL, 125, 16);
618 WMMoveWidget(panel->appL, 5, 45);
619 WMSetLabelTextAlignment(panel->appL, WARight);
620 WMSetLabelText(panel->appL, _("Applications menu"));
622 panel->appP = WMCreatePopUpButton(panel->menuF);
623 WMResizeWidget(panel->appP, 95, 20);
624 WMMoveWidget(panel->appP, 135, 45);
626 panel->listL = WMCreateLabel(panel->menuF);
627 WMResizeWidget(panel->listL, 125, 16);
628 WMMoveWidget(panel->listL, 5, 80);
629 WMSetLabelTextAlignment(panel->listL, WARight);
630 WMSetLabelText(panel->listL, _("Window list menu"));
632 panel->listP = WMCreatePopUpButton(panel->menuF);
633 WMResizeWidget(panel->listP, 95, 20);
634 WMMoveWidget(panel->listP, 135, 80);
637 panel->selL = WMCreateLabel(panel->menuF);
638 WMResizeWidget(panel->selL, 125, 16);
639 WMMoveWidget(panel->selL, 5, 115);
640 WMSetLabelTextAlignment(panel->selL, WARight);
641 WMSetLabelText(panel->selL, _("Select windows"));
643 panel->selP = WMCreatePopUpButton(panel->menuF);
644 WMResizeWidget(panel->selP, 95, 20);
645 WMMoveWidget(panel->selP, 135, 115);
647 for (i = 0; i < sizeof(buttonNames)/sizeof(char*); i++) {
648 WMAddPopUpButtonItem(panel->appP, buttonNames[i]);
649 WMAddPopUpButtonItem(panel->selP, buttonNames[i]);
650 WMAddPopUpButtonItem(panel->listP, buttonNames[i]);
653 WMMapSubwidgets(panel->menuF);
655 /* ************** Grab Modifier **************** */
656 panel->grabF = WMCreateFrame(panel->frame);
657 WMResizeWidget(panel->grabF, 240, 55);
658 WMMoveWidget(panel->grabF, 270, 165);
659 WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));
661 WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
662 "involve dragging windows with the mouse,\n"
663 "clicking inside the window."),
664 WMWidgetView(panel->grabF));
666 panel->grabP = WMCreatePopUpButton(panel->grabF);
667 WMResizeWidget(panel->grabP, 160, 20);
668 WMMoveWidget(panel->grabP, 40, 25);
670 fillModifierPopUp(panel->grabP);
672 WMMapSubwidgets(panel->grabF);
674 WMRealizeWidget(panel->frame);
675 WMMapSubwidgets(panel->frame);
678 showData(panel);
682 static void
683 storeCommandInScript(char *cmd, char *line)
685 char *path;
686 FILE *f;
687 char buffer[128];
689 path = wstrappend(wusergnusteppath(), "/Library/WindowMaker/autostart");
691 f = fopen(path, "r");
692 if (!f) {
693 f = fopen(path, "w");
694 if (!f) {
695 wsyserror(_("could not create %s"), path);
696 goto end;
698 fprintf(f, "#!/bin/sh\n");
699 fputs(line, f);
700 fputs("\n", f);
701 } else {
702 int len = strlen(cmd);
703 int ok = 0;
704 char *tmppath;
705 FILE *fo;
707 tmppath = wstrappend(wusergnusteppath(),
708 "/Library/WindowMaker/autostart.tmp");
709 fo = fopen(tmppath, "w");
710 if (!fo) {
711 wsyserror(_("could not create temporary file %s"), tmppath);
712 goto end;
715 while (!feof(f)) {
716 if (!fgets(buffer, 127, f)) {
717 break;
719 if (buffer[0] == '\n') {
720 /* don't write empty lines, else the file will grow
721 * indefinitely (one '\n' added at end of file on each save).
723 continue;
725 if (strncmp(buffer, cmd, len)==0) {
726 if (!ok) {
727 fputs(line, fo);
728 fputs("\n", fo);
729 ok = 1;
731 } else {
732 fputs(buffer, fo);
735 if (!ok) {
736 fputs(line, fo);
737 fputs("\n", fo);
739 fclose(fo);
741 if (rename(tmppath, path)!=0) {
742 wsyserror(_("could not rename file %s to %s\n"), tmppath, path);
744 free(tmppath);
746 sprintf(buffer, "chmod u+x %s", path);
747 system(buffer);
749 end:
750 free(path);
751 if (f)
752 fclose(f);
756 static void
757 storeData(_Panel *panel)
759 char buffer[64];
760 int i;
761 char *tmp, *p;
762 static char *button[6] = {"None", "left", "middle", "right", "Button4", "Button5"};
763 WMUserDefaults *udb = WMGetStandardUserDefaults();
765 if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) {
766 tmp = WMGetTextFieldText(panel->threT);
767 if (strlen(tmp)==0) {
768 free(tmp);
769 tmp = wstrdup("4");
772 sprintf(buffer, XSET" m %i/%i %s\n", (int)(panel->acceleration*10),
773 10, tmp);
774 storeCommandInScript(XSET" m", buffer);
776 free(tmp);
779 tmp = WMGetTextFieldText(panel->ddelaT);
780 if (sscanf(tmp, "%i", &i) == 1 && i > 0)
781 SetIntegerForKey(i, "DoubleClickTime");
783 SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions");
785 i = WMGetPopUpButtonSelectedItem(panel->appP);
786 SetStringForKey(button[i], "ApplicationMenuMouseButton");
788 i = WMGetPopUpButtonSelectedItem(panel->listP);
789 SetStringForKey(button[i], "WindowListMouseButton");
791 i = WMGetPopUpButtonSelectedItem(panel->selP);
792 SetStringForKey(button[i], "SelectWindowsMouseButton");
794 tmp = WMGetPopUpButtonItem(panel->grabP,
795 WMGetPopUpButtonSelectedItem(panel->grabP));
796 tmp = wstrdup(tmp);
797 p = strchr(tmp, ' ');
798 *p = 0;
800 SetStringForKey(tmp, "ModifierKey");
802 free(tmp);
806 Panel*
807 InitMouseSettings(WMScreen *scr, WMWindow *win)
809 _Panel *panel;
811 panel = wmalloc(sizeof(_Panel));
812 memset(panel, 0, sizeof(_Panel));
814 panel->sectionName = _("Mouse Preferences");
816 panel->description = _("Mouse speed/acceleration, double click delay,\n"
817 "mouse button bindings etc.");
819 panel->win = win;
821 panel->callbacks.createWidgets = createPanel;
822 panel->callbacks.updateDomain = storeData;
824 AddSection(panel, ICON_FILE);
826 return panel;