summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-02-08 12:26:35 -0800
committerJeremy Huddleston <jeremyhu@apple.com>2011-02-27 15:46:22 -0800
commit968652983f8e6ae6889b48e15f4098ff6ad4a15a (patch)
treef302e25d0277e8245d657fc7c016a17493a9ce22
parent13578b852b7631f99cf1fd5e2e5469edc5aae369 (diff)
XQuartz: RandR: Provide an alert box when entering a RandR mode for the first time.
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--hw/xquartz/X11Application.h3
-rw-r--r--hw/xquartz/X11Application.m29
-rw-r--r--hw/xquartz/bundle/Resources/English.lproj/Localizable.stringsbin2698 -> 4410 bytes
-rw-r--r--hw/xquartz/quartzRandR.c4
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 b855c8358..3521517a2 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
index 03415026e..bf2089ca1 100644
--- a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings
+++ b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings
Binary files differ
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",