summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-07-19 20:00:27 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-07-19 20:00:27 -0700
commitac43984215faf464fd48bd006cac1c6539603cea (patch)
tree38245e517de26bbd123213e4ee3417f7bc1efb45 /hw
parentec95a9c829b8e37529aa828c05fbaabc45cffe42 (diff)
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 <jeremyhu@apple.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/xquartz/X11Application.h3
-rw-r--r--hw/xquartz/X11Application.m42
-rw-r--r--hw/xquartz/man/Xquartz.man3
3 files changed, 36 insertions, 12 deletions
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 619f32f7a..baee29d4c 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -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"
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 320bca179..8a03fbe29 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -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.
diff --git a/hw/xquartz/man/Xquartz.man b/hw/xquartz/man/Xquartz.man
index aea56c943..0ea6e6eb8 100644
--- a/hw/xquartz/man/Xquartz.man
+++ b/hw/xquartz/man/Xquartz.man
@@ -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