minor style tweaks
This commit is contained in:
@@ -50,9 +50,9 @@ LowLevelWindow_X11::~LowLevelWindow_X11()
|
|||||||
// Reset the display
|
// Reset the display
|
||||||
if( !m_bWasWindowed )
|
if( !m_bWasWindowed )
|
||||||
{
|
{
|
||||||
XRRScreenConfiguration *screenConfig = XRRGetScreenInfo( X11Helper::Dpy, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ) );
|
XRRScreenConfiguration *pScreenConfig = XRRGetScreenInfo( X11Helper::Dpy, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ) );
|
||||||
XRRSetScreenConfig( X11Helper::Dpy, screenConfig, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ), 0, 1, CurrentTime );
|
XRRSetScreenConfig( X11Helper::Dpy, pScreenConfig, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ), 0, 1, CurrentTime );
|
||||||
XRRFreeScreenConfigInfo( screenConfig );
|
XRRFreeScreenConfigInfo( pScreenConfig );
|
||||||
|
|
||||||
XUngrabKeyboard( X11Helper::Dpy, CurrentTime );
|
XUngrabKeyboard( X11Helper::Dpy, CurrentTime );
|
||||||
}
|
}
|
||||||
@@ -121,9 +121,7 @@ CString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
XVisualInfo *xvi = glXChooseVisual( X11Helper::Dpy, DefaultScreen(X11Helper::Dpy), visAttribs );
|
XVisualInfo *xvi = glXChooseVisual( X11Helper::Dpy, DefaultScreen(X11Helper::Dpy), visAttribs );
|
||||||
|
|
||||||
if( xvi == NULL )
|
if( xvi == NULL )
|
||||||
{
|
|
||||||
return "No visual available for that depth.";
|
return "No visual available for that depth.";
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable StructureNotifyMask, so we receive a MapNotify for the following XMapWindow. */
|
/* Enable StructureNotifyMask, so we receive a MapNotify for the following XMapWindow. */
|
||||||
X11Helper::OpenMask( StructureNotifyMask );
|
X11Helper::OpenMask( StructureNotifyMask );
|
||||||
@@ -131,9 +129,8 @@ CString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
// I get strange behavior if I add override redirect after creating the window.
|
// I get strange behavior if I add override redirect after creating the window.
|
||||||
// So, let's recreate the window when changing that state.
|
// So, let's recreate the window when changing that state.
|
||||||
if( !X11Helper::MakeWindow(xvi->screen, xvi->depth, xvi->visual, p.width, p.height, !p.windowed) )
|
if( !X11Helper::MakeWindow(xvi->screen, xvi->depth, xvi->visual, p.width, p.height, !p.windowed) )
|
||||||
{
|
|
||||||
return "Failed to create the window.";
|
return "Failed to create the window.";
|
||||||
}
|
|
||||||
m_bWindowIsOpen = true;
|
m_bWindowIsOpen = true;
|
||||||
|
|
||||||
char *szWindowTitle = const_cast<char *>( p.sWindowTitle.c_str() );
|
char *szWindowTitle = const_cast<char *>( p.sWindowTitle.c_str() );
|
||||||
@@ -151,7 +148,7 @@ CString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
// events. Do this by grabbing all events, remembering
|
// events. Do this by grabbing all events, remembering
|
||||||
// uninteresting events, and putting them back on the queue
|
// uninteresting events, and putting them back on the queue
|
||||||
// after MapNotify arrives.
|
// after MapNotify arrives.
|
||||||
while(true)
|
while(1)
|
||||||
{
|
{
|
||||||
XNextEvent( X11Helper::Dpy, &ev );
|
XNextEvent( X11Helper::Dpy, &ev );
|
||||||
if( ev.type == MapNotify )
|
if( ev.type == MapNotify )
|
||||||
@@ -174,37 +171,35 @@ CString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
// We're remodeling the existing window, and not touching the
|
// We're remodeling the existing window, and not touching the
|
||||||
// context.
|
// context.
|
||||||
bNewDeviceOut = false;
|
bNewDeviceOut = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRScreenConfiguration *screenConfig = XRRGetScreenInfo( X11Helper::Dpy, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ) );
|
XRRScreenConfiguration *pScreenConfig = XRRGetScreenInfo( X11Helper::Dpy, RootWindow( X11Helper::Dpy, DefaultScreen(X11Helper::Dpy) ) );
|
||||||
|
|
||||||
if( !p.windowed )
|
if( !p.windowed )
|
||||||
{
|
{
|
||||||
// Find a matching mode.
|
// Find a matching mode.
|
||||||
int sizesXct;
|
int iSizesXct;
|
||||||
XRRScreenSize *sizesX = XRRSizes( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ), &sizesXct );
|
XRRScreenSize *pSizesX = XRRSizes( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ), &iSizesXct );
|
||||||
ASSERT_M( sizesXct != 0, "Couldn't get resolution list from X server" );
|
ASSERT_M( iSizesXct != 0, "Couldn't get resolution list from X server" );
|
||||||
|
|
||||||
int sizeMatch = -1;
|
int iSizeMatch = -1;
|
||||||
int i = 0;
|
|
||||||
while(i < sizesXct)
|
for( int i = 0; i < iSizesXct; ++i )
|
||||||
{
|
{
|
||||||
if(sizesX[i].width == p.width && sizesX[i].height == p.height)
|
if( pSizesX[i].width == p.width && pSizesX[i].height == p.height )
|
||||||
{
|
{
|
||||||
sizeMatch = i;
|
iSizeMatch = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set this mode.
|
// Set this mode.
|
||||||
// XXX: This doesn't handle if the config has changed since we queried it (see man Xrandr)
|
// XXX: This doesn't handle if the config has changed since we queried it (see man Xrandr)
|
||||||
XRRSetScreenConfig( X11Helper::Dpy, screenConfig, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ), sizeMatch, 1, CurrentTime );
|
XRRSetScreenConfig( X11Helper::Dpy, pScreenConfig, RootWindow( X11Helper::Dpy, DefaultScreen(X11Helper::Dpy) ), iSizeMatch, 1, CurrentTime );
|
||||||
|
|
||||||
// Move the window to the corner that the screen focuses in on.
|
// Move the window to the corner that the screen focuses in on.
|
||||||
XMoveWindow( X11Helper::Dpy, X11Helper::Win, 0, 0 );
|
XMoveWindow( X11Helper::Dpy, X11Helper::Win, 0, 0 );
|
||||||
|
|
||||||
|
|
||||||
XRaiseWindow( X11Helper::Dpy, X11Helper::Win );
|
XRaiseWindow( X11Helper::Dpy, X11Helper::Win );
|
||||||
|
|
||||||
if( m_bWasWindowed )
|
if( m_bWasWindowed )
|
||||||
@@ -219,7 +214,7 @@ CString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
{
|
{
|
||||||
if( !m_bWasWindowed )
|
if( !m_bWasWindowed )
|
||||||
{
|
{
|
||||||
XRRSetScreenConfig( X11Helper::Dpy, screenConfig, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ), 0, 1, CurrentTime );
|
XRRSetScreenConfig( X11Helper::Dpy, pScreenConfig, RootWindow( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ) ), 0, 1, CurrentTime );
|
||||||
// In windowed mode, we actually want the WM to function normally.
|
// In windowed mode, we actually want the WM to function normally.
|
||||||
// Release any previous grab.
|
// Release any previous grab.
|
||||||
XUngrabKeyboard( X11Helper::Dpy, CurrentTime );
|
XUngrabKeyboard( X11Helper::Dpy, CurrentTime );
|
||||||
@@ -227,7 +222,7 @@ CString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo( screenConfig );
|
XRRFreeScreenConfigInfo( pScreenConfig );
|
||||||
|
|
||||||
// Do this before resizing the window so that pane-style WMs (Ion,
|
// Do this before resizing the window so that pane-style WMs (Ion,
|
||||||
// ratpoison) don't resize us back inappropriately.
|
// ratpoison) don't resize us back inappropriately.
|
||||||
@@ -290,18 +285,14 @@ void LowLevelWindow_X11::SwapBuffers()
|
|||||||
|
|
||||||
void LowLevelWindow_X11::GetDisplayResolutions( DisplayResolutions &out ) const
|
void LowLevelWindow_X11::GetDisplayResolutions( DisplayResolutions &out ) const
|
||||||
{
|
{
|
||||||
// This _NEEDS_ Xrandr to be present, but feck, who doesn't have it?
|
int iSizesXct;
|
||||||
|
XRRScreenSize *pSizesX = XRRSizes( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ), &iSizesXct );
|
||||||
|
ASSERT_M( iSizesXct != 0, "Couldn't get resolution list from X server" );
|
||||||
|
|
||||||
int sizesXct;
|
for( int i = 0; i < iSizesXct; ++i )
|
||||||
XRRScreenSize *sizesX = XRRSizes( X11Helper::Dpy, DefaultScreen( X11Helper::Dpy ), &sizesXct );
|
|
||||||
ASSERT_M( sizesXct != 0, "Couldn't get resolution list from X server" );
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
while(i < sizesXct)
|
|
||||||
{
|
{
|
||||||
DisplayResolution res = { sizesX[i].width, sizesX[i].height };
|
DisplayResolution res = { pSizesX[i].width, pSizesX[i].height };
|
||||||
out.s.insert( res );
|
out.s.insert( res );
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user