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.
25 #include <X11/Xutil.h>
26 #include <X11/XKBlib.h>
34 typedef struct _Panel
{
41 CallbackRec callbacks
;
67 WMPopUpButton
*button1P
;
68 WMPopUpButton
*button2P
;
69 WMPopUpButton
*button3P
;
70 WMPopUpButton
*button8P
;
71 WMPopUpButton
*button9P
;
72 WMPopUpButton
*wheelP
;
73 WMPopUpButton
*wheelTiltP
;
80 /**/ int maxThreshold
;
84 #define ICON_FILE "mousesettings"
86 #define SPEED_ICON_FILE "mousespeed"
88 #define DELAY_ICON "timer%i"
89 #define DELAY_ICON_S "timer%is"
91 /* need access to the double click variables */
92 #include <WINGs/WINGsP.h>
94 static char *modifierNames
[8];
96 static char *buttonActions
[4];
98 static char *wheelActions
[2];
100 #define DELAY(i) ((i)*75+170)
103 static void setMouseAccel(WMScreen
* scr
, float accel
, int threshold
)
110 XChangePointerControl(WMScreenDisplay(scr
), True
, True
, n
, d
, threshold
);
113 static void speedChange(WMWidget
* w
, void *data
)
115 _Panel
*panel
= (_Panel
*) data
;
124 tmp
= WMGetTextFieldText(panel
->acceT
);
125 if (sscanf(tmp
, "%f", &accel
) != 1 || accel
< 0) {
126 WMRunAlertPanel(WMWidgetScreen(panel
->acceT
), GetWindow(),
128 _("Invalid mouse acceleration value. Must be a positive real value."),
129 _("OK"), NULL
, NULL
);
133 panel
->acceleration
= accel
;
136 i
= (int)WMGetSliderValue(panel
->speedS
);
138 panel
->acceleration
= 0.25 + (i
* 0.25);
140 sprintf(buffer
, "%.2f", 0.25 + (i
* 0.25));
141 WMSetTextFieldText(panel
->acceT
, buffer
);
144 tmp
= WMGetTextFieldText(panel
->threT
);
145 if (sscanf(tmp
, "%i", &threshold
) != 1 || threshold
< 0 || threshold
> panel
->maxThreshold
) {
146 WMRunAlertPanel(WMWidgetScreen(panel
->parent
), GetWindow(), _("Error"),
148 ("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."),
149 _("OK"), NULL
, NULL
);
151 setMouseAccel(WMWidgetScreen(panel
->parent
), panel
->acceleration
, threshold
);
156 static void returnPressed(void *observerData
, WMNotification
* notification
)
158 _Panel
*panel
= (_Panel
*) observerData
;
160 /* Parameter not used, but tell the compiler that it is ok */
163 speedChange(NULL
, panel
);
166 static void doubleClick(WMWidget
* w
, void *data
)
168 _Panel
*panel
= (_Panel
*) data
;
172 for (i
= 0; i
< 5; i
++) {
173 if (panel
->ddelaB
[i
] == w
)
176 WINGsConfiguration
.doubleClickDelay
= DELAY(i
);
178 sprintf(buffer
, "%i", DELAY(i
));
179 WMSetTextFieldText(panel
->ddelaT
, buffer
);
182 static int getButtonAction(const char *str
)
187 if (strcasecmp(str
, "None") == 0)
189 else if (strcasecmp(str
, "OpenApplicationsMenu") == 0)
191 else if (strcasecmp(str
, "OpenWindowListMenu") == 0)
193 else if (strcasecmp(str
, "SelectWindows") == 0)
200 static int getWheelAction(const char *str
)
205 if (strcasecmp(str
, "None") == 0)
207 else if (strcasecmp(str
, "SwitchWorkspaces") == 0)
214 static void getMouseParameters(Display
* dpy
, float *accel
, int *thre
)
218 XGetPointerControl(dpy
, &n
, &d
, thre
);
220 *accel
= (float)n
/ (float)d
;
223 static void showData(_Panel
* panel
)
227 int a
= -1, b
= -1, c
= -1, w
= -1;
230 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->parent
));
232 str
= GetStringForKey("MouseLeftButtonAction");
233 i
= getButtonAction(str
);
237 wwarning(_("bad value %s for option %s"), str
, "MouseLeftButtonAction");
242 WMSetPopUpButtonSelectedItem(panel
->button1P
, a
);
244 str
= GetStringForKey("MouseMiddleButtonAction");
245 i
= getButtonAction(str
);
249 wwarning(_("bad value %s for option %s"), str
, "MouseMiddleButtonAction");
254 WMSetPopUpButtonSelectedItem(panel
->button2P
, b
);
256 str
= GetStringForKey("MouseRightButtonAction");
257 i
= getButtonAction(str
);
261 wwarning(_("bad value %s for option %s"), str
, "MouseRightButtonAction");
266 WMSetPopUpButtonSelectedItem(panel
->button3P
, c
);
268 str
= GetStringForKey("MouseBackwardButtonAction");
269 i
= getButtonAction(str
);
273 wwarning(_("bad value %s for option %s"), str
, "MouseBackwardButtonAction");
278 WMSetPopUpButtonSelectedItem(panel
->button8P
, b
);
280 str
= GetStringForKey("MouseForwardButtonAction");
281 i
= getButtonAction(str
);
285 wwarning(_("bad value %s for option %s"), str
, "MouseForwardButtonAction");
290 WMSetPopUpButtonSelectedItem(panel
->button9P
, b
);
292 str
= GetStringForKey("MouseWheelAction");
293 i
= getWheelAction(str
);
297 wwarning(_("bad value %s for option %s"), str
, "MouseWheelAction");
302 WMSetPopUpButtonSelectedItem(panel
->wheelP
, w
);
304 str
= GetStringForKey("MouseWheelTiltAction");
305 i
= getWheelAction(str
);
309 wwarning(_("bad value %s for option %s"), str
, "MouseWheelTiltAction");
314 WMSetPopUpButtonSelectedItem(panel
->wheelTiltP
, w
);
316 WMSetButtonSelected(panel
->disaB
, GetBoolForKey("DisableWSMouseActions"));
318 /**/ getMouseParameters(dpy
, &accel
, &a
);
319 panel
->maxThreshold
= WidthOfScreen(DefaultScreenOfDisplay(dpy
));
320 if (a
> panel
->maxThreshold
) {
321 panel
->maxThreshold
= a
;
323 sprintf(buffer
, "%i", a
);
324 WMSetTextFieldText(panel
->threT
, buffer
);
326 WMSetSliderValue(panel
->speedS
, (accel
- 0.25) / 0.25);
328 panel
->acceleration
= accel
;
329 sprintf(buffer
, "%.2f", accel
);
330 WMSetTextFieldText(panel
->acceT
, buffer
);
332 /**/ b
= GetIntegerForKey("DoubleClickTime");
333 /* find best match */
335 for (i
= 0; i
< 5; i
++) {
340 WMPerformButtonClick(panel
->ddelaB
[a
]);
341 sprintf(buffer
, "%i", b
);
342 WMSetTextFieldText(panel
->ddelaT
, buffer
);
344 /**/ str
= GetStringForKey("ModifierKey");
347 a
= ModifierFromKey(dpy
, str
);
350 str
= modifierNames
[a
];
353 for (i
= 0; i
< WMGetPopUpButtonNumberOfItems(panel
->grabP
); i
++) {
354 if (strstr(WMGetPopUpButtonItem(panel
->grabP
, i
), str
)) {
355 WMSetPopUpButtonSelectedItem(panel
->grabP
, i
);
365 previous
= WMGetPopUpButtonItem(panel
->grabP
, 0);
366 if (previous
!= NULL
)
367 WMSetPopUpButtonSelectedItem(panel
->grabP
, 0);
368 wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"),
369 str
, previous
?previous
:"(empty)");
373 static void fillModifierPopUp(WMPopUpButton
* pop
)
375 XModifierKeymap
*mapping
;
376 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(pop
));
381 mapping
= XGetModifierMapping(dpy
);
383 if (!mapping
|| mapping
->max_keypermod
== 0) {
384 WMAddPopUpButtonItem(pop
, "Mod1");
385 WMAddPopUpButtonItem(pop
, "Mod2");
386 WMAddPopUpButtonItem(pop
, "Mod3");
387 WMAddPopUpButtonItem(pop
, "Mod4");
388 WMAddPopUpButtonItem(pop
, "Mod5");
389 wwarning(_("could not retrieve keyboard modifier mapping"));
393 for (j
= 0; j
< 8; j
++) {
403 memset(array
, 0, sizeof(char *) * 8);
404 for (i
= 0; i
< mapping
->max_keypermod
; i
++) {
405 idx
= i
+ j
* mapping
->max_keypermod
;
406 if (mapping
->modifiermap
[idx
] != 0) {
408 for (l
= 0; l
< 4; l
++) {
409 if (xext_xkb_supported
)
410 ksym
= XkbKeycodeToKeysym(dpy
, mapping
->modifiermap
[idx
], 0, l
);
412 ksym
= XKeycodeToKeysym(dpy
, mapping
->modifiermap
[idx
], 0);
413 if (ksym
!= NoSymbol
)
416 if (ksym
!= NoSymbol
)
417 str
= XKeysymToString(ksym
);
420 if (str
&& !strstr(str
, "_Lock") && !strstr(str
, "Shift")
421 && !strstr(str
, "Control")) {
422 array
[a
++] = wstrdup(str
);
427 for (k
= 0; k
< a
; k
++) {
428 if (array
[k
] == NULL
)
430 tmp
= wstrdup(array
[k
]);
431 ptr
= strstr(tmp
, "_L");
434 ptr
= strstr(tmp
, "_R");
437 sprintf(buffer
, "%s (%s)", modifierNames
[j
], tmp
);
438 /*sprintf(buffer, "%s", tmp); */
439 WMAddPopUpButtonItem(pop
, buffer
);
440 for (i
= k
+ 1; i
< a
; i
++) {
441 if (array
[i
] == NULL
)
443 if (strstr(array
[i
], tmp
)) {
459 XFreeModifiermap(mapping
);
462 static void createPanel(Panel
* p
)
464 _Panel
*panel
= (_Panel
*) p
;
465 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
476 panel
->box
= WMCreateBox(panel
->parent
);
477 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
479 /**************** Mouse Speed ****************/
480 panel
->speedF
= WMCreateFrame(panel
->box
);
481 WMResizeWidget(panel
->speedF
, 225, 90);
482 WMMoveWidget(panel
->speedF
, 15, 5);
483 WMSetFrameTitle(panel
->speedF
, _("Mouse Speed"));
485 panel
->speedL
= WMCreateLabel(panel
->speedF
);
486 WMResizeWidget(panel
->speedL
, 40, 46);
487 WMMoveWidget(panel
->speedL
, 10, 14);
488 WMSetLabelImagePosition(panel
->speedL
, WIPImageOnly
);
489 path
= LocateImage(SPEED_ICON_FILE
);
491 icon
= WMCreateBlendedPixmapFromFile(scr
, path
, &color
);
493 WMSetLabelImage(panel
->speedL
, icon
);
494 WMReleasePixmap(icon
);
496 wwarning(_("could not load icon %s"), path
);
501 panel
->speedS
= WMCreateSlider(panel
->speedF
);
502 WMResizeWidget(panel
->speedS
, 150, 15);
503 WMMoveWidget(panel
->speedS
, 60, 35);
504 WMSetSliderMinValue(panel
->speedS
, 0);
505 WMSetSliderMaxValue(panel
->speedS
, 40);
506 WMSetSliderContinuous(panel
->speedS
, False
);
507 WMSetSliderAction(panel
->speedS
, speedChange
, panel
);
509 panel
->acceL
= WMCreateLabel(panel
->speedF
);
510 WMResizeWidget(panel
->acceL
, 50, 16);
511 WMMoveWidget(panel
->acceL
, 10, 65);
512 WMSetLabelTextAlignment(panel
->acceL
, WARight
);
513 WMSetLabelText(panel
->acceL
, _("Accel.:"));
515 panel
->acceT
= WMCreateTextField(panel
->speedF
);
516 WMResizeWidget(panel
->acceT
, 40, 20);
517 WMMoveWidget(panel
->acceT
, 60, 63);
518 WMAddNotificationObserver(returnPressed
, panel
, WMTextDidEndEditingNotification
, panel
->acceT
);
520 panel
->threL
= WMCreateLabel(panel
->speedF
);
521 WMResizeWidget(panel
->threL
, 80, 16);
522 WMMoveWidget(panel
->threL
, 100, 65);
523 WMSetLabelTextAlignment(panel
->threL
, WARight
);
524 WMSetLabelText(panel
->threL
, _("Threshold:"));
526 panel
->threT
= WMCreateTextField(panel
->speedF
);
527 WMResizeWidget(panel
->threT
, 30, 20);
528 WMMoveWidget(panel
->threT
, 180, 63);
529 WMAddNotificationObserver(returnPressed
, panel
, WMTextDidEndEditingNotification
, panel
->threT
);
531 WMMapSubwidgets(panel
->speedF
);
533 /* ************** Grab Modifier **************** */
534 panel
->grabF
= WMCreateFrame(panel
->box
);
535 WMResizeWidget(panel
->grabF
, 225, 45);
536 WMMoveWidget(panel
->grabF
, 15, 95);
537 WMSetFrameTitle(panel
->grabF
, _("Mouse Grab Modifier"));
539 WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n"
540 "involve dragging windows with the mouse,\n"
541 "clicking inside the window."), WMWidgetView(panel
->grabF
));
543 panel
->grabP
= WMCreatePopUpButton(panel
->grabF
);
544 WMResizeWidget(panel
->grabP
, 160, 20);
545 WMMoveWidget(panel
->grabP
, 50, 18);
547 fillModifierPopUp(panel
->grabP
);
548 WMMapSubwidgets(panel
->grabF
);
550 /***************** Doubleclick Delay ****************/
552 panel
->ddelaF
= WMCreateFrame(panel
->box
);
553 WMResizeWidget(panel
->ddelaF
, 225, 87);
554 WMMoveWidget(panel
->ddelaF
, 15, 140);
555 WMSetFrameTitle(panel
->ddelaF
, _("Double-Click Delay"));
557 buf1
= wmalloc(strlen(DELAY_ICON
) + 2);
558 buf2
= wmalloc(strlen(DELAY_ICON_S
) + 2);
560 for (i
= 0; i
< 5; i
++) {
561 panel
->ddelaB
[i
] = WMCreateCustomButton(panel
->ddelaF
, WBBStateChangeMask
);
562 WMResizeWidget(panel
->ddelaB
[i
], 25, 25);
563 WMMoveWidget(panel
->ddelaB
[i
], 20 + (40 * i
), 20);
564 WMSetButtonBordered(panel
->ddelaB
[i
], False
);
565 WMSetButtonImagePosition(panel
->ddelaB
[i
], WIPImageOnly
);
566 WMSetButtonAction(panel
->ddelaB
[i
], doubleClick
, panel
);
568 WMGroupButtons(panel
->ddelaB
[0], panel
->ddelaB
[i
]);
570 sprintf(buf1
, DELAY_ICON
, i
+ 1);
571 sprintf(buf2
, DELAY_ICON_S
, i
+ 1);
572 path
= LocateImage(buf1
);
574 icon
= WMCreatePixmapFromFile(scr
, path
);
576 WMSetButtonImage(panel
->ddelaB
[i
], icon
);
577 WMReleasePixmap(icon
);
579 wwarning(_("could not load icon file %s"), path
);
583 path
= LocateImage(buf2
);
585 icon
= WMCreatePixmapFromFile(scr
, path
);
587 WMSetButtonAltImage(panel
->ddelaB
[i
], icon
);
588 WMReleasePixmap(icon
);
590 wwarning(_("could not load icon file %s"), path
);
598 panel
->tester
= CreateDoubleTest(panel
->ddelaF
, _("Test"));
599 WMResizeWidget(panel
->tester
, 84, 29);
600 WMMoveWidget(panel
->tester
, 25, 52);
602 panel
->ddelaT
= WMCreateTextField(panel
->ddelaF
);
603 WMResizeWidget(panel
->ddelaT
, 40, 20);
604 WMMoveWidget(panel
->ddelaT
, 130, 57);
606 panel
->ddelaL
= WMCreateLabel(panel
->ddelaF
);
607 WMResizeWidget(panel
->ddelaL
, 40, 16);
608 WMMoveWidget(panel
->ddelaL
, 175, 63);
613 font
= WMSystemFontOfSize(scr
, 10);
614 color
= WMDarkGrayColor(scr
);
615 WMSetLabelTextColor(panel
->ddelaL
, color
);
616 WMSetLabelFont(panel
->ddelaL
, font
);
618 WMReleaseColor(color
);
620 WMSetLabelText(panel
->ddelaL
, _("msec"));
622 WMMapSubwidgets(panel
->ddelaF
);
624 /* ************** Workspace Action Buttons **************** */
626 panel
->menuF
= WMCreateFrame(panel
->box
);
627 WMResizeWidget(panel
->menuF
, 260, 222);
628 WMMoveWidget(panel
->menuF
, 250, 5);
629 WMSetFrameTitle(panel
->menuF
, _("Workspace Mouse Actions"));
631 panel
->disaB
= WMCreateSwitchButton(panel
->menuF
);
632 WMResizeWidget(panel
->disaB
, 205, 18);
633 WMMoveWidget(panel
->disaB
, 10, 15);
634 WMSetButtonText(panel
->disaB
, _("Disable mouse actions"));
636 panel
->button1L
= WMCreateLabel(panel
->menuF
);
637 WMResizeWidget(panel
->button1L
, 107, 20);
638 WMMoveWidget(panel
->button1L
, 5, 40);
639 WMSetLabelTextAlignment(panel
->button1L
, WARight
);
640 WMSetLabelText(panel
->button1L
, _("Left Button"));
642 panel
->button1P
= WMCreatePopUpButton(panel
->menuF
);
643 WMResizeWidget(panel
->button1P
, 135, 20);
644 WMMoveWidget(panel
->button1P
, 115, 40);
646 panel
->button2L
= WMCreateLabel(panel
->menuF
);
647 WMResizeWidget(panel
->button2L
, 107, 20);
648 WMMoveWidget(panel
->button2L
, 5, 65);
649 WMSetLabelTextAlignment(panel
->button2L
, WARight
);
650 WMSetLabelText(panel
->button2L
, _("Middle Button"));
652 panel
->button2P
= WMCreatePopUpButton(panel
->menuF
);
653 WMResizeWidget(panel
->button2P
, 135, 20);
654 WMMoveWidget(panel
->button2P
, 115, 65);
656 panel
->button3L
= WMCreateLabel(panel
->menuF
);
657 WMResizeWidget(panel
->button3L
, 107, 20);
658 WMMoveWidget(panel
->button3L
, 5, 90);
659 WMSetLabelTextAlignment(panel
->button3L
, WARight
);
660 WMSetLabelText(panel
->button3L
, _("Right Button"));
662 panel
->button3P
= WMCreatePopUpButton(panel
->menuF
);
663 WMResizeWidget(panel
->button3P
, 135, 20);
664 WMMoveWidget(panel
->button3P
, 115, 90);
666 panel
->button8L
= WMCreateLabel(panel
->menuF
);
667 WMResizeWidget(panel
->button8L
, 107, 20);
668 WMMoveWidget(panel
->button8L
, 5, 115);
669 WMSetLabelTextAlignment(panel
->button8L
, WARight
);
670 WMSetLabelText(panel
->button8L
, _("Back Button"));
672 panel
->button8P
= WMCreatePopUpButton(panel
->menuF
);
673 WMResizeWidget(panel
->button8P
, 135, 20);
674 WMMoveWidget(panel
->button8P
, 115, 115);
676 panel
->button9L
= WMCreateLabel(panel
->menuF
);
677 WMResizeWidget(panel
->button9L
, 107, 20);
678 WMMoveWidget(panel
->button9L
, 5, 140);
679 WMSetLabelTextAlignment(panel
->button9L
, WARight
);
680 WMSetLabelText(panel
->button9L
, _("Forward Button"));
682 panel
->button9P
= WMCreatePopUpButton(panel
->menuF
);
683 WMResizeWidget(panel
->button9P
, 135, 20);
684 WMMoveWidget(panel
->button9P
, 115, 140);
686 panel
->wheelL
= WMCreateLabel(panel
->menuF
);
687 WMResizeWidget(panel
->wheelL
, 107, 20);
688 WMMoveWidget(panel
->wheelL
, 5, 165);
689 WMSetLabelTextAlignment(panel
->wheelL
, WARight
);
690 WMSetLabelText(panel
->wheelL
, _("Mouse Wheel"));
692 panel
->wheelP
= WMCreatePopUpButton(panel
->menuF
);
693 WMResizeWidget(panel
->wheelP
, 135, 20);
694 WMMoveWidget(panel
->wheelP
, 115, 165);
696 panel
->wheelTiltL
= WMCreateLabel(panel
->menuF
);
697 WMResizeWidget(panel
->wheelTiltL
, 107, 20);
698 WMMoveWidget(panel
->wheelTiltL
, 5, 190);
699 WMSetLabelTextAlignment(panel
->wheelTiltL
, WARight
);
700 WMSetLabelText(panel
->wheelTiltL
, _("Mouse Wheel Tilt"));
702 panel
->wheelTiltP
= WMCreatePopUpButton(panel
->menuF
);
703 WMResizeWidget(panel
->wheelTiltP
, 135, 20);
704 WMMoveWidget(panel
->wheelTiltP
, 115, 190);
706 for (i
= 0; i
< wlengthof(buttonActions
); i
++) {
707 WMAddPopUpButtonItem(panel
->button1P
, buttonActions
[i
]);
708 WMAddPopUpButtonItem(panel
->button2P
, buttonActions
[i
]);
709 WMAddPopUpButtonItem(panel
->button3P
, buttonActions
[i
]);
710 WMAddPopUpButtonItem(panel
->button8P
, buttonActions
[i
]);
711 WMAddPopUpButtonItem(panel
->button9P
, buttonActions
[i
]);
714 for (i
= 0; i
< wlengthof(wheelActions
); i
++) {
715 WMAddPopUpButtonItem(panel
->wheelP
, wheelActions
[i
]);
716 WMAddPopUpButtonItem(panel
->wheelTiltP
, wheelActions
[i
]);
719 WMMapSubwidgets(panel
->menuF
);
721 WMRealizeWidget(panel
->box
);
722 WMMapSubwidgets(panel
->box
);
727 static void storeCommandInScript(const char *cmd
, const char *line
)
733 path
= wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart");
735 f
= fopen(path
, "rb");
737 f
= fopen(path
, "wb");
739 werror(_("could not create %s"), path
);
742 fprintf(f
, "#!/bin/sh\n");
746 int len
= strlen(cmd
);
751 tmppath
= wstrconcat(wusergnusteppath(), "/Library/WindowMaker/autostart.tmp");
752 fo
= fopen(tmppath
, "wb");
754 werror(_("could not create temporary file %s"), tmppath
);
760 if (!fgets(buffer
, 127, f
)) {
763 if (buffer
[0] == '\n') {
764 /* don't write empty lines, else the file will grow
765 * indefinitely (one '\n' added at end of file on each save).
769 if (strncmp(buffer
, cmd
, len
) == 0) {
786 if (rename(tmppath
, path
) != 0) {
787 werror(_("could not rename file %s to %s"), tmppath
, path
);
791 sprintf(buffer
, "chmod u+x %s", path
);
792 if (system(buffer
) == -1)
793 werror(_("could not execute command \"%s\""), buffer
);
798 fsync(fileno(f
)); /* this may be rw */
803 static void storeData(_Panel
* panel
)
808 static char *button
[4] = { "None", "OpenApplicationsMenu", "OpenWindowListMenu", "SelectWindows" };
809 static char *wheel
[2] = { "None", "SwitchWorkspaces" };
810 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
812 if (!WMGetUDBoolForKey(udb
, "NoXSetStuff")) {
813 tmp
= WMGetTextFieldText(panel
->threT
);
814 if (strlen(tmp
) == 0) {
819 sprintf(buffer
, XSET
" m %i/%i %s\n", (int)(panel
->acceleration
* 10), 10, tmp
);
820 storeCommandInScript(XSET
" m", buffer
);
825 tmp
= WMGetTextFieldText(panel
->ddelaT
);
826 if (sscanf(tmp
, "%i", &i
) == 1 && i
> 0)
827 SetIntegerForKey(i
, "DoubleClickTime");
830 SetBoolForKey(WMGetButtonSelected(panel
->disaB
), "DisableWSMouseActions");
832 i
= WMGetPopUpButtonSelectedItem(panel
->button1P
);
833 SetStringForKey(button
[i
], "MouseLeftButtonAction");
835 i
= WMGetPopUpButtonSelectedItem(panel
->button2P
);
836 SetStringForKey(button
[i
], "MouseMiddleButtonAction");
838 i
= WMGetPopUpButtonSelectedItem(panel
->button3P
);
839 SetStringForKey(button
[i
], "MouseRightButtonAction");
841 i
= WMGetPopUpButtonSelectedItem(panel
->button8P
);
842 SetStringForKey(button
[i
], "MouseBackwardButtonAction");
844 i
= WMGetPopUpButtonSelectedItem(panel
->button9P
);
845 SetStringForKey(button
[i
], "MouseForwardButtonAction");
847 i
= WMGetPopUpButtonSelectedItem(panel
->wheelP
);
848 SetStringForKey(wheel
[i
], "MouseWheelAction");
850 i
= WMGetPopUpButtonSelectedItem(panel
->wheelTiltP
);
851 SetStringForKey(wheel
[i
], "MouseWheelTiltAction");
853 tmp
= WMGetPopUpButtonItem(panel
->grabP
, WMGetPopUpButtonSelectedItem(panel
->grabP
));
855 p
= strchr(tmp
, ' ');
859 SetStringForKey(tmp
, "ModifierKey");
864 Panel
*InitMouseSettings(WMWidget
*parent
)
868 modifierNames
[0] = wstrdup(_("Shift"));
869 modifierNames
[1] = wstrdup(_("Lock"));
870 modifierNames
[2] = wstrdup(_("Control"));
871 modifierNames
[3] = wstrdup(_("Mod1"));
872 modifierNames
[4] = wstrdup(_("Mod2"));
873 modifierNames
[5] = wstrdup(_("Mod3"));
874 modifierNames
[6] = wstrdup(_("Mod4"));
875 modifierNames
[7] = wstrdup(_("Mod5"));
877 buttonActions
[0] = wstrdup(_("None"));
878 buttonActions
[1] = wstrdup(_("Applications Menu"));
879 buttonActions
[2] = wstrdup(_("Window List Menu"));
880 buttonActions
[3] = wstrdup(_("Select Windows"));
882 wheelActions
[0] = wstrdup(_("None"));
883 wheelActions
[1] = wstrdup(_("Switch Workspaces"));
885 panel
= wmalloc(sizeof(_Panel
));
887 panel
->sectionName
= _("Mouse Preferences");
889 panel
->description
= _("Mouse speed/acceleration, double click delay,\n" "mouse button bindings etc.");
891 panel
->parent
= parent
;
893 panel
->callbacks
.createWidgets
= createPanel
;
894 panel
->callbacks
.updateDomain
= storeData
;
896 AddSection(panel
, ICON_FILE
);