nel-X11-modesetting.patch
b/code/nel/src/3d/driver/opengl/driver_opengl.cpp Sat May 22 12:18:02 2010 +0200 | ||
---|---|---|
1612 | 1612 |
_WindowX = clientRect.left; |
1613 | 1613 |
_WindowY = clientRect.top; |
1614 | 1614 |
_FullScreen = !mode.Windowed; |
1615 |
#else |
|
1616 |
// TODO linux version !!! |
|
1617 |
#endif |
|
1615 |
|
|
1616 |
#elif defined(NL_OS_UNIX) // NL_OS_WINDOWS |
|
1617 |
|
|
1618 |
// Update WM hints (update size and disallow resizing) |
|
1619 |
XSizeHints size_hints; |
|
1620 |
size_hints.x = 0; |
|
1621 |
size_hints.y = 0; |
|
1622 |
size_hints.width = mode.Width; |
|
1623 |
size_hints.height = mode.Height; |
|
1624 |
size_hints.flags = PSize | PMinSize | PMaxSize; |
|
1625 |
size_hints.min_width = mode.Width; |
|
1626 |
size_hints.min_height = mode.Height; |
|
1627 |
size_hints.max_width = mode.Width; |
|
1628 |
size_hints.max_height = mode.Height; |
|
1629 |
|
|
1630 |
XSetWMNormalHints(dpy, win, &size_hints); |
|
1631 |
|
|
1632 |
// Toggle fullscreen |
|
1633 |
if (mode.Windowed == _FullScreen) |
|
1634 |
{ |
|
1635 |
XEvent xev; |
|
1636 |
memset(&xev, 0, sizeof(xev)); |
|
1637 |
xev.type = ClientMessage; |
|
1638 |
xev.xclient.window = win; |
|
1639 |
xev.xclient.message_type = XInternAtom(dpy, "_NET_WM_STATE", false); |
|
1640 |
xev.xclient.format = 32; |
|
1641 |
xev.xclient.data.l[0] = !mode.Windowed; |
|
1642 |
xev.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", false); |
|
1643 |
xev.xclient.data.l[2] = 0; |
|
1644 |
XSendEvent(dpy, DefaultRootWindow(dpy), false, SubstructureNotifyMask, &xev); |
|
1645 |
|
|
1646 |
//TODO: Change X display mode |
|
1647 |
} |
|
1648 |
_FullScreen = !mode.Windowed; |
|
1649 |
|
|
1650 |
// Resize and update the window |
|
1651 |
XResizeWindow(dpy, win, mode.Width, mode.Height); |
|
1652 |
XMapWindow(dpy, win); |
|
1653 |
|
|
1654 |
#endif // NL_OS_UNIX |
|
1618 | 1655 |
return true; |
1619 | 1656 |
} |
1620 | 1657 |
|
b/code/nel/src/3d/driver/opengl/driver_opengl.cpp Sat May 22 12:54:26 2010 +0200 | ||
---|---|---|
1096 | 1096 |
XSetWindowAttributes attr; |
1097 | 1097 |
attr.colormap = cmap; |
1098 | 1098 |
attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy)); |
1099 |
|
|
1100 |
#ifdef XF86VIDMODE |
|
1101 |
// If we're going to attempt fullscreen, we need to set redirect to True, |
|
1102 |
// This basically places the window with no borders in the top left |
|
1103 |
// corner of the screen. |
|
1104 |
if (mode.Windowed) |
|
1105 |
{ |
|
1106 |
attr.override_redirect = False; |
|
1107 |
} |
|
1108 |
else |
|
1109 |
{ |
|
1110 |
attr.override_redirect = True; |
|
1111 |
} |
|
1112 |
#else |
|
1113 | 1099 |
attr.override_redirect = False; |
1114 |
#endif |
|
1115 | 1100 |
|
1116 | 1101 |
int attr_flags = CWOverrideRedirect | CWColormap | CWBackPixel; |
1117 | 1102 |
|
... | ... | |
1615 | 1600 |
|
1616 | 1601 |
#elif defined(NL_OS_UNIX) // NL_OS_WINDOWS |
1617 | 1602 |
|
1603 |
#ifdef XF86VIDMODE |
|
1604 |
if (!mode.Windowed) |
|
1605 |
{ |
|
1606 |
if (mode.Windowed == _FullScreen) |
|
1607 |
{ |
|
1608 |
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode)); |
|
1609 |
XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &_OldDotClock, &_OldScreenMode); |
|
1610 |
XF86VidModeGetViewPort(dpy, DefaultScreen(dpy), &_OldX, &_OldY); |
|
1611 |
} |
|
1612 |
|
|
1613 |
XF86VidModeModeInfo **modes; |
|
1614 |
int nmodes; |
|
1615 |
if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &modes)) |
|
1616 |
{ |
|
1617 |
for (int i = 0; i < nmodes; i++) |
|
1618 |
{ |
|
1619 |
nldebug("3D: Available mode - %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); |
|
1620 |
if(modes[i]->hdisplay == mode.Width && modes[i]->vdisplay == mode.Height) |
|
1621 |
{ |
|
1622 |
if(XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), modes[i])) |
|
1623 |
{ |
|
1624 |
nlinfo("3D: Switching to mode %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); |
|
1625 |
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0); |
|
1626 |
} |
|
1627 |
break; |
|
1628 |
} |
|
1629 |
} |
|
1630 |
} |
|
1631 |
} |
|
1632 |
else if (mode.Windowed == _FullScreen) |
|
1633 |
{ |
|
1634 |
XF86VidModeModeInfo info; |
|
1635 |
nlinfo("3D: Switching back to original mode"); |
|
1636 |
|
|
1637 |
// This is a bit ugly - a quick hack to copy the ModeLine structure |
|
1638 |
// into the modeInfo structure. |
|
1639 |
memcpy((XF86VidModeModeLine *)((char *)&info + sizeof(info.dotclock)),&_OldScreenMode, sizeof(XF86VidModeModeLine)); |
|
1640 |
info.dotclock = _OldDotClock; |
|
1641 |
|
|
1642 |
nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay); |
|
1643 |
XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &info); |
|
1644 |
nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY); |
|
1645 |
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), _OldX, _OldY); |
|
1646 |
} |
|
1647 |
#endif // XF86VIDMODE |
|
1648 |
|
|
1618 | 1649 |
// Update WM hints (update size and disallow resizing) |
1619 | 1650 |
XSizeHints size_hints; |
1620 | 1651 |
size_hints.x = 0; |
... | ... | |
1642 | 1673 |
xev.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", false); |
1643 | 1674 |
xev.xclient.data.l[2] = 0; |
1644 | 1675 |
XSendEvent(dpy, DefaultRootWindow(dpy), false, SubstructureNotifyMask, &xev); |
1645 |
|
|
1646 |
//TODO: Change X display mode |
|
1647 | 1676 |
} |
1648 | 1677 |
_FullScreen = !mode.Windowed; |
1649 | 1678 |
|
b/code/nel/src/3d/driver/opengl/driver_opengl.cpp Sat May 22 13:06:56 2010 +0200 | ||
---|---|---|
1141 | 1141 |
// XEvent event; |
1142 | 1142 |
// XIfEvent(dpy, &event, WaitForNotify, (char *)this); |
1143 | 1143 |
|
1144 |
#ifdef XF86VIDMODE |
|
1145 |
if (!mode.Windowed) |
|
1146 |
{ |
|
1147 |
// Set window to the right size, map it to the display, and raise it to the front |
|
1148 |
XResizeWindow(dpy, win, width, height); |
|
1149 |
XMapRaised(dpy, win); |
|
1150 |
XRaiseWindow(dpy, win); |
|
1151 |
|
|
1152 |
// grab the mouse and keyboard on the fullscreen window |
|
1153 |
if ((XGrabPointer(dpy, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime) != GrabSuccess) || |
|
1154 |
(XGrabKeyboard(dpy, win, True, GrabModeAsync, GrabModeAsync, CurrentTime) != 0) ) |
|
1155 |
{ |
|
1156 |
// Until I work out how to deal with this nicely, it just gives |
|
1157 |
// an error and exits the prorgam. |
|
1158 |
nlerror("Unable to grab keyboard and mouse"); |
|
1159 |
} |
|
1160 |
else |
|
1161 |
{ |
|
1162 |
// Save the old screen mode and dotclock and viewport |
|
1163 |
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode)); |
|
1164 |
XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &_OldDotClock, &_OldScreenMode); |
|
1165 |
XF86VidModeGetViewPort(dpy, DefaultScreen(dpy), &_OldX, &_OldY); |
|
1166 |
|
|
1167 |
// Get a list of modes, search for an appropriate one. |
|
1168 |
XF86VidModeModeInfo **modes; |
|
1169 |
int nmodes; |
|
1170 |
if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &modes)) |
|
1171 |
{ |
|
1172 |
int mode_index = -1; // Gah, magic numbers all bad. |
|
1173 |
for (int i = 0; i < nmodes; i++) |
|
1174 |
{ |
|
1175 |
nldebug("3D: Available mode - %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); |
|
1176 |
if(modes[i]->hdisplay == width && modes[i]->vdisplay == height) |
|
1177 |
{ |
|
1178 |
mode_index = i; |
|
1179 |
break; |
|
1180 |
} |
|
1181 |
} |
|
1182 |
// Switch to the mode |
|
1183 |
if (mode_index != -1) |
|
1184 |
{ |
|
1185 |
if(XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), modes[mode_index])) |
|
1186 |
{ |
|
1187 |
nlinfo("3D: Switching to mode %dx%d", modes[mode_index]->hdisplay, modes[mode_index]->vdisplay); |
|
1188 |
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0); |
|
1189 |
_FullScreen = true; |
|
1190 |
} |
|
1191 |
} |
|
1192 |
else |
|
1193 |
{ |
|
1194 |
// This is a problem, since we've nuked the border from |
|
1195 |
// window in the setup stage, until I work out how |
|
1196 |
// to get it back (recreate window? seems excessive) |
|
1197 |
nlerror("Couldn't find an appropriate mode %dx%d", width, height); |
|
1198 |
} |
|
1199 |
} |
|
1200 |
} |
|
1201 |
} |
|
1202 |
|
|
1203 |
#endif // XF86VIDMODE |
|
1144 |
setMode(mode); |
|
1204 | 1145 |
|
1205 | 1146 |
#endif // NL_OS_UNIX |
1206 | 1147 |
|
... | ... | |
1603 | 1544 |
#ifdef XF86VIDMODE |
1604 | 1545 |
if (!mode.Windowed) |
1605 | 1546 |
{ |
1547 |
// Store old mdoe in order to restore it when leaving fullscreen |
|
1606 | 1548 |
if (mode.Windowed == _FullScreen) |
1607 | 1549 |
{ |
1608 | 1550 |
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode)); |
... | ... | |
1610 | 1552 |
XF86VidModeGetViewPort(dpy, DefaultScreen(dpy), &_OldX, &_OldY); |
1611 | 1553 |
} |
1612 | 1554 |
|
1555 |
// Find the requested mode and use it |
|
1613 | 1556 |
XF86VidModeModeInfo **modes; |
1614 | 1557 |
int nmodes; |
1615 | 1558 |
if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &modes)) |