1 /* MouseSettings.c- mouse options (some are equivalent to xset)
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 #include <X11/Xutil.h>
30 /* double-click tester */
39 typedef struct _Panel
{
44 CallbackRec callbacks
;
80 WMButton
*lastClickedSpeed
;
86 #define ICON_FILE "mousesettings"
88 #define SPEED_ICON_FILE "mousespeed"
89 #define SPEED_IMAGE "speed%i"
90 #define SPEED_IMAGE_S "speed%is"
92 #define DELAY_ICON "timer%i"
93 #define DELAY_ICON_S "timer%is"
95 #define MOUSEB_L "minimouseleft"
96 #define MOUSEB_M "minimousemiddle"
97 #define MOUSEB_R "minimouseright"
99 /* need access to the double click variables */
104 static char *modifierNames
[] = {
116 #define DELAY(i) ((i)*75+170)
119 int ModifierFromKey(Display
*dpy
, char *key
);
123 setMouseAccel(WMScreen
*scr
, float accel
, int threshold
)
130 XChangePointerControl(WMScreenDisplay(scr
), True
, True
, n
, d
, threshold
);
135 speedClick(WMWidget
*w
, void *data
)
137 _Panel
*panel
= (_Panel
*)data
;
146 tmp
= WMGetTextFieldText(panel
->acceT
);
147 if (sscanf(tmp
, "%f", &accel
)!=1 || accel
< 0) {
148 WMRunAlertPanel(WMWidgetScreen(panel
->acceT
), GetWindow(panel
),
150 _("Invalid mouse acceleration value. Must be a positive real value."),
151 _("OK"), NULL
, NULL
);
155 panel
->acceleration
= accel
;
158 for (i
=0; i
<5; i
++) {
159 if (panel
->speedB
[i
]==w
)
163 panel
->acceleration
= 0.5+(i
*0.5);
165 sprintf(buffer
, "%.2f", 0.5+(i
*0.5));
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
);
176 setMouseAccel(WMWidgetScreen(panel
->win
), panel
->acceleration
,
184 returnPressed(void *observerData
, WMNotification
*notification
)
186 _Panel
*panel
= (_Panel
*)observerData
;
188 speedClick(NULL
, panel
);
193 doubleClick(WMWidget
*w
, void *data
)
195 _Panel
*panel
= (_Panel
*)data
;
197 extern _WINGsConfiguration WINGsConfiguration
;
200 for (i
=0; i
<5; i
++) {
201 if (panel
->ddelaB
[i
]==w
)
204 WINGsConfiguration
.doubleClickDelay
= DELAY(i
);
206 sprintf(buffer
, "%i", DELAY(i
));
207 WMSetTextFieldText(panel
->ddelaT
, buffer
);
218 if (strcasecmp(str
, "left")==0)
220 else if (strcasecmp(str
, "middle")==0)
222 else if (strcasecmp(str
, "right")==0)
224 else if (strcasecmp(str
, "button1")==0)
226 else if (strcasecmp(str
, "button2")==0)
228 else if (strcasecmp(str
, "button3")==0)
230 else if (strcasecmp(str
, "button4")==0
231 || strcasecmp(str
, "button5")==0) {
232 wwarning(_("mouse button %s not supported by WPrefs."), str
);
241 getMouseParameters(Display
*dpy
, float *accel
, int *thre
)
245 XGetPointerControl(dpy
, &n
, &d
, thre
);
247 *accel
= (float)n
/(float)d
;
253 showData(_Panel
*panel
)
257 int a
=-1, b
=-1, c
=-1;
260 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(panel
->win
));
262 str
= GetStringForKey("SelectWindowsMouseButton");
268 wwarning(_("bad value %s for option %s"),str
, "SelectWindowsMouseButton");
269 WMPerformButtonClick(panel
->smb
[0]);
272 WMPerformButtonClick(panel
->smb
[i
]);
275 str
= GetStringForKey("WindowListMouseButton");
281 wwarning(_("bad value %s for option %s"), str
, "WindowListMouseButton");
282 WMPerformButtonClick(panel
->lmb
[1]);
285 WMPerformButtonClick(panel
->lmb
[i
]);
288 str
= GetStringForKey("ApplicationMenuMouseButton");
294 wwarning(_("bad value %s for option %s"), str
, "ApplicationMenuMouseButton");
295 WMPerformButtonClick(panel
->amb
[2]);
298 WMPerformButtonClick(panel
->amb
[i
]);
302 WMSetButtonSelected(panel
->disaB
, GetBoolForKey("DisableWSMouseActions"));
305 getMouseParameters(dpy
, &accel
, &a
);
306 panel
->maxThreshold
= WidthOfScreen(DefaultScreenOfDisplay(dpy
));
307 if (a
> panel
->maxThreshold
) {
308 panel
->maxThreshold
= a
;
310 sprintf(buffer
, "%i", a
);
311 WMSetTextFieldText(panel
->threT
, buffer
);
314 for (i
=0; i
<5; i
++) {
315 if (0.5+(float)i
*0.5 == accel
)
319 WMPerformButtonClick(panel
->speedB
[a
]);
320 panel
->lastClickedSpeed
= panel
->speedB
[a
];
322 panel
->acceleration
= accel
;
323 sprintf(buffer
, "%.2f", accel
);
324 WMSetTextFieldText(panel
->acceT
, buffer
);
326 speedClick(panel
->lastClickedSpeed
, panel
);
328 b
= GetIntegerForKey("DoubleClickTime");
329 /* find best match */
331 for (i
=0; i
<5; i
++) {
336 WMPerformButtonClick(panel
->ddelaB
[a
]);
337 sprintf(buffer
, "%i", b
);
338 WMSetTextFieldText(panel
->ddelaT
, buffer
);
341 str
= GetStringForKey("ModifierKey");
344 a
= ModifierFromKey(dpy
, str
);
347 str
= modifierNames
[a
];
350 for (i
=0; i
<WMGetPopUpButtonNumberOfItems(panel
->grabP
); i
++) {
351 if (strstr(WMGetPopUpButtonItem(panel
->grabP
, i
), str
)) {
352 WMSetPopUpButtonSelectedItem(panel
->grabP
, i
);
360 sscanf(WMGetPopUpButtonItem(panel
->grabP
, 0), "%s", buffer
);
361 WMSetPopUpButtonSelectedItem(panel
->grabP
, 0);
362 wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"),
370 fillModifierPopUp(WMPopUpButton
*pop
)
372 XModifierKeymap
*mapping
;
373 Display
*dpy
= WMScreenDisplay(WMWidgetScreen(pop
));
379 mapping
= XGetModifierMapping(dpy
);
381 if (!mapping
|| mapping
->max_keypermod
==0) {
382 WMAddPopUpButtonItem(pop
, "Mod1");
383 WMAddPopUpButtonItem(pop
, "Mod2");
384 WMAddPopUpButtonItem(pop
, "Mod3");
385 WMAddPopUpButtonItem(pop
, "Mod4");
386 WMAddPopUpButtonItem(pop
, "Mod5");
387 wwarning(_("could not retrieve keyboard modifier mapping"));
392 for (j
=0; j
<8; j
++) {
402 memset(array
, 0, sizeof(char*)*8);
403 for (i
=0; i
< mapping
->max_keypermod
; i
++) {
404 idx
= i
+j
*mapping
->max_keypermod
;
405 if (mapping
->modifiermap
[idx
]!=0) {
407 for (l
=0; l
<4; l
++) {
408 ksym
= XKeycodeToKeysym(dpy
, mapping
->modifiermap
[idx
], l
);
413 str
= XKeysymToString(ksym
);
416 if (str
&& !strstr(str
, "_Lock") && !strstr(str
, "Shift")
417 && !strstr(str
, "Control")) {
418 array
[a
++] = wstrdup(str
);
423 for (k
=0; k
<a
; k
++) {
426 tmp
= wstrdup(array
[k
]);
427 ptr
= strstr(tmp
, "_L");
430 ptr
= strstr(tmp
, "_R");
433 sprintf(buffer
, "%s (%s)", modifierNames
[j
], tmp
);
434 WMAddPopUpButtonItem(pop
, buffer
);
435 for (i
=k
+1; i
<a
; i
++) {
436 if (strstr(array
[i
], tmp
)) {
452 XFreeModifiermap(mapping
);
458 mouseButtonClickA(WMWidget
*w
, void *data
)
460 _Panel
*panel
= (_Panel
*)data
;
463 for (i
=0; i
<3; i
++) {
464 if (panel
->amb
[i
]==w
)
469 if (WMGetButtonSelected(panel
->lmb
[i
]))
470 WMSetButtonSelected(panel
->lmb
[i
], False
);
471 if (WMGetButtonSelected(panel
->smb
[i
]))
472 WMSetButtonSelected(panel
->smb
[i
], False
);
476 mouseButtonClickL(WMWidget
*w
, void *data
)
478 _Panel
*panel
= (_Panel
*)data
;
481 for (i
=0; i
<3; i
++) {
482 if (panel
->lmb
[i
]==w
)
487 if (WMGetButtonSelected(panel
->smb
[i
]))
488 WMSetButtonSelected(panel
->smb
[i
], False
);
489 if (WMGetButtonSelected(panel
->amb
[i
]))
490 WMSetButtonSelected(panel
->amb
[i
], False
);
494 mouseButtonClickS(WMWidget
*w
, void *data
)
496 _Panel
*panel
= (_Panel
*)data
;
499 for (i
=0; i
<3; i
++) {
500 if (panel
->smb
[i
]==w
)
505 if (WMGetButtonSelected(panel
->lmb
[i
]))
506 WMSetButtonSelected(panel
->lmb
[i
], False
);
507 if (WMGetButtonSelected(panel
->amb
[i
]))
508 WMSetButtonSelected(panel
->amb
[i
], False
);
512 createPanel(Panel
*p
)
514 _Panel
*panel
= (_Panel
*)p
;
515 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
526 panel
->frame
= WMCreateFrame(panel
->win
);
527 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
528 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
530 /**************** Mouse Speed ****************/
531 panel
->speedF
= WMCreateFrame(panel
->frame
);
532 WMResizeWidget(panel
->speedF
, 245, 100);
533 WMMoveWidget(panel
->speedF
, 15, 15);
534 WMSetFrameTitle(panel
->speedF
, _("Mouse Speed"));
536 panel
->speedL
= WMCreateLabel(panel
->speedF
);
537 WMResizeWidget(panel
->speedL
, 40, 46);
538 WMMoveWidget(panel
->speedL
, 15, 14);
539 WMSetLabelImagePosition(panel
->speedL
, WIPImageOnly
);
540 path
= LocateImage(SPEED_ICON_FILE
);
542 icon
= WMCreateBlendedPixmapFromFile(scr
, path
, &color
);
544 WMSetLabelImage(panel
->speedL
, icon
);
545 WMReleasePixmap(icon
);
547 wwarning(_("could not load icon %s"), path
);
552 buf1
= wmalloc(strlen(SPEED_IMAGE
)+2);
553 buf2
= wmalloc(strlen(SPEED_IMAGE_S
)+2);
555 for (i
= 0; i
< 5; i
++) {
556 panel
->speedB
[i
] = WMCreateCustomButton(panel
->speedF
,
558 WMResizeWidget(panel
->speedB
[i
], 26, 26);
559 WMMoveWidget(panel
->speedB
[i
], 60+(35*i
), 25);
560 WMSetButtonBordered(panel
->speedB
[i
], False
);
561 WMSetButtonImagePosition(panel
->speedB
[i
], WIPImageOnly
);
562 WMSetButtonAction(panel
->speedB
[i
], speedClick
, panel
);
564 WMGroupButtons(panel
->speedB
[0], panel
->speedB
[i
]);
566 sprintf(buf1
, SPEED_IMAGE
, i
);
567 sprintf(buf2
, SPEED_IMAGE_S
, i
);
568 path
= LocateImage(buf1
);
570 icon
= WMCreatePixmapFromFile(scr
, path
);
572 WMSetButtonImage(panel
->speedB
[i
], icon
);
573 WMReleasePixmap(icon
);
575 wwarning(_("could not load icon file %s"), path
);
579 path
= LocateImage(buf2
);
581 icon
= WMCreatePixmapFromFile(scr
, path
);
583 WMSetButtonAltImage(panel
->speedB
[i
], icon
);
584 WMReleasePixmap(icon
);
586 wwarning(_("could not load icon file %s"), path
);
593 panel
->acceL
= WMCreateLabel(panel
->speedF
);
594 WMResizeWidget(panel
->acceL
, 70, 16);
595 WMMoveWidget(panel
->acceL
, 10, 67);
596 WMSetLabelTextAlignment(panel
->acceL
, WARight
);
597 WMSetLabelText(panel
->acceL
, _("Acceler.:"));
599 panel
->acceT
= WMCreateTextField(panel
->speedF
);
600 WMResizeWidget(panel
->acceT
, 40, 20);
601 WMMoveWidget(panel
->acceT
, 80, 65);
602 WMAddNotificationObserver(returnPressed
, panel
,
603 WMTextDidEndEditingNotification
, panel
->acceT
);
606 panel
->threL
= WMCreateLabel(panel
->speedF
);
607 WMResizeWidget(panel
->threL
, 80, 16);
608 WMMoveWidget(panel
->threL
, 120, 67);
609 WMSetLabelTextAlignment(panel
->threL
, WARight
);
610 WMSetLabelText(panel
->threL
, _("Threshold:"));
612 panel
->threT
= WMCreateTextField(panel
->speedF
);
613 WMResizeWidget(panel
->threT
, 30, 20);
614 WMMoveWidget(panel
->threT
, 200, 65);
615 WMAddNotificationObserver(returnPressed
, panel
,
616 WMTextDidEndEditingNotification
, panel
->threT
);
618 WMMapSubwidgets(panel
->speedF
);
620 /***************** Doubleclick Delay ****************/
622 panel
->ddelaF
= WMCreateFrame(panel
->frame
);
623 WMResizeWidget(panel
->ddelaF
, 245, 95);
624 WMMoveWidget(panel
->ddelaF
, 15, 125);
625 WMSetFrameTitle(panel
->ddelaF
, _("Double-Click Delay"));
627 buf1
= wmalloc(strlen(DELAY_ICON
)+2);
628 buf2
= wmalloc(strlen(DELAY_ICON_S
)+2);
630 for (i
= 0; i
< 5; i
++) {
631 panel
->ddelaB
[i
] = WMCreateCustomButton(panel
->ddelaF
,
633 WMResizeWidget(panel
->ddelaB
[i
], 25, 25);
634 WMMoveWidget(panel
->ddelaB
[i
], 30+(40*i
), 20);
635 WMSetButtonBordered(panel
->ddelaB
[i
], False
);
636 WMSetButtonImagePosition(panel
->ddelaB
[i
], WIPImageOnly
);
637 WMSetButtonAction(panel
->ddelaB
[i
], doubleClick
, panel
);
639 WMGroupButtons(panel
->ddelaB
[0], panel
->ddelaB
[i
]);
641 sprintf(buf1
, DELAY_ICON
, i
+1);
642 sprintf(buf2
, DELAY_ICON_S
, i
+1);
643 path
= LocateImage(buf1
);
645 icon
= WMCreatePixmapFromFile(scr
, path
);
647 WMSetButtonImage(panel
->ddelaB
[i
], icon
);
648 WMReleasePixmap(icon
);
650 wwarning(_("could not load icon file %s"), path
);
654 path
= LocateImage(buf2
);
656 icon
= WMCreatePixmapFromFile(scr
, path
);
658 WMSetButtonAltImage(panel
->ddelaB
[i
], icon
);
659 WMReleasePixmap(icon
);
661 wwarning(_("could not load icon file %s"), path
);
669 panel
->tester
= CreateDoubleTest(panel
->ddelaF
, _("Test"));
670 WMResizeWidget(panel
->tester
, 84, 29);
671 WMMoveWidget(panel
->tester
, 35, 55);
673 panel
->ddelaT
= WMCreateTextField(panel
->ddelaF
);
674 WMResizeWidget(panel
->ddelaT
, 40, 20);
675 WMMoveWidget(panel
->ddelaT
, 140, 60);
677 panel
->ddelaL
= WMCreateLabel(panel
->ddelaF
);
678 WMResizeWidget(panel
->ddelaL
, 40, 16);
679 WMMoveWidget(panel
->ddelaL
, 185, 65);
684 font
= WMSystemFontOfSize(scr
, 10);
685 color
= WMDarkGrayColor(scr
);
686 WMSetLabelTextColor(panel
->ddelaL
, color
);
687 WMSetLabelFont(panel
->ddelaL
, font
);
689 WMReleaseColor(color
);
691 WMSetLabelText(panel
->ddelaL
, "msec");
693 WMMapSubwidgets(panel
->ddelaF
);
695 /* ************** Workspace Action Buttons **************** */
696 panel
->menuF
= WMCreateFrame(panel
->frame
);
697 WMResizeWidget(panel
->menuF
, 240, 145);
698 WMMoveWidget(panel
->menuF
, 270, 15);
699 WMSetFrameTitle(panel
->menuF
, _("Workspace Mouse Actions"));
701 panel
->disaB
= WMCreateSwitchButton(panel
->menuF
);
702 WMResizeWidget(panel
->disaB
, 205, 18);
703 WMMoveWidget(panel
->disaB
, 10, 20);
704 WMSetButtonText(panel
->disaB
, _("Disable mouse actions"));
706 panel
->mblL
= WMCreateLabel(panel
->menuF
);
707 WMResizeWidget(panel
->mblL
, 16, 22);
708 WMMoveWidget(panel
->mblL
, 135, 40);
709 WMSetLabelImagePosition(panel
->mblL
, WIPImageOnly
);
710 path
= LocateImage(MOUSEB_L
);
712 icon
= WMCreatePixmapFromFile(scr
, path
);
714 WMSetLabelImage(panel
->mblL
, icon
);
715 WMReleasePixmap(icon
);
717 wwarning(_("could not load icon file %s"), path
);
721 panel
->mbmL
= WMCreateLabel(panel
->menuF
);
722 WMResizeWidget(panel
->mbmL
, 16, 22);
723 WMMoveWidget(panel
->mbmL
, 170, 40);
724 WMSetLabelImagePosition(panel
->mbmL
, WIPImageOnly
);
725 path
= LocateImage(MOUSEB_M
);
727 icon
= WMCreatePixmapFromFile(scr
, path
);
729 WMSetLabelImage(panel
->mbmL
, icon
);
730 WMReleasePixmap(icon
);
732 wwarning(_("could not load icon file %s"), path
);
737 panel
->mbrL
= WMCreateLabel(panel
->menuF
);
738 WMResizeWidget(panel
->mbrL
, 16, 22);
739 WMMoveWidget(panel
->mbrL
, 205, 40);
740 WMSetLabelImagePosition(panel
->mbrL
, WIPImageOnly
);
741 path
= LocateImage(MOUSEB_R
);
743 icon
= WMCreatePixmapFromFile(scr
, path
);
745 WMSetLabelImage(panel
->mbrL
, icon
);
746 WMReleasePixmap(icon
);
748 wwarning(_("could not load icon file %s"), path
);
753 panel
->appL
= WMCreateLabel(panel
->menuF
);
754 WMResizeWidget(panel
->appL
, 125, 16);
755 WMMoveWidget(panel
->appL
, 5, 65);
756 WMSetLabelTextAlignment(panel
->appL
, WARight
);
757 WMSetLabelText(panel
->appL
, _("Applications menu"));
759 panel
->listL
= WMCreateLabel(panel
->menuF
);
760 WMResizeWidget(panel
->listL
, 125, 16);
761 WMMoveWidget(panel
->listL
, 5, 90);
762 WMSetLabelTextAlignment(panel
->listL
, WARight
);
763 WMSetLabelText(panel
->listL
, _("Window list menu"));
765 panel
->selL
= WMCreateLabel(panel
->menuF
);
766 WMResizeWidget(panel
->selL
, 125, 16);
767 WMMoveWidget(panel
->selL
, 5, 115);
768 WMSetLabelTextAlignment(panel
->selL
, WARight
);
769 WMSetLabelText(panel
->selL
, _("Select windows"));
772 for (i
=0; i
<3; i
++) {
773 panel
->amb
[i
] = WMCreateRadioButton(panel
->menuF
);
774 WMResizeWidget(panel
->amb
[i
], 24, 24);
775 WMMoveWidget(panel
->amb
[i
], 135+35*i
, 65);
776 WMSetButtonText(panel
->amb
[i
], NULL
);
777 WMSetButtonAction(panel
->amb
[i
], mouseButtonClickA
, panel
);
779 panel
->lmb
[i
] = WMCreateRadioButton(panel
->menuF
);
780 WMResizeWidget(panel
->lmb
[i
], 24, 24);
781 WMMoveWidget(panel
->lmb
[i
], 135+35*i
, 90);
782 WMSetButtonText(panel
->lmb
[i
], NULL
);
783 WMSetButtonAction(panel
->lmb
[i
], mouseButtonClickL
, panel
);
785 panel
->smb
[i
] = WMCreateRadioButton(panel
->menuF
);
786 WMResizeWidget(panel
->smb
[i
], 24, 24);
787 WMMoveWidget(panel
->smb
[i
], 135+35*i
, 115);
788 WMSetButtonText(panel
->smb
[i
], NULL
);
789 WMSetButtonAction(panel
->smb
[i
], mouseButtonClickS
, panel
);
792 WMGroupButtons(panel
->lmb
[0], panel
->lmb
[i
]);
793 WMGroupButtons(panel
->amb
[0], panel
->amb
[i
]);
794 WMGroupButtons(panel
->smb
[0], panel
->smb
[i
]);
798 WMMapSubwidgets(panel
->menuF
);
800 /* ************** Grab Modifier **************** */
801 panel
->grabF
= WMCreateFrame(panel
->frame
);
802 WMResizeWidget(panel
->grabF
, 240, 55);
803 WMMoveWidget(panel
->grabF
, 270, 165);
804 WMSetFrameTitle(panel
->grabF
, _("Mouse Grab Modifier"));
806 panel
->grabP
= WMCreatePopUpButton(panel
->grabF
);
807 WMResizeWidget(panel
->grabP
, 160, 20);
808 WMMoveWidget(panel
->grabP
, 40, 25);
810 fillModifierPopUp(panel
->grabP
);
812 WMMapSubwidgets(panel
->grabF
);
814 WMRealizeWidget(panel
->frame
);
815 WMMapSubwidgets(panel
->frame
);
823 storeCommandInScript(char *cmd
, char *line
)
830 p
= wusergnusteppath();
831 path
= wmalloc(strlen(p
)+64);
832 sprintf(path
, "%s/Library/WindowMaker/autostart", p
);
834 f
= fopen(path
, "r");
836 f
= fopen(path
, "w");
838 wsyserror(_("could not create %s"), path
);
841 fprintf(f
, "#!/bin/sh\n");
845 int len
= strlen(cmd
);
850 tmppath
= wmalloc(strlen(p
)+64);
851 sprintf(tmppath
, "%s/Library/WindowMaker/autostart.tmp", p
);
852 fo
= fopen(tmppath
, "w");
854 wsyserror(_("could not create temporary file %s"), tmppath
);
859 if (!fgets(buffer
, 127, f
)) {
862 if (strncmp(buffer
, cmd
, len
)==0) {
878 if (rename(tmppath
, path
)!=0) {
879 wsyserror(_("could not rename file %s to %s\n"), tmppath
, path
);
883 sprintf(buffer
, "chmod u+x %s", path
);
894 storeData(_Panel
*panel
)
899 static char *button
[3] = {"left", "middle", "right"};
900 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
902 if (!WMGetUDBoolForKey(udb
, "NoXSetStuff")) {
903 tmp
= WMGetTextFieldText(panel
->threT
);
904 if (strlen(tmp
)==0) {
909 sprintf(buffer
, XSET
" m %i/%i %s\n", (int)(panel
->acceleration
*10),
911 storeCommandInScript(XSET
" m", buffer
);
916 tmp
= WMGetTextFieldText(panel
->ddelaT
);
917 if (sscanf(tmp
, "%i", &i
) == 1 && i
> 0)
918 SetIntegerForKey(i
, "DoubleClickTime");
920 SetBoolForKey(WMGetButtonSelected(panel
->disaB
), "DisableWSMouseActions");
922 for (i
=0; i
<3; i
++) {
923 if (WMGetButtonSelected(panel
->amb
[i
]))
927 SetStringForKey(button
[i
], "ApplicationMenuMouseButton");
929 for (i
=0; i
<3; i
++) {
930 if (WMGetButtonSelected(panel
->lmb
[i
]))
934 SetStringForKey(button
[i
], "WindowListMouseButton");
936 for (i
=0; i
<3; i
++) {
937 if (WMGetButtonSelected(panel
->smb
[i
]))
941 SetStringForKey(button
[i
], "SelectWindowsMouseButton");
943 tmp
= WMGetPopUpButtonItem(panel
->grabP
,
944 WMGetPopUpButtonSelectedItem(panel
->grabP
));
946 p
= strchr(tmp
, ' ');
949 SetStringForKey(tmp
, "ModifierKey");
956 InitMouseSettings(WMScreen
*scr
, WMWindow
*win
)
960 panel
= wmalloc(sizeof(_Panel
));
961 memset(panel
, 0, sizeof(_Panel
));
963 panel
->sectionName
= _("Mouse Preferences");
967 panel
->callbacks
.createWidgets
= createPanel
;
968 panel
->callbacks
.updateDomain
= storeData
;
970 AddSection(panel
, ICON_FILE
);