wmaker: Cleaned dangerous function prototype usage
[wmaker-crm.git] / WPrefs.app / MouseSettings.c
blob2c836aefead1c00bcdbcc0eca12ecba7ae9d1bfa
2 /* MouseSettings.c- mouse options (some are equivalent to xset)
4 * WPrefs - Window Maker Preferences Program
6 * Copyright (c) 1998-2003 Alfredo K. Kojima
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 along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "WPrefs.h"
25 #include <X11/Xutil.h>
26 #include <X11/XKBlib.h>
28 #include <unistd.h>
29 #include <math.h>
32 #define XSET "xset"
34 typedef struct _Panel {
35 WMBox *box;
37 char *sectionName;
39 char *description;
41 CallbackRec callbacks;
43 WMWidget *parent;
45 WMFrame *speedF;
46 WMLabel *speedL;
47 WMSlider *speedS;
48 WMLabel *acceL;
49 WMTextField *acceT;
50 WMLabel *threL;
51 WMTextField *threT;
53 WMFrame *ddelaF;
54 WMButton *ddelaB[5];
55 WMTextField *ddelaT;
56 WMLabel *ddelaL;
57 DoubleTest *tester;
59 WMFrame *menuF;
60 WMLabel *button1L;
61 WMLabel *button2L;
62 WMLabel *button3L;
63 WMLabel *wheelL;
64 WMPopUpButton *button1P;
65 WMPopUpButton *button2P;
66 WMPopUpButton *button3P;
67 WMPopUpButton *wheelP;
69 WMButton *disaB;
71 WMFrame *grabF;
72 WMPopUpButton *grabP;
74 /**/ int maxThreshold;
75 float acceleration;
76 } _Panel;
78 #define ICON_FILE "mousesettings"
80 #define SPEED_ICON_FILE "mousespeed"
82 #define DELAY_ICON "timer%i"
83 #define DELAY_ICON_S "timer%is"
85 /* need access to the double click variables */
86 #include <WINGs/WINGsP.h>
88 static char *modifierNames[8];
90 static char *buttonActions[4];
92 static char *wheelActions[2];
94 #define DELAY(i) ((i)*75+170)
97 static void setMouseAccel(WMScreen * scr, float accel, int threshold)
99 int n, d;
101 d = 10;
102 n = accel * d;
104 XChangePointerControl(WMScreenDisplay(scr), True, True, n, d, threshold);
107 static void speedChange(WMWidget * w, void *data)
109 _Panel *panel = (_Panel *) data;
110 int i;
111 char buffer[64];
112 int threshold;
113 char *tmp;
115 if (w == NULL) {
116 float accel;
118 tmp = WMGetTextFieldText(panel->acceT);
119 if (sscanf(tmp, "%f", &accel) != 1 || accel < 0) {
120 WMRunAlertPanel(WMWidgetScreen(panel->acceT), GetWindow(panel),
121 _("Error"),
122 _("Invalid mouse acceleration value. Must be a positive real value."),
123 _("OK"), NULL, NULL);
124 wfree(tmp);
125 return;
127 panel->acceleration = accel;
128 wfree(tmp);
129 } else {
130 i = (int)WMGetSliderValue(panel->speedS);
132 panel->acceleration = 0.25 + (i * 0.25);
134 sprintf(buffer, "%.2f", 0.25 + (i * 0.25));
135 WMSetTextFieldText(panel->acceT, buffer);
138 tmp = WMGetTextFieldText(panel->threT);
139 if (sscanf(tmp, "%i", &threshold) != 1 || threshold < 0 || threshold > panel->maxThreshold) {
140 WMRunAlertPanel(WMWidgetScreen(panel->parent), GetWindow(panel), _("Error"),
142 ("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."),
143 _("OK"), NULL, NULL);
144 } else {
145 setMouseAccel(WMWidgetScreen(panel->parent), panel->acceleration, threshold);
147 wfree(tmp);
150 static void returnPressed(void *observerData, WMNotification * notification)
152 _Panel *panel = (_Panel *) observerData;
154 speedChange(NULL, panel);
157 static void doubleClick(WMWidget * w, void *data)
159 _Panel *panel = (_Panel *) data;
160 int i;
161 extern _WINGsConfiguration WINGsConfiguration;
162 char buffer[32];
164 for (i = 0; i < 5; i++) {
165 if (panel->ddelaB[i] == w)
166 break;
168 WINGsConfiguration.doubleClickDelay = DELAY(i);
170 sprintf(buffer, "%i", DELAY(i));
171 WMSetTextFieldText(panel->ddelaT, buffer);
174 static int getButtonAction(const char *str)
176 if (!str)
177 return -2;
179 if (strcasecmp(str, "None") == 0)
180 return 0;
181 else if (strcasecmp(str, "OpenApplicationsMenu") == 0)
182 return 1;
183 else if (strcasecmp(str, "OpenWindowListMenu") == 0)
184 return 2;
185 else if (strcasecmp(str, "SelectWindows") == 0)
186 return 3;
187 else
188 return -1;
192 static int getWheelAction(const char *str)
194 if (!str)
195 return -2;
197 if (strcasecmp(str, "None") == 0)
198 return 0;
199 else if (strcasecmp(str, "SwitchWorkspaces") == 0)
200 return 1;
201 else
202 return -1;
206 static void getMouseParameters(Display * dpy, float *accel, int *thre)
208 int n, d;
210 XGetPointerControl(dpy, &n, &d, thre);
212 *accel = (float)n / (float)d;
215 static void showData(_Panel * panel)
217 char *str;
218 int i;
219 int a = -1, b = -1, c = -1, w = -1;
220 float accel;
221 char buffer[32];
222 Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent));
224 str = GetStringForKey("MouseLeftButtonAction");
225 i = getButtonAction(str);
226 if (i < 0) {
227 a = 3;
228 if (i == -1) {
229 wwarning(_("bad value %s for option %s"), str, "MouseLeftButtonAction");
231 } else {
232 a = i;
234 WMSetPopUpButtonSelectedItem(panel->button1P, a);
236 str = GetStringForKey("MouseMiddleButtonAction");
237 i = getButtonAction(str);
238 if (i < 0) {
239 b = 2;
240 if (i == -1) {
241 wwarning(_("bad value %s for option %s"), str, "MouseMiddleButtonAction");
243 } else {
244 b = i;
246 WMSetPopUpButtonSelectedItem(panel->button2P, b);
248 str = GetStringForKey("MouseRightButtonAction");
249 i = getButtonAction(str);
250 if (i < 0) {
251 c = 1;
252 if (i == -1) {
253 wwarning(_("bad value %s for option %s"), str, "MouseRightButtonAction");
255 } else {
256 c = i;
258 WMSetPopUpButtonSelectedItem(panel->button3P, c);
260 str = GetStringForKey("MouseWheelAction");
261 i = getWheelAction(str);
262 if (i < 0) {
263 w = 0;
264 if (i == -1) {
265 wwarning(_("bad value %s for option %s"), str, "MouseWheelAction");
267 } else {
268 w = i;
270 WMSetPopUpButtonSelectedItem(panel->wheelP, w);
272 WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions"));
274 /**/ getMouseParameters(dpy, &accel, &a);
275 panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy));
276 if (a > panel->maxThreshold) {
277 panel->maxThreshold = a;
279 sprintf(buffer, "%i", a);
280 WMSetTextFieldText(panel->threT, buffer);
282 WMSetSliderValue(panel->speedS, (accel - 0.25) / 0.25);
284 panel->acceleration = accel;
285 sprintf(buffer, "%.2f", accel);
286 WMSetTextFieldText(panel->acceT, buffer);
288 /**/ b = GetIntegerForKey("DoubleClickTime");
289 /* find best match */
290 a = -1;
291 for (i = 0; i < 5; i++) {
292 if (DELAY(i) == b)
293 a = i;
295 if (a >= 0)
296 WMPerformButtonClick(panel->ddelaB[a]);
297 sprintf(buffer, "%i", b);
298 WMSetTextFieldText(panel->ddelaT, buffer);
300 /**/ str = GetStringForKey("ModifierKey");
301 if (!str)
302 str = "mod1";
303 a = ModifierFromKey(dpy, str);
305 if (a != -1) {
306 str = modifierNames[a];
308 a = 0;
309 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->grabP); i++) {
310 if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) {
311 WMSetPopUpButtonSelectedItem(panel->grabP, i);
312 a = 1;
313 break;
318 if (a < 1) {
319 sscanf(WMGetPopUpButtonItem(panel->grabP, 0), "%s", buffer);
320 WMSetPopUpButtonSelectedItem(panel->grabP, 0);
321 wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"),
322 str, buffer);
326 static void fillModifierPopUp(WMPopUpButton * pop)
328 XModifierKeymap *mapping;
329 Display *dpy = WMScreenDisplay(WMWidgetScreen(pop));
330 int i, j;
331 char *str;
332 char buffer[64];
334 mapping = XGetModifierMapping(dpy);
336 if (!mapping || mapping->max_keypermod == 0) {
337 WMAddPopUpButtonItem(pop, "Mod1");
338 WMAddPopUpButtonItem(pop, "Mod2");
339 WMAddPopUpButtonItem(pop, "Mod3");
340 WMAddPopUpButtonItem(pop, "Mod4");
341 WMAddPopUpButtonItem(pop, "Mod5");
342 wwarning(_("could not retrieve keyboard modifier mapping"));
343 return;
346 for (j = 0; j < 8; j++) {
347 int idx;
348 char *array[8];
349 int a;
350 KeySym ksym;
351 int k;
352 char *ptr;
353 char *tmp;
355 a = 0;
356 memset(array, 0, sizeof(char *) * 8);
357 for (i = 0; i < mapping->max_keypermod; i++) {
358 idx = i + j * mapping->max_keypermod;
359 if (mapping->modifiermap[idx] != 0) {
360 int l;
361 for (l = 0; l < 4; l++) {
362 ksym = XkbKeycodeToKeysym(dpy, mapping->modifiermap[idx], 0, l);
363 if (ksym != NoSymbol)
364 break;
366 if (ksym != NoSymbol)
367 str = XKeysymToString(ksym);
368 else
369 str = NULL;
370 if (str && !strstr(str, "_Lock") && !strstr(str, "Shift")
371 && !strstr(str, "Control")) {
372 array[a++] = wstrdup(str);
377 for (k = 0; k < a; k++) {
378 if (array[k] == NULL)
379 continue;
380 tmp = wstrdup(array[k]);
381 ptr = strstr(tmp, "_L");
382 if (ptr)
383 *ptr = 0;
384 ptr = strstr(tmp, "_R");
385 if (ptr)
386 *ptr = 0;
387 sprintf(buffer, "%s (%s)", modifierNames[j], tmp);
388 /*sprintf(buffer, "%s", tmp); */
389 WMAddPopUpButtonItem(pop, buffer);
390 for (i = k + 1; i < a; i++) {
391 if (array[i] == NULL)
392 continue;
393 if (strstr(array[i], tmp)) {
394 wfree(array[i]);
395 array[i] = NULL;
396 break;
399 wfree(tmp);
402 while (--a > 0) {
403 if (array[a])
404 wfree(array[a]);
408 if (mapping)
409 XFreeModifiermap(mapping);
412 static void createPanel(Panel * p)
414 _Panel *panel = (_Panel *) p;
415 WMScreen *scr = WMWidgetScreen(panel->parent);
416 WMPixmap *icon;
417 char *buf1, *buf2;
418 int i;
419 RColor color;
420 char *path;
422 color.red = 0xae;
423 color.green = 0xaa;
424 color.blue = 0xae;
426 panel->box = WMCreateBox(panel->parent);
427 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
429 /**************** Mouse Speed ****************/
430 panel->speedF = WMCreateFrame(panel->box);
431 WMResizeWidget(panel->speedF, 245, 100);
432 WMMoveWidget(panel->speedF, 15, 5);
433 WMSetFrameTitle(panel->speedF, _("Mouse Speed"));
435 panel->speedL = WMCreateLabel(panel->speedF);
436 WMResizeWidget(panel->speedL, 40, 46);
437 WMMoveWidget(panel->speedL, 15, 14);
438 WMSetLabelImagePosition(panel->speedL, WIPImageOnly);
439 path = LocateImage(SPEED_ICON_FILE);
440 if (path) {
441 icon = WMCreateBlendedPixmapFromFile(scr, path, &color);
442 if (icon) {
443 WMSetLabelImage(panel->speedL, icon);
444 WMReleasePixmap(icon);
445 } else {
446 wwarning(_("could not load icon %s"), path);
448 wfree(path);
451 panel->speedS = WMCreateSlider(panel->speedF);
452 WMResizeWidget(panel->speedS, 160, 15);
453 WMMoveWidget(panel->speedS, 70, 35);
454 WMSetSliderMinValue(panel->speedS, 0);
455 WMSetSliderMaxValue(panel->speedS, 40);
456 WMSetSliderContinuous(panel->speedS, False);
457 WMSetSliderAction(panel->speedS, speedChange, panel);
459 panel->acceL = WMCreateLabel(panel->speedF);
460 WMResizeWidget(panel->acceL, 70, 16);
461 WMMoveWidget(panel->acceL, 10, 67);
462 WMSetLabelTextAlignment(panel->acceL, WARight);
463 WMSetLabelText(panel->acceL, _("Acceler.:"));
465 panel->acceT = WMCreateTextField(panel->speedF);
466 WMResizeWidget(panel->acceT, 40, 20);
467 WMMoveWidget(panel->acceT, 80, 65);
468 WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->acceT);
470 panel->threL = WMCreateLabel(panel->speedF);
471 WMResizeWidget(panel->threL, 80, 16);
472 WMMoveWidget(panel->threL, 120, 67);
473 WMSetLabelTextAlignment(panel->threL, WARight);
474 WMSetLabelText(panel->threL, _("Threshold:"));
476 panel->threT = WMCreateTextField(panel->speedF);
477 WMResizeWidget(panel->threT, 30, 20);
478 WMMoveWidget(panel->threT, 200, 65);
479 WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->threT);
481 WMMapSubwidgets(panel->speedF);
483 /***************** Doubleclick Delay ****************/
485 panel->ddelaF = WMCreateFrame(panel->box);
486 WMResizeWidget(panel->ddelaF, 245, 105);
487 WMMoveWidget(panel->ddelaF, 15, 115);
488 WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay"));
490 buf1 = wmalloc(strlen(DELAY_ICON) + 2);
491 buf2 = wmalloc(strlen(DELAY_ICON_S) + 2);
493 for (i = 0; i < 5; i++) {
494 panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask);
495 WMResizeWidget(panel->ddelaB[i], 25, 25);
496 WMMoveWidget(panel->ddelaB[i], 30 + (40 * i), 25);
497 WMSetButtonBordered(panel->ddelaB[i], False);
498 WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly);
499 WMSetButtonAction(panel->ddelaB[i], doubleClick, panel);
500 if (i > 0) {
501 WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]);
503 sprintf(buf1, DELAY_ICON, i + 1);
504 sprintf(buf2, DELAY_ICON_S, i + 1);
505 path = LocateImage(buf1);
506 if (path) {
507 icon = WMCreatePixmapFromFile(scr, path);
508 if (icon) {
509 WMSetButtonImage(panel->ddelaB[i], icon);
510 WMReleasePixmap(icon);
511 } else {
512 wwarning(_("could not load icon file %s"), path);
514 wfree(path);
516 path = LocateImage(buf2);
517 if (path) {
518 icon = WMCreatePixmapFromFile(scr, path);
519 if (icon) {
520 WMSetButtonAltImage(panel->ddelaB[i], icon);
521 WMReleasePixmap(icon);
522 } else {
523 wwarning(_("could not load icon file %s"), path);
525 wfree(path);
528 wfree(buf1);
529 wfree(buf2);
531 panel->tester = CreateDoubleTest(panel->ddelaF, _("Test"));
532 WMResizeWidget(panel->tester, 84, 29);
533 WMMoveWidget(panel->tester, 35, 60);
535 panel->ddelaT = WMCreateTextField(panel->ddelaF);
536 WMResizeWidget(panel->ddelaT, 40, 20);
537 WMMoveWidget(panel->ddelaT, 140, 65);
539 panel->ddelaL = WMCreateLabel(panel->ddelaF);
540 WMResizeWidget(panel->ddelaL, 40, 16);
541 WMMoveWidget(panel->ddelaL, 185, 70);
543 WMFont *font;
544 WMColor *color;
546 font = WMSystemFontOfSize(scr, 10);
547 color = WMDarkGrayColor(scr);
548 WMSetLabelTextColor(panel->ddelaL, color);
549 WMSetLabelFont(panel->ddelaL, font);
550 WMReleaseFont(font);
551 WMReleaseColor(color);
553 WMSetLabelText(panel->ddelaL, _("msec"));
555 WMMapSubwidgets(panel->ddelaF);
557 /* ************** Workspace Action Buttons **************** */
558 panel->menuF = WMCreateFrame(panel->box);
559 WMResizeWidget(panel->menuF, 240, 160);
560 WMMoveWidget(panel->menuF, 270, 5);
561 WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions"));
563 panel->disaB = WMCreateSwitchButton(panel->menuF);
564 WMResizeWidget(panel->disaB, 205, 18);
565 WMMoveWidget(panel->disaB, 10, 18);
566 WMSetButtonText(panel->disaB, _("Disable mouse actions"));
568 panel->button1L = WMCreateLabel(panel->menuF);
569 WMResizeWidget(panel->button1L, 87, 20);
570 WMMoveWidget(panel->button1L, 5, 45);
571 WMSetLabelTextAlignment(panel->button1L, WARight);
572 WMSetLabelText(panel->button1L, _("Left Button"));
574 panel->button1P = WMCreatePopUpButton(panel->menuF);
575 WMResizeWidget(panel->button1P, 135, 20);
576 WMMoveWidget(panel->button1P, 95, 45);
578 panel->button2L = WMCreateLabel(panel->menuF);
579 WMResizeWidget(panel->button2L, 87, 20);
580 WMMoveWidget(panel->button2L, 5, 73);
581 WMSetLabelTextAlignment(panel->button2L, WARight);
582 WMSetLabelText(panel->button2L, _("Middle Button"));
584 panel->button2P = WMCreatePopUpButton(panel->menuF);
585 WMResizeWidget(panel->button2P, 135, 20);
586 WMMoveWidget(panel->button2P, 95, 73);
588 panel->button3L = WMCreateLabel(panel->menuF);
589 WMResizeWidget(panel->button3L, 87, 20);
590 WMMoveWidget(panel->button3L, 5, 101);
591 WMSetLabelTextAlignment(panel->button3L, WARight);
592 WMSetLabelText(panel->button3L, _("Right Button"));
594 panel->button3P = WMCreatePopUpButton(panel->menuF);
595 WMResizeWidget(panel->button3P, 135, 20);
596 WMMoveWidget(panel->button3P, 95, 101);
598 panel->wheelL = WMCreateLabel(panel->menuF);
599 WMResizeWidget(panel->wheelL, 87, 20);
600 WMMoveWidget(panel->wheelL, 5, 129);
601 WMSetLabelTextAlignment(panel->wheelL, WARight);
602 WMSetLabelText(panel->wheelL, _("Mouse Wheel"));
604 panel->wheelP = WMCreatePopUpButton(panel->menuF);
605 WMResizeWidget(panel->wheelP, 135, 20);
606 WMMoveWidget(panel->wheelP, 95, 129);
608 for (i = 0; i < sizeof(buttonActions) / sizeof(buttonActions[0]); i++) {
609 WMAddPopUpButtonItem(panel->button1P, buttonActions[i]);
610 WMAddPopUpButtonItem(panel->button2P, buttonActions[i]);
611 WMAddPopUpButtonItem(panel->button3P, buttonActions[i]);
614 for (i = 0; i < sizeof(wheelActions) / sizeof(wheelActions[0]); i++) {
615 WMAddPopUpButtonItem(panel->wheelP, wheelActions[i]);
618 WMMapSubwidgets(panel->menuF);
620 /* ************** Grab Modifier **************** */
621 panel->grabF = WMCreateFrame(panel->box);
622 WMResizeWidget(panel->grabF, 240, 50);
623 WMMoveWidget(panel->grabF, 270, 170);
624 WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier"));
626 WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
627 "involve dragging windows with the mouse,\n"
628 "clicking inside the window."), WMWidgetView(panel->grabF));
630 panel->grabP = WMCreatePopUpButton(panel->grabF);
631 WMResizeWidget(panel->grabP, 160, 20);
632 WMMoveWidget(panel->grabP, 40, 20);
634 fillModifierPopUp(panel->grabP);
636 WMMapSubwidgets(panel->grabF);
638 WMRealizeWidget(panel->box);
639 WMMapSubwidgets(panel->box);
641 showData(panel);
644 static void storeCommandInScript(const char *cmd, const char *line)
646 char *path;
647 FILE *f;
648 char buffer[128];
650 path = wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart");
652 f = fopen(path, "rb");
653 if (!f) {
654 f = fopen(path, "wb");
655 if (!f) {
656 werror(_("could not create %s"), path);
657 goto end;
659 fprintf(f, "#!/bin/sh\n");
660 fputs(line, f);
661 fputs("\n", f);
662 } else {
663 int len = strlen(cmd);
664 int ok = 0;
665 char *tmppath;
666 FILE *fo;
668 tmppath = wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart.tmp");
669 fo = fopen(tmppath, "wb");
670 if (!fo) {
671 werror(_("could not create temporary file %s"), tmppath);
672 wfree(tmppath);
673 goto end;
676 while (!feof(f)) {
677 if (!fgets(buffer, 127, f)) {
678 break;
680 if (buffer[0] == '\n') {
681 /* don't write empty lines, else the file will grow
682 * indefinitely (one '\n' added at end of file on each save).
684 continue;
686 if (strncmp(buffer, cmd, len) == 0) {
687 if (!ok) {
688 fputs(line, fo);
689 fputs("\n", fo);
690 ok = 1;
692 } else {
693 fputs(buffer, fo);
696 if (!ok) {
697 fputs(line, fo);
698 fputs("\n", fo);
700 fsync(fileno(fo));
701 fclose(fo);
703 if (rename(tmppath, path) != 0) {
704 werror(_("could not rename file %s to %s"), tmppath, path);
706 wfree(tmppath);
708 sprintf(buffer, "chmod u+x %s", path);
709 system(buffer);
711 end:
712 wfree(path);
713 if (f) {
714 fsync(fileno(f)); /* this may be rw */
715 fclose(f);
719 static void storeData(_Panel * panel)
721 char buffer[64];
722 int i;
723 char *tmp, *p;
724 static char *button[4] = { "None", "OpenApplicationsMenu", "OpenWindowListMenu", "SelectWindows" };
725 static char *wheel[2] = { "None", "SwitchWorkspaces" };
726 WMUserDefaults *udb = WMGetStandardUserDefaults();
728 if (!WMGetUDBoolForKey(udb, "NoXSetStuff")) {
729 tmp = WMGetTextFieldText(panel->threT);
730 if (strlen(tmp) == 0) {
731 wfree(tmp);
732 tmp = wstrdup("4");
735 sprintf(buffer, XSET " m %i/%i %s\n", (int)(panel->acceleration * 10), 10, tmp);
736 storeCommandInScript(XSET " m", buffer);
738 wfree(tmp);
741 tmp = WMGetTextFieldText(panel->ddelaT);
742 if (sscanf(tmp, "%i", &i) == 1 && i > 0)
743 SetIntegerForKey(i, "DoubleClickTime");
745 SetBoolForKey(WMGetButtonSelected(panel->disaB), "DisableWSMouseActions");
747 i = WMGetPopUpButtonSelectedItem(panel->button1P);
748 SetStringForKey(button[i], "MouseLeftButtonAction");
750 i = WMGetPopUpButtonSelectedItem(panel->button2P);
751 SetStringForKey(button[i], "MouseMiddleButtonAction");
753 i = WMGetPopUpButtonSelectedItem(panel->button3P);
754 SetStringForKey(button[i], "MouseRightButtonAction");
756 i = WMGetPopUpButtonSelectedItem(panel->wheelP);
757 SetStringForKey(wheel[i], "MouseWheelAction");
759 tmp = WMGetPopUpButtonItem(panel->grabP, WMGetPopUpButtonSelectedItem(panel->grabP));
760 tmp = wstrdup(tmp);
761 p = strchr(tmp, ' ');
762 *p = 0;
764 SetStringForKey(tmp, "ModifierKey");
766 wfree(tmp);
769 Panel *InitMouseSettings(WMScreen * scr, WMWidget * parent)
771 _Panel *panel;
773 modifierNames[0] = wstrdup(_("Shift"));
774 modifierNames[1] = wstrdup(_("Lock"));
775 modifierNames[2] = wstrdup(_("Control"));
776 modifierNames[3] = wstrdup(_("Mod1"));
777 modifierNames[4] = wstrdup(_("Mod2"));
778 modifierNames[5] = wstrdup(_("Mod3"));
779 modifierNames[6] = wstrdup(_("Mod4"));
780 modifierNames[7] = wstrdup(_("Mod5"));
782 buttonActions[0] = wstrdup(_("None"));
783 buttonActions[1] = wstrdup(_("Applications Menu"));
784 buttonActions[2] = wstrdup(_("Window List Menu"));
785 buttonActions[3] = wstrdup(_("Select Windows"));
787 wheelActions[0] = wstrdup(_("None"));
788 wheelActions[1] = wstrdup(_("Switch Workspaces"));
790 panel = wmalloc(sizeof(_Panel));
792 panel->sectionName = _("Mouse Preferences");
794 panel->description = _("Mouse speed/acceleration, double click delay,\n" "mouse button bindings etc.");
796 panel->parent = parent;
798 panel->callbacks.createWidgets = createPanel;
799 panel->callbacks.updateDomain = storeData;
801 AddSection(panel, ICON_FILE);
803 return panel;