XQuartz: Some motion made towards supporting fullscreen.

(cherry picked from commit 99be3d68b64059caada739a373e5e01844c776e0)
This commit is contained in:
Jeremy Huddleston 2008-10-08 18:39:41 -07:00
parent dc166bf642
commit d13c3cbd43
10 changed files with 257 additions and 50 deletions

View File

@ -81,6 +81,7 @@ extern int quartzHasRoot, quartzEnableRootless;
#define PREFS_FAKEBUTTONS "enable_fake_buttons" #define PREFS_FAKEBUTTONS "enable_fake_buttons"
#define PREFS_SYSBEEP "enable_system_beep" #define PREFS_SYSBEEP "enable_system_beep"
#define PREFS_KEYEQUIVS "enable_key_equivalents" #define PREFS_KEYEQUIVS "enable_key_equivalents"
#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
#define PREFS_SYNC_KEYMAP "sync_keymap" #define PREFS_SYNC_KEYMAP "sync_keymap"
#define PREFS_DEPTH "depth" #define PREFS_DEPTH "depth"
#define PREFS_NO_AUTH "no_auth" #define PREFS_NO_AUTH "no_auth"

View File

@ -625,16 +625,12 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
default:quartzUseSysBeep]; default:quartzUseSysBeep];
#if 0
// TODO: Add fullscreen support quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
//quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS default:quartzEnableRootless];
// default:quartzEnableRootless];
#ifdef DARWIN_DDX_MISSING
quartzFullscreenDisableHotkeys = ![self prefs_get_boolean: quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
@PREFS_FULLSCREEN_HOTKEYS default: @PREFS_FULLSCREEN_HOTKEYS default:
!quartzFullscreenDisableHotkeys]; !quartzFullscreenDisableHotkeys];
quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
default:quartzXpluginOptions];
#endif #endif
darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
default:darwinFakeButtons]; default:darwinFakeButtons];

View File

@ -596,9 +596,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{ {
int value = ![enable_fullscreen intValue]; int value = ![enable_fullscreen intValue];
#ifdef DARWIN_DDX_MISSING
DarwinSendDDXEvent(kXquartzSetRootless, 1, value); DarwinSendDDXEvent(kXquartzSetRootless, 1, value);
#endif
[NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value]; [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
[NSApp prefs_synchronize]; [NSApp prefs_synchronize];
@ -606,9 +604,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (IBAction) toggle_fullscreen:sender - (IBAction) toggle_fullscreen:sender
{ {
#ifdef DARWIN_DDX_MISSING
DarwinSendDDXEvent(kXquartzToggleFullscreen, 0); DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
#endif
} }
- (void) set_can_quit:(OSX_BOOL)state - (void) set_can_quit:(OSX_BOOL)state

View File

@ -231,27 +231,20 @@ static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, in
case kXquartzToggleFullscreen: case kXquartzToggleFullscreen:
DEBUG_LOG("kXquartzToggleFullscreen\n"); DEBUG_LOG("kXquartzToggleFullscreen\n");
#ifdef DARWIN_DDX_MISSING
if (quartzEnableRootless) if (quartzEnableRootless)
QuartzSetFullscreen(!quartzHasRoot); QuartzSetFullscreen(!quartzHasRoot);
else if (quartzHasRoot) else if (quartzHasRoot)
QuartzHide(); QuartzHide();
else else
QuartzShow(); QuartzShow(xe[i].u.keyButtonPointer.rootX,
#else xe[i].u.keyButtonPointer.rootY);
// ErrorF("kXquartzToggleFullscreen not implemented\n");
#endif
break; break;
case kXquartzSetRootless: case kXquartzSetRootless:
DEBUG_LOG("kXquartzSetRootless\n"); DEBUG_LOG("kXquartzSetRootless\n");
#ifdef DARWIN_DDX_MISSING
QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0); QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0);
if (!quartzEnableRootless && !quartzHasRoot) if (!quartzEnableRootless && !quartzHasRoot)
QuartzHide(); QuartzHide();
#else
// ErrorF("kXquartzSetRootless not implemented\n");
#endif
break; break;
case kXquartzSetRootClip: case kXquartzSetRootClip:

View File

@ -61,6 +61,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <IOKit/pwr_mgt/IOPMLib.h> #include <IOKit/pwr_mgt/IOPMLib.h>
#include <rootlessCommon.h>
#include <Xplugin.h>
#define FAKE_RANDR 1 #define FAKE_RANDR 1
// Shared global variables for Quartz modes // Shared global variables for Quartz modes
@ -76,6 +79,7 @@ DevPrivateKey quartzScreenKey = &quartzScreenKeyIndex;
int aquaMenuBarHeight = 0; int aquaMenuBarHeight = 0;
QuartzModeProcsPtr quartzProcs = NULL; QuartzModeProcsPtr quartzProcs = NULL;
const char *quartzOpenGLBundle = NULL; const char *quartzOpenGLBundle = NULL;
int quartzFullscreenDisableHotkeys = TRUE;
#if defined(RANDR) && !defined(FAKE_RANDR) #if defined(RANDR) && !defined(FAKE_RANDR)
Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) { Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
@ -228,18 +232,12 @@ RREditConnectionInfo (ScreenPtr pScreen)
} }
#endif #endif
/* static void QuartzUpdateScreens(void) {
* QuartzDisplayChangeHandler
* Adjust for screen arrangement changes.
*/
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
{
ScreenPtr pScreen; ScreenPtr pScreen;
WindowPtr pRoot; WindowPtr pRoot;
int x, y, width, height, sx, sy; int x, y, width, height, sx, sy;
xEvent e; xEvent e;
DEBUG_LOG("QuartzDisplayChangedHandler(): noPseudoramiXExtension=%d, screenInfo.numScreens=%d\n", noPseudoramiXExtension, screenInfo.numScreens);
if (noPseudoramiXExtension || screenInfo.numScreens != 1) if (noPseudoramiXExtension || screenInfo.numScreens != 1)
{ {
/* FIXME: if not using Xinerama, we have multiple screens, and /* FIXME: if not using Xinerama, we have multiple screens, and
@ -278,7 +276,6 @@ void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
AppleWMSetScreenOrigin(pRoot); AppleWMSetScreenOrigin(pRoot);
pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL); pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
// QuartzIgnoreNextWarpCursor();
DefineInitialRootWindow(pRoot); DefineInitialRootWindow(pRoot);
/* Send an event for the root reconfigure */ /* Send an event for the root reconfigure */
@ -298,6 +295,65 @@ void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
#endif #endif
} }
/*
* QuartzDisplayChangeHandler
* Adjust for screen arrangement changes.
*/
void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
QuartzUpdateScreens();
}
void QuartzSetFullscreen(Bool state) {
if(quartzHasRoot == state)
return;
quartzHasRoot = state;
xp_disable_update ();
if (!quartzHasRoot && !quartzEnableRootless)
RootlessHideAllWindows();
RootlessUpdateRooted(quartzHasRoot);
if (quartzHasRoot && !quartzEnableRootless)
RootlessShowAllWindows ();
/* Only update screen info when something is visible. Avoids the wm
* moving the windows out from under the menubar when it shouldn't
*/
if (quartzHasRoot || quartzEnableRootless)
QuartzUpdateScreens();
/* Somehow the menubar manages to interfere with our event stream
* in fullscreen mode, even though it's not visible.
*/
X11ApplicationShowHideMenubar(!quartzHasRoot);
xp_reenable_update ();
if (quartzFullscreenDisableHotkeys)
xp_disable_hot_keys(quartzHasRoot);
}
void QuartzSetRootless(Bool state) {
if(quartzEnableRootless == state)
return;
quartzEnableRootless = state;
if (!quartzEnableRootless && !quartzHasRoot) {
xp_disable_update();
RootlessHideAllWindows();
xp_reenable_update();
} else if (quartzEnableRootless && !quartzHasRoot) {
xp_disable_update();
RootlessShowAllWindows();
QuartzUpdateScreens();
xp_reenable_update();
}
}
/* /*
* QuartzShow * QuartzShow
@ -311,14 +367,18 @@ void QuartzShow(
{ {
int i; int i;
if (!quartzServerVisible) { if (quartzServerVisible)
return;
quartzServerVisible = TRUE; quartzServerVisible = TRUE;
for (i = 0; i < screenInfo.numScreens; i++) { for (i = 0; i < screenInfo.numScreens; i++) {
if (screenInfo.screens[i]) { if (screenInfo.screens[i]) {
quartzProcs->ResumeScreen(screenInfo.screens[i], x, y); quartzProcs->ResumeScreen(screenInfo.screens[i], x, y);
} }
} }
}
if (!quartzEnableRootless)
QuartzSetFullscreen(TRUE);
} }
@ -339,6 +399,8 @@ void QuartzHide(void)
} }
} }
} }
QuartzSetFullscreen(FALSE);
quartzServerVisible = FALSE; quartzServerVisible = FALSE;
} }

View File

@ -137,4 +137,7 @@ void QuartzShow(int x, int y); // (x, y) = cursor loc
void QuartzHide(void); void QuartzHide(void);
void QuartzSetRootClip(BOOL enable); void QuartzSetRootClip(BOOL enable);
void QuartzSpaceChanged(uint32_t space_id); void QuartzSpaceChanged(uint32_t space_id);
void QuartzSetFullscreen(Bool state);
void QuartzSetRootless(Bool state);
#endif #endif

View File

@ -60,6 +60,7 @@ extern int quartzUseSysBeep;
extern int focusOnNewWindow; extern int focusOnNewWindow;
extern int quartzUseAGL; extern int quartzUseAGL;
extern int quartzEnableKeyEquivalents; extern int quartzEnableKeyEquivalents;
extern int quartzFullscreenDisableHotkeys;
// Other shared data // Other shared data
extern int quartzServerVisible; extern int quartzServerVisible;

View File

@ -273,7 +273,8 @@ Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
void RootlessFlushWindowColormap (WindowPtr pWin); void RootlessFlushWindowColormap (WindowPtr pWin);
void RootlessFlushScreenColormaps (ScreenPtr pScreen); void RootlessFlushScreenColormaps (ScreenPtr pScreen);
RootlessColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors); // xp_error
int RootlessColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors);
// Move a window to its proper location on the screen. // Move a window to its proper location on the screen.
void RootlessRepositionWindow(WindowPtr pWin); void RootlessRepositionWindow(WindowPtr pWin);
@ -281,4 +282,13 @@ void RootlessRepositionWindow(WindowPtr pWin);
// Move the window to it's correct place in the physical stacking order. // Move the window to it's correct place in the physical stacking order.
void RootlessReorderWindow(WindowPtr pWin); void RootlessReorderWindow(WindowPtr pWin);
void RootlessScreenExpose (ScreenPtr pScreen);
void RootlessHideAllWindows (void);
void RootlessShowAllWindows (void);
void RootlessUpdateRooted (Bool state);
void RootlessEnableRoot (ScreenPtr pScreen);
void RootlessDisableRoot (ScreenPtr pScreen);
#endif /* _ROOTLESSCOMMON_H */ #endif /* _ROOTLESSCOMMON_H */

View File

@ -475,6 +475,34 @@ RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
return result; return result;
} }
expose_1 (WindowPtr pWin)
{
WindowPtr pChild;
if (!pWin->realized)
return;
(*pWin->drawable.pScreen->PaintWindowBackground) (pWin, &pWin->borderClip,
PW_BACKGROUND);
/* FIXME: comments in windowstr.h indicate that borderClip doesn't
include subwindow visibility. But I'm not so sure.. so we may
be exposing too much.. */
miSendExposures (pWin, &pWin->borderClip,
pWin->drawable.x, pWin->drawable.y);
for (pChild = pWin->firstChild; pChild != NULL; pChild = pChild->nextSib)
expose_1 (pChild);
}
void
RootlessScreenExpose (ScreenPtr pScreen)
{
expose_1 (WindowTable[pScreen->myNum]);
}
ColormapPtr ColormapPtr
RootlessGetColormap (ScreenPtr pScreen) RootlessGetColormap (ScreenPtr pScreen)
{ {
@ -718,3 +746,18 @@ Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
return TRUE; return TRUE;
} }
void RootlessUpdateRooted (Bool state) {
int i;
if (!state)
{
for (i = 0; i < screenInfo.numScreens; i++)
RootlessDisableRoot (screenInfo.screens[i]);
}
else
{
for (i = 0; i < screenInfo.numScreens; i++)
RootlessEnableRoot (screenInfo.screens[i]);
}
}

View File

@ -1581,3 +1581,105 @@ RootlessOrderAllWindows (void)
} }
RL_DEBUG_MSG("RootlessOrderAllWindows() done"); RL_DEBUG_MSG("RootlessOrderAllWindows() done");
} }
void
RootlessEnableRoot (ScreenPtr pScreen)
{
WindowPtr pRoot;
pRoot = WindowTable[pScreen->myNum];
RootlessEnsureFrame (pRoot);
(*pScreen->ClearToBackground) (pRoot, 0, 0, 0, 0, TRUE);
RootlessReorderWindow (pRoot);
}
void
RootlessDisableRoot (ScreenPtr pScreen)
{
WindowPtr pRoot;
RootlessWindowRec *winRec;
pRoot = WindowTable[pScreen->myNum];
winRec = WINREC (pRoot);
if (winRec != NULL)
{
RootlessDestroyFrame (pRoot, winRec);
DeleteProperty (pRoot, xa_native_window_id ());
}
}
void
RootlessHideAllWindows (void)
{
int i;
ScreenPtr pScreen;
WindowPtr pWin;
RootlessWindowRec *winRec;
xp_window_changes wc;
if (windows_hidden)
return;
windows_hidden = TRUE;
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
pWin = WindowTable[i];
if (pScreen == NULL || pWin == NULL)
continue;
for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
{
if (!pWin->realized)
continue;
RootlessStopDrawing (pWin, FALSE);
winRec = WINREC (pWin);
if (winRec != NULL)
{
wc.stack_mode = XP_UNMAPPED;
wc.sibling = 0;
configure_window ((xp_window_id)winRec->wid, XP_STACKING, &wc);
}
}
}
}
void
RootlessShowAllWindows (void)
{
int i;
ScreenPtr pScreen;
WindowPtr pWin;
RootlessWindowRec *winRec;
if (!windows_hidden)
return;
windows_hidden = FALSE;
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
pWin = WindowTable[i];
if (pScreen == NULL || pWin == NULL)
continue;
for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
{
if (!pWin->realized)
continue;
winRec = RootlessEnsureFrame (pWin);
if (winRec == NULL)
continue;
RootlessReorderWindow (pWin);
}
RootlessScreenExpose (pScreen);
}
}