mcde: keyboard and mouse in System Settings; dtsession keeps them
dtsystemsettings draws the Keyboard pane (key repeat, its delay and rate, key click, a field to try it) and the Mouse pane (primary button, pointer speed, threshold, double-click time) instead of opening dtstyle. A change takes effect at once through Xlib and goes to dtsession as dtstyle sends it (_DT_SM_KEYBOARD_INFO, _DT_SM_POINTER_INFO; *multiClickTime through _DtAddToResource). dtsession saves and restores the XKB repeat delay and interval (XkbGetAutoRepeatRate at logout, XkbSetAutoRepeatRate at login), which the core keyboard state does not carry. And it keeps every pointer button: the map was char[5], the parse of the property wrote past it without a bound, and the restore cut the map to 5, which the server refuses on a mouse with more buttons. Measured on Xvfb (build/mcde-shots): the sliders set the server (xset q: delay 490, rate 29, click 20; acceleration 3/1, multiClickTime 280; xmodmap -pp 1->3, 3->1). Through a whole dtsession: logout wrote RepeatDelay 490, RepeatInterval 34, ButtonMap 3,2,1,4,...,10 (10 buttons), AccelNum 3; the next login restored delay 490 rate 29, acceleration 3/1 and the swapped buttons. The double-click time is saved (dt.resources) but its restore is not measured: a dtsession started without Xsession gets no resources loaded (3 in xrdb, against 108 in a real session). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
451aac7fe4
commit
c0bf505c0a
11 files changed
+338
-13
No files matched your search
@@ -96,7 +96,8 @@ place of CDE; pkgsrc builds it on any platform from `pkgsrc/`.
|
||||
(`panes.c`, plain C with `test_panes`), a click opens the pane in the
|
||||
window, "Show All" goes back, `-pane ID` opens one at once (the bar's
|
||||
"... Settings..." items do). Drawn here through McdeSys: Sound, Network,
|
||||
Bluetooth, Date & Time, About; CDE's style manager and printer tool open
|
||||
Bluetooth, Date & Time, About, Keyboard, Mouse; CDE's style manager and
|
||||
printer tool open
|
||||
for their panes until those are drawn here. Accounts (`accounts.c`):
|
||||
the people (uid 1000..59999), add, delete, password, administrator, all
|
||||
through McdeSys; not as root the pane offers "Unlock...": a terminal where
|
||||
@@ -104,6 +105,19 @@ place of CDE; pkgsrc builds it on any platform from `pkgsrc/`.
|
||||
Update (`update.c`): running/available version, new packages, source;
|
||||
"Update Now..." runs `dtsystemsettings -apply-update` (mcde_sys_update_apply)
|
||||
as root in a terminal.
|
||||
Keyboard and Mouse (`input.c`): settings of the X server, not of the
|
||||
system, so no McdeSys: Xlib (XChangeKeyboardControl, XkbSetAutoRepeatRate,
|
||||
XChangePointerControl, XSetPointerMapping) at once, and the properties
|
||||
`_DT_SM_KEYBOARD_INFO`/`_DT_SM_POINTER_INFO` on dtsession's window as
|
||||
dtstyle sends them, so dtsession saves them at logout. dtsession saves
|
||||
and restores the XKB repeat delay and interval too (`SmSave.c`
|
||||
PrintRepeatRate, `SmRestore.c`; resources RepeatDelay, RepeatInterval),
|
||||
and keeps every button of the pointer map (`Sm.h` pointerMap[256]; it was
|
||||
5 and the save overflowed it with a mouse of more buttons -- Xvfb has 10).
|
||||
Test a session through logout and login with dtaction ExitSession and
|
||||
DTDATABASESEARCHPATH set; a dtsession started without Xsession does not
|
||||
get its resources loaded, so the double-click time is not measured that
|
||||
way.
|
||||
- McdeSys users and update: `users.c` (getpwent/getgrnam, useradd/userdel),
|
||||
the backends for password and the administrators' group -- NetBSD hashes
|
||||
with pw_gensalt(3)/crypt(3) for `usermod -p` and, having no tool to remove
|
||||
|
||||
@@ -159,6 +159,8 @@ typedef struct
|
||||
|
||||
XKeyboardState kbdState; /* Keyboard Control Information */
|
||||
char *autoRepeats;
|
||||
int repeatDelay; /* MCDE: XKB key repeat, ms; -1 */
|
||||
int repeatInterval; /* when not saved */
|
||||
|
||||
char *buttonMap; /*Button Mapping Information */
|
||||
|
||||
@@ -222,7 +224,9 @@ typedef struct
|
||||
Boolean audioChange;
|
||||
Boolean pointerChange;
|
||||
Boolean pointerMapChange;
|
||||
char pointerMap[5];
|
||||
/* MCDE: as many as X has (a mouse with a wheel reports 7 and more;
|
||||
* 5 overflowed in SmSave.c) */
|
||||
unsigned char pointerMap[256];
|
||||
int numButton;
|
||||
Boolean keyboardChange;
|
||||
Boolean screenSavChange;
|
||||
|
||||
@@ -97,6 +97,8 @@ extern char SmNbellPitch[];
|
||||
extern char SmNbellDuration[];
|
||||
extern char SmNledMask[];
|
||||
extern char SmNglobalRepeats[];
|
||||
extern char SmNrepeatDelay[];
|
||||
extern char SmNrepeatInterval[];
|
||||
extern char SmNautoRepeats[];
|
||||
extern char SmNaccelNum[];
|
||||
extern char SmNaccelDenom[];
|
||||
@@ -160,6 +162,8 @@ extern char SmCbellPitch[];
|
||||
extern char SmCbellDuration[];
|
||||
extern char SmCledMask[];
|
||||
extern char SmCglobalRepeats[];
|
||||
extern char SmCrepeatDelay[];
|
||||
extern char SmCrepeatInterval[];
|
||||
extern char SmCautoRepeats[];
|
||||
extern char SmCaccelNum[];
|
||||
extern char SmCaccelDenom[];
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/StringDefs.h>
|
||||
@@ -196,6 +197,12 @@ static XtResource settingsResources[] =
|
||||
XtRImmediate, (XtPointer) 2},
|
||||
{SmNautoRepeats, SmCautoRepeats, XtRString, sizeof(String),
|
||||
XtOffset(SessionSettingsPtr, autoRepeats), XtRString, (XtPointer) ""},
|
||||
{SmNrepeatDelay, SmCrepeatDelay, XtRInt, sizeof(int),
|
||||
XtOffset(SessionSettingsPtr, repeatDelay),
|
||||
XtRImmediate, (XtPointer) -1},
|
||||
{SmNrepeatInterval, SmCrepeatInterval, XtRInt, sizeof(int),
|
||||
XtOffset(SessionSettingsPtr, repeatInterval),
|
||||
XtRImmediate, (XtPointer) -1},
|
||||
|
||||
{SmNbuttonMap, SmCbuttonMap, XtRString, sizeof(String),
|
||||
XtOffset(SessionSettingsPtr, buttonMap), XtRString, (XtPointer) ""},
|
||||
@@ -1301,6 +1308,16 @@ RestoreSettings( void )
|
||||
XSetFontPath(smGD.display, restorePtrArray, numArgs);
|
||||
}
|
||||
|
||||
/*
|
||||
* MCDE: the key repeat delay and rate, which the core protocol does not
|
||||
* have: XKB's XkbSetAutoRepeatRate(3), as xset(1) "r rate" sets them.
|
||||
* SmSave.c (PrintRepeatRate) saves what the server had.
|
||||
*/
|
||||
if (smSettings.repeatDelay > 0 && smSettings.repeatInterval > 0)
|
||||
XkbSetAutoRepeatRate(smGD.display, XkbUseCoreKbd,
|
||||
(unsigned int) smSettings.repeatDelay,
|
||||
(unsigned int) smSettings.repeatInterval);
|
||||
|
||||
/*
|
||||
* Restore the keyboard control information. In order for it
|
||||
* to be restored it has to be changed from a XKeyboardState
|
||||
@@ -1447,7 +1464,10 @@ RestoreSettings( void )
|
||||
/*
|
||||
* Copy the pointer map into the saved map for logout
|
||||
*/
|
||||
smToSet.numButton = ((numArgs > 5) ? 5 : numArgs);
|
||||
/* MCDE: every button; 5 saved a map the server refuses at the next
|
||||
* login on a mouse with more */
|
||||
smToSet.numButton = ((numArgs > (int) sizeof smToSet.pointerMap) ?
|
||||
(int) sizeof smToSet.pointerMap : numArgs);
|
||||
for(i = 0; i < smToSet.numButton;i++)
|
||||
{
|
||||
smToSet.pointerMap[i] = restoreCharArray[i];
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/keysymdef.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <Dt/DtP.h>
|
||||
#include <Dt/Connect.h>
|
||||
#include <Dt/UserMsg.h>
|
||||
@@ -147,6 +148,8 @@ static int PrintFontPaths(
|
||||
XrmDatabase *smBase,
|
||||
char **fontPath,
|
||||
int numPaths) ;
|
||||
static void PrintRepeatRate(
|
||||
XrmDatabase *smBase) ;
|
||||
static int PrintKeyboardControl(
|
||||
XrmDatabase *smBase);
|
||||
static int PrintPointerMapping(
|
||||
@@ -1185,6 +1188,7 @@ QueryServerSettings( void )
|
||||
XFreeFontPath(fontPath);
|
||||
return(-1);
|
||||
}
|
||||
PrintRepeatRate(&smBase);
|
||||
|
||||
/*
|
||||
* Put all the button modifier information into the resource database.
|
||||
@@ -1397,7 +1401,7 @@ SaveCustomizeSettings( void )
|
||||
XrmDatabase smBase = NULL;
|
||||
char *tmpChar[20], *ptrRet = NULL, *tmpKey;
|
||||
Status newStat;
|
||||
char tmpMap[128];
|
||||
char tmpMap[1024];
|
||||
|
||||
|
||||
if(smCust.pointerChange)
|
||||
@@ -1411,7 +1415,7 @@ SaveCustomizeSettings( void )
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(ptrRet, "%d %s %d %d %s",
|
||||
sscanf(ptrRet, "%d %1023s %d %d %49s",
|
||||
&smToSet.numButton,
|
||||
tmpMap,
|
||||
&smSettings.accelNum,
|
||||
@@ -1421,12 +1425,15 @@ SaveCustomizeSettings( void )
|
||||
|
||||
tmpKey = strtok(tmpMap, "_");
|
||||
i = 0;
|
||||
while(tmpKey != NULL)
|
||||
while(tmpKey != NULL && i < (int) sizeof smToSet.pointerMap)
|
||||
{
|
||||
smToSet.pointerMap[i] = (char) atoi(tmpKey);
|
||||
smToSet.pointerMap[i] = (unsigned char) atoi(tmpKey);
|
||||
i++;
|
||||
tmpKey = strtok(NULL, "_");
|
||||
}
|
||||
/* MCDE: no more buttons than the map names */
|
||||
if (smToSet.numButton > i)
|
||||
smToSet.numButton = i;
|
||||
|
||||
|
||||
/*
|
||||
@@ -1444,7 +1451,7 @@ SaveCustomizeSettings( void )
|
||||
|
||||
if(smToSet.pointerMapChange == True)
|
||||
{
|
||||
if(PrintPointerMapping(&smBase, smToSet.pointerMap,
|
||||
if(PrintPointerMapping(&smBase, (char *) smToSet.pointerMap,
|
||||
smToSet.numButton) != 0)
|
||||
{
|
||||
return(-1);
|
||||
@@ -1532,6 +1539,7 @@ SaveCustomizeSettings( void )
|
||||
sprintf((char *)tmpChar,"%d", smSettings.kbdState.global_auto_repeat);
|
||||
strcat(resSpec, (char *)tmpChar);
|
||||
XrmPutLineResource(&smBase, resSpec);
|
||||
PrintRepeatRate(&smBase);
|
||||
}
|
||||
|
||||
|
||||
@@ -1993,6 +2001,29 @@ PrintFontPaths(
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* MCDE: the key repeat delay and rate, from the server as it is now
|
||||
* (XkbGetAutoRepeatRate(3)); restored by SmRestore.c. Not in the core
|
||||
* keyboard state XGetKeyboardControl returns.
|
||||
*/
|
||||
static void
|
||||
PrintRepeatRate(
|
||||
XrmDatabase *smBase)
|
||||
{
|
||||
unsigned int delay = 0, interval = 0;
|
||||
char line[128];
|
||||
|
||||
if (!XkbGetAutoRepeatRate(smGD.display, XkbUseCoreKbd, &delay, &interval)
|
||||
|| delay == 0 || interval == 0)
|
||||
return;
|
||||
snprintf(line, sizeof line, "%s*%s:%u", SM_RESOURCE_CLASS,
|
||||
SmCrepeatDelay, delay);
|
||||
XrmPutLineResource(smBase, line);
|
||||
snprintf(line, sizeof line, "%s*%s:%u", SM_RESOURCE_CLASS,
|
||||
SmCrepeatInterval, interval);
|
||||
XrmPutLineResource(smBase, line);
|
||||
}
|
||||
|
||||
/*************************************<->*************************************
|
||||
*
|
||||
* PrintKeyboardControl (smBase)
|
||||
|
||||
@@ -91,6 +91,9 @@ char SmNbellPitch[] = "bellPitch";
|
||||
char SmNbellDuration[] = "bellDuration";
|
||||
char SmNledMask[] = "ledMask";
|
||||
char SmNglobalRepeats[] = "globalAutoRepeats";
|
||||
/* MCDE: the XKB key repeat (SmSave.c PrintRepeatRate, SmRestore.c) */
|
||||
char SmNrepeatDelay[] = "repeatDelay";
|
||||
char SmNrepeatInterval[] = "repeatInterval";
|
||||
char SmNautoRepeats[] = "autoRepeats";
|
||||
char SmNaccelNum[] = "accelNum";
|
||||
char SmNaccelDenom[] = "accelDenom";
|
||||
@@ -153,6 +156,8 @@ char SmCbellPitch[] = "BellPitch";
|
||||
char SmCbellDuration[] = "BellDuration";
|
||||
char SmCledMask[] ="LedMask";
|
||||
char SmCglobalRepeats[] = "GlobalAutoRepeats";
|
||||
char SmCrepeatDelay[] = "RepeatDelay";
|
||||
char SmCrepeatInterval[] = "RepeatInterval";
|
||||
char SmCautoRepeats[] = "AutoRepeats";
|
||||
char SmCaccelNum[] = "AccelNum";
|
||||
char SmCaccelDenom[] = "AccelDenom";
|
||||
|
||||
@@ -4,7 +4,8 @@ MAINTAINERCLEANFILES = Makefile.in
|
||||
# panes.c is the list of the panes, plain C with its own tests (make check).
|
||||
bin_PROGRAMS = dtsystemsettings
|
||||
|
||||
dtsystemsettings_SOURCES = main.c panes.c panes.h ui.h accounts.c update.c
|
||||
dtsystemsettings_SOURCES = main.c panes.c panes.h ui.h accounts.c update.c \
|
||||
input.c
|
||||
dtsystemsettings_CPPFLAGS = -I$(top_srcdir)/include $(DT_INCDIR) \
|
||||
-I$(top_builddir)/include \
|
||||
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\"
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* input.c -- dtsystemsettings: the keyboard and the mouse
|
||||
*
|
||||
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
||||
*
|
||||
* What CDE's style manager sets for them, in the window itself: key repeat,
|
||||
* its delay and rate, key click; the primary button, the pointer speed, the
|
||||
* double-click time. A change takes effect at once, with Xlib --
|
||||
* XChangeKeyboardControl(3), XkbSetAutoRepeatRate(3), XChangePointerControl(3),
|
||||
* XSetPointerMapping(3) -- and goes to the session manager the way dtstyle
|
||||
* sends it (programs/dtstyle/Protocol.c, SmNewKeyboardSettings and
|
||||
* SmNewPointerSettings): a property on dtsession's window, which dtsession
|
||||
* writes into the session at logout and sets again at the next login
|
||||
* (dtsession/SmSave.c, SmRestore.c; the repeat delay and rate are MCDE's
|
||||
* addition there). The double-click time is a resource, *multiClickTime,
|
||||
* merged into the server's resources with _DtAddToResource(3) as dtstyle does.
|
||||
*
|
||||
* These are settings of the X server for this user's session, not of the
|
||||
* operating system: no McdeSys call is needed.
|
||||
*
|
||||
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/Scale.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Dt/DtP.h>
|
||||
#include <Dt/SessionM.h>
|
||||
#include <Dt/SessionP.h>
|
||||
|
||||
#include "ui.h"
|
||||
|
||||
/* ---- the session manager (dtstyle/Protocol.c) ---------------------------- */
|
||||
|
||||
static Window
|
||||
SmWindow(Display *dpy)
|
||||
{
|
||||
Window w;
|
||||
|
||||
if (_DtGetSmWindow(dpy, RootWindow(dpy, 0), &w) != Success)
|
||||
return None;
|
||||
return w;
|
||||
}
|
||||
|
||||
/* ---- shared ------------------------------------------------------------- */
|
||||
|
||||
static Widget
|
||||
Scale(Widget parent, const char *name, const char *label, int min, int max,
|
||||
int value, XtCallbackProc cb)
|
||||
{
|
||||
Widget w;
|
||||
|
||||
(void) Text(parent, "label", label);
|
||||
w = XtVaCreateManagedWidget(name, xmScaleWidgetClass, parent,
|
||||
XmNorientation, XmHORIZONTAL, XmNminimum, min, XmNmaximum, max,
|
||||
XmNvalue, value < min ? min : value > max ? max : value,
|
||||
XmNshowValue, True, XmNscaleWidth, 320, NULL);
|
||||
XtAddCallback(w, XmNvalueChangedCallback, cb, NULL);
|
||||
return w;
|
||||
}
|
||||
|
||||
static int
|
||||
ScaleValue(Widget w)
|
||||
{
|
||||
int v = 0;
|
||||
|
||||
XmScaleGetValue(w, &v);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* ---- the keyboard ------------------------------------------------------- */
|
||||
|
||||
static Widget kbRepeat, kbDelay, kbRate, kbClick;
|
||||
|
||||
static void
|
||||
KeyboardApply(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
Display *dpy = XtDisplay(kbRepeat);
|
||||
XKeyboardControl kc;
|
||||
PropDtSmKeyboardInfo prop;
|
||||
Window sm;
|
||||
Boolean on = XmToggleButtonGetState(kbRepeat);
|
||||
int rate = ScaleValue(kbRate);
|
||||
|
||||
(void) w;
|
||||
(void) data;
|
||||
(void) call;
|
||||
kc.auto_repeat_mode = on ? AutoRepeatModeOn : AutoRepeatModeOff;
|
||||
kc.key_click_percent = ScaleValue(kbClick);
|
||||
XChangeKeyboardControl(dpy, KBAutoRepeatMode | KBKeyClickPercent, &kc);
|
||||
/* rate: keys a second; XKB takes the interval in milliseconds */
|
||||
(void) XkbSetAutoRepeatRate(dpy, XkbUseCoreKbd,
|
||||
(unsigned int) ScaleValue(kbDelay),
|
||||
(unsigned int) (1000 / (rate > 0 ? rate : 1)));
|
||||
XtSetSensitive(kbDelay, on);
|
||||
XtSetSensitive(kbRate, on);
|
||||
if ((sm = SmWindow(dpy)) != None) {
|
||||
Atom a = XInternAtom(dpy, _XA_DT_SM_KEYBOARD_INFO, False);
|
||||
|
||||
prop.flags = 0;
|
||||
prop.smKeyClickPercent = (unsigned long) kc.key_click_percent;
|
||||
prop.smGlobalAutoRepeat = (unsigned long) kc.auto_repeat_mode;
|
||||
XChangeProperty(dpy, sm, a, a, 32, PropModeReplace,
|
||||
(unsigned char *) &prop, PROP_DT_SM_KEYBOARD_INFO_ELEMENTS);
|
||||
}
|
||||
XFlush(dpy);
|
||||
}
|
||||
|
||||
Widget
|
||||
MakeKeyboard(Widget parent)
|
||||
{
|
||||
Display *dpy = XtDisplay(parent);
|
||||
Widget box = XtVaCreateWidget("keyboard", xmRowColumnWidgetClass, parent,
|
||||
XmNspacing, 6, NULL);
|
||||
XKeyboardState ks;
|
||||
unsigned int delay = 660, interval = 40;
|
||||
Widget field;
|
||||
|
||||
XGetKeyboardControl(dpy, &ks);
|
||||
(void) XkbGetAutoRepeatRate(dpy, XkbUseCoreKbd, &delay, &interval);
|
||||
kbRepeat = XtVaCreateManagedWidget("Keys repeat when held down",
|
||||
xmToggleButtonWidgetClass, box,
|
||||
XmNset, ks.global_auto_repeat == AutoRepeatModeOn, NULL);
|
||||
XtAddCallback(kbRepeat, XmNvalueChangedCallback, KeyboardApply, NULL);
|
||||
kbDelay = Scale(box, "delay", "Delay until repeat (milliseconds):",
|
||||
150, 1000, (int) delay, KeyboardApply);
|
||||
kbRate = Scale(box, "rate", "Repeat rate (keys a second):", 2, 50,
|
||||
interval > 0 ? (int) ((1000 + interval / 2) / interval) : 25,
|
||||
KeyboardApply);
|
||||
kbClick = Scale(box, "click", "Key click volume:", 0, 100,
|
||||
ks.key_click_percent, KeyboardApply);
|
||||
XtSetSensitive(kbDelay, ks.global_auto_repeat == AutoRepeatModeOn);
|
||||
XtSetSensitive(kbRate, ks.global_auto_repeat == AutoRepeatModeOn);
|
||||
(void) Text(box, "label", "Try it here:");
|
||||
field = XtVaCreateManagedWidget("try", xmTextFieldWidgetClass, box,
|
||||
XmNcolumns, 40, NULL);
|
||||
(void) field;
|
||||
return box;
|
||||
}
|
||||
|
||||
/* ---- the mouse ---------------------------------------------------------- */
|
||||
|
||||
#define MAX_BUTTONS 256
|
||||
|
||||
static Widget msLeft, msRight, msSpeed, msThreshold, msDouble;
|
||||
static unsigned char msMap[MAX_BUTTONS];
|
||||
static int msButtons;
|
||||
|
||||
/* "left" or "right" handed: buttons 1 and 3 change places, the others stay */
|
||||
static Boolean
|
||||
LeftHanded(void)
|
||||
{
|
||||
return msButtons >= 3 && msMap[0] == 3 && msMap[2] == 1;
|
||||
}
|
||||
|
||||
static void
|
||||
MouseApply(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
Display *dpy = XtDisplay(msSpeed);
|
||||
char map[4 * MAX_BUTTONS], res[64], prop[4 * MAX_BUTTONS + 128];
|
||||
Boolean left = XmToggleButtonGetState(msLeft);
|
||||
int speed = ScaleValue(msSpeed), threshold = ScaleValue(msThreshold);
|
||||
int dclick = ScaleValue(msDouble), i;
|
||||
size_t at = 0;
|
||||
Window sm;
|
||||
|
||||
(void) data;
|
||||
/* the radio pair: the one switched off does nothing */
|
||||
if (w != NULL && call != NULL && XmIsToggleButton(w) &&
|
||||
!((XmToggleButtonCallbackStruct *) call)->set)
|
||||
return;
|
||||
if (msButtons >= 3 && left != LeftHanded()) {
|
||||
unsigned char t = msMap[0];
|
||||
|
||||
msMap[0] = msMap[2];
|
||||
msMap[2] = t;
|
||||
/* the server says busy while a button is down; once again */
|
||||
if (XSetPointerMapping(dpy, msMap, msButtons) != MappingSuccess)
|
||||
(void) XSetPointerMapping(dpy, msMap, msButtons);
|
||||
}
|
||||
XChangePointerControl(dpy, True, True, speed, 1, threshold);
|
||||
/* dtstyle's resource line (programs/dtstyle/Mouse.c,
|
||||
* multiClickTimeString) */
|
||||
snprintf(res, sizeof res, "*multiClickTime:%d\n", dclick);
|
||||
_DtAddToResource(dpy, res);
|
||||
for (i = 0; i < msButtons && at + 8 < sizeof map; i++)
|
||||
at += (size_t) snprintf(map + at, sizeof map - at, "%s%d",
|
||||
i > 0 ? "_" : "", msMap[i]);
|
||||
map[at] = '\0';
|
||||
/* what dtsession reads (dtsession/SmSave.c): "BUTTONS MAP ACCEL
|
||||
* THRESHOLD RESOURCE", the map joined by "_" */
|
||||
snprintf(prop, sizeof prop, "%d %s %d %d %s", msButtons, map, speed,
|
||||
threshold, res);
|
||||
if ((sm = SmWindow(dpy)) != None)
|
||||
XChangeProperty(dpy, sm,
|
||||
XInternAtom(dpy, _XA_DT_SM_POINTER_INFO, False), XA_STRING,
|
||||
8, PropModeReplace, (unsigned char *) prop,
|
||||
(int) strlen(prop));
|
||||
XFlush(dpy);
|
||||
}
|
||||
|
||||
Widget
|
||||
MakeMouse(Widget parent)
|
||||
{
|
||||
Display *dpy = XtDisplay(parent);
|
||||
Widget box = XtVaCreateWidget("mouse", xmRowColumnWidgetClass, parent,
|
||||
XmNspacing, 6, NULL);
|
||||
Widget radio;
|
||||
int num = 2, den = 1, thr = 4, dclick = XtGetMultiClickTime(dpy);
|
||||
|
||||
msButtons = XGetPointerMapping(dpy, msMap, MAX_BUTTONS);
|
||||
XGetPointerControl(dpy, &num, &den, &thr);
|
||||
(void) Text(box, "label", "Primary button:");
|
||||
radio = XtVaCreateManagedWidget("hand", xmRowColumnWidgetClass, box,
|
||||
XmNorientation, XmHORIZONTAL, XmNradioBehavior, True, NULL);
|
||||
msRight = XtVaCreateManagedWidget("Left (right-handed)",
|
||||
xmToggleButtonWidgetClass, radio, XmNset, !LeftHanded(), NULL);
|
||||
msLeft = XtVaCreateManagedWidget("Right (left-handed)",
|
||||
xmToggleButtonWidgetClass, radio, XmNset, LeftHanded(), NULL);
|
||||
XtAddCallback(msRight, XmNvalueChangedCallback, MouseApply, NULL);
|
||||
XtAddCallback(msLeft, XmNvalueChangedCallback, MouseApply, NULL);
|
||||
if (msButtons < 3)
|
||||
XtSetSensitive(radio, False);
|
||||
msSpeed = Scale(box, "speed", "Pointer speed (acceleration):", 1, 10,
|
||||
den > 0 ? num / den : num, MouseApply);
|
||||
msThreshold = Scale(box, "threshold",
|
||||
"Speeds up after (pixels):", 1, 20, thr, MouseApply);
|
||||
msDouble = Scale(box, "double", "Double-click time (milliseconds):",
|
||||
100, 900, dclick, MouseApply);
|
||||
return box;
|
||||
}
|
||||
@@ -523,6 +523,10 @@ ShowPane(const Pane *p)
|
||||
w = MakeAccounts(paneArea);
|
||||
else if (strcmp(p->id, "update") == 0)
|
||||
w = MakeUpdate(paneArea);
|
||||
else if (strcmp(p->id, "keyboard") == 0)
|
||||
w = MakeKeyboard(paneArea);
|
||||
else if (strcmp(p->id, "mouse") == 0)
|
||||
w = MakeMouse(paneArea);
|
||||
if (w == NULL)
|
||||
return;
|
||||
current = w;
|
||||
|
||||
@@ -32,10 +32,8 @@ const Pane panes[] = {
|
||||
PANE_COMMAND, "dtstyle" },
|
||||
|
||||
{ "sound", "Sound", CAT_HARDWARE, "Dtaudio.m.pm", PANE_OWN, NULL },
|
||||
{ "keyboard", "Keyboard", CAT_HARDWARE, "DtKeybd.pm", PANE_COMMAND,
|
||||
"dtstyle" },
|
||||
{ "mouse", "Mouse", CAT_HARDWARE, "DtMouse.pm", PANE_COMMAND,
|
||||
"dtstyle" },
|
||||
{ "keyboard", "Keyboard", CAT_HARDWARE, "DtKeybd.pm", PANE_OWN, NULL },
|
||||
{ "mouse", "Mouse", CAT_HARDWARE, "DtMouse.pm", PANE_OWN, NULL },
|
||||
{ "printers", "Printers", CAT_HARDWARE, "Dtprint.m.pm", PANE_COMMAND,
|
||||
"dtprintinfo -all" },
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ void AsRoot(const char *title, const char *command, char *buf, size_t len);
|
||||
/* the panes in accounts.c and update.c */
|
||||
Widget MakeAccounts(Widget parent);
|
||||
Widget MakeUpdate(Widget parent);
|
||||
/* the panes in input.c */
|
||||
Widget MakeKeyboard(Widget parent);
|
||||
Widget MakeMouse(Widget parent);
|
||||
/* dtsystemsettings -apply-update: what the terminal of "Update Now" runs */
|
||||
int ApplyUpdate(void);
|
||||
|
||||
|
||||
Reference in new issue
Block a user