diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2011-02-08 12:26:35 -0800 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-03-03 18:16:07 -0800 |
commit | 3be0b136fad8aafe557cc0ce354e705f0c04245a (patch) | |
tree | edad7f3a91f36f105196598aa46065d497d7d8ee | |
parent | ceaa2f438d44b23a8958c42de4f666048aedabb1 (diff) |
XQuartz: RandR: Provide an alert box when entering a RandR mode for the first time.
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit 968652983f8e6ae6889b48e15f4098ff6ad4a15a)
-rw-r--r-- | hw/xquartz/X11Application.h | 3 | ||||
-rw-r--r-- | hw/xquartz/X11Application.m | 29 | ||||
-rw-r--r-- | hw/xquartz/bundle/Resources/English.lproj/Localizable.strings | bin | 2698 -> 4410 bytes | |||
-rw-r--r-- | hw/xquartz/quartzRandR.c | 4 |
4 files changed, 36 insertions, 0 deletions
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h index b3ad19b53..256ff187a 100644 --- a/hw/xquartz/X11Application.h +++ b/hw/xquartz/X11Application.h @@ -73,6 +73,8 @@ void X11ApplicationServerReady (void); void X11ApplicationShowHideMenubar (int state); void X11ApplicationLaunchClient (const char *cmd); +Bool X11ApplicationCanEnterRandR (void); + void X11ApplicationMain(int argc, char **argv, char **envp); #define PREFS_APPSMENU "apps_menu" @@ -86,6 +88,7 @@ void X11ApplicationMain(int argc, char **argv, char **envp); #define PREFS_NO_TCP "nolisten_tcp" #define PREFS_DONE_XINIT_CHECK "done_xinit_check" #define PREFS_NO_QUIT_ALERT "no_quit_alert" +#define PREFS_NO_RANDR_ALERT "no_randr_alert" #define PREFS_OPTION_SENDS_ALT "option_sends_alt" #define PREFS_FAKE_BUTTON2 "fake_button2" #define PREFS_FAKE_BUTTON3 "fake_button3" diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 4a52a1230..13a6c7aaa 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -883,6 +883,35 @@ void X11ApplicationLaunchClient (const char *cmd) { [string release]; } +/* This is a special function in that it is run from the *SERVER* thread and + * not the AppKit thread. We want to block entering a screen-capturing RandR + * mode until we notify the user about how to get out if the X11 client crashes. + */ +Bool X11ApplicationCanEnterRandR(void) { + NSString *title, *msg; + + if([X11App prefs_get_boolean:@PREFS_NO_RANDR_ALERT default:NO] || XQuartzShieldingWindowLevel != 0) + return TRUE; + + title = NSLocalizedString(@"Enter RandR mode?", @"Dialog title when switching to RandR"); + msg = NSLocalizedString(@"An application has requested X11 to change the resolution of your display. X11 will restore the display to its previous state when the requesting application requests to return to the previous state. Alternatively, you can use the ⌥⌘A key sequence to force X11 to return to the previous state.", + @"Dialog when switching to RandR"); + + if(!XQuartzIsRootless) + QuartzShowFullscreen(FALSE); + + switch(NSRunAlertPanel(title, msg, NSLocalizedString(@"Allow", @""), NSLocalizedString (@"Cancel", @""), NSLocalizedString (@"Always Allow", @""))) { + case NSAlertOtherReturn: + [X11App prefs_set_boolean:@PREFS_NO_RANDR_ALERT value:YES]; + [X11App prefs_synchronize]; + case NSAlertDefaultReturn: + return YES; + + default: + return NO; + } +} + static void check_xinitrc (void) { char *tem, buf[1024]; NSString *msg; diff --git a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings Binary files differindex 03415026e..bf2089ca1 100644 --- a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings +++ b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c index 57e975550..ede7969c7 100644 --- a/hw/xquartz/quartzRandR.c +++ b/hw/xquartz/quartzRandR.c @@ -40,6 +40,8 @@ #include "quartz.h" #include "darwin.h" +#include "X11Application.h" + #include <AvailabilityMacros.h> #include <X11/extensions/randr.h> @@ -349,6 +351,8 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS); if(XQuartzShieldingWindowLevel == 0 && captureDisplay) { + if(!X11ApplicationCanEnterRandR()) + return FALSE; CGCaptureAllDisplays(); XQuartzShieldingWindowLevel = CGShieldingWindowLevel(); // 2147483630 DEBUG_LOG("Display captured. ShieldWindowID: %u, Shield level: %d\n", |