XQuartz: Add a scroll_in_device_direction preference

This preference allows users to override the related option in Mac OS X's
Mouse/Trackpad preferences.  This effectively lets the user determine
which "context" all of X11 fits into for context-based scrolling until
such API exists within X11 itself to pass along to X11 clients.

This is applicable to Mav OS X 10.7+
Signed-off-by: Jeremy Huddleston Sequoia's avatarJeremy Huddleston <jeremyhu@apple.com>
parent ec95a9c8
......@@ -104,6 +104,9 @@ void X11ApplicationMain(int argc, char **argv, char **envp);
#define PREFS_FFM "wm_ffm"
#define PREFS_FOCUS_ON_NEW_WINDOW "wm_focus_on_new_window"
#define PREFS_SCROLL_IN_DEV_DIRECTION "scroll_in_device_direction"
extern Bool XQuartzScrollInDeviceDirection;
#define PREFS_SYNC_PB "sync_pasteboard"
#define PREFS_SYNC_PB_TO_CLIPBOARD "sync_pasteboard_to_clipboard"
#define PREFS_SYNC_PB_TO_PRIMARY "sync_pasteboard_to_primary"
......
......@@ -79,6 +79,11 @@ static TISInputSourceRef last_key_layout;
static KeyboardLayoutRef last_key_layout;
#endif
/* This preference is only tested on Lion or later as it's not relevant to
* earlier OS versions.
*/
Bool XQuartzScrollInDeviceDirection = FALSE;
extern int darwinFakeButtons;
/* Store the mouse location while in the background, and update X11's pointer
......@@ -787,6 +792,9 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
noTestExtensions = ![self prefs_get_boolean:@PREFS_TEST_EXTENSIONS
default:FALSE];
XQuartzScrollInDeviceDirection = [self prefs_get_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION
default:XQuartzScrollInDeviceDirection];
#if XQUARTZ_SPARKLE
NSURL *url = [self prefs_copy_url:@PREFS_UPDATE_FEED default:nil];
......@@ -1339,20 +1347,30 @@ static const char *untrusted_str(NSEvent *e) {
break;
case NSScrollWheel:
{
float deltaX = [e deltaX];
float deltaY = [e deltaY];
#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
/* If we're in the background, we need to send a MotionNotify event
* first, since we aren't getting them on background mouse motion
*/
if(!XQuartzServerVisible && noTestExtensions) {
bgMouseLocationUpdated = FALSE;
DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
location.y, pressure, tilt.x, tilt.y);
}
/* If we're in the background, we need to send a MotionNotify event
* first, since we aren't getting them on background mouse motion
*/
if(!XQuartzServerVisible && noTestExtensions) {
bgMouseLocationUpdated = FALSE;
DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
location.y, pressure, tilt.x, tilt.y);
}
#endif
DarwinSendScrollEvents([e deltaX], [e deltaY], location.x, location.y,
pressure, tilt.x, tilt.y);
break;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
// TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
if(NSAppKitVersionNumber >= 1117 && XQuartzScrollInDeviceDirection && [e isDirectionInvertedFromDevice]) {
deltaX *= -1;
deltaY *= -1;
}
#endif
DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
pressure, tilt.x, tilt.y);
break;
}
case NSKeyDown: case NSKeyUp:
{
/* XKB clobbers our keymap at startup, so we need to force it on the first keypress.
......
......@@ -83,6 +83,9 @@ This option defaults to false and is provided only "for experts." It updates th
.TP 8
.B defaults write __bundle_id_prefix__.X11 enable_test_extensions -boolean true
This option defaults to false and is only accessible through the command line. Enable this option to turn on the DEC-XTRAP, RECORD, and XTEST extensions in the server.
.TP 8
.B defaults write __laucnd_id_prefix__.X11 scroll_in_device_direction -boolean true
This option defaults to false. Enable this option to ensure that X11 scroll events are always in the direction of the device. This overrides the related option in the Mouse/Trackpad section of System Preferences.
.SH OPTIONS
.PP
In addition to the normal server options described in the \fIXserver(1)\fP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment