#include <iostream>
#ifndef WIN32
#include <X11/Xlib.h>
+#ifdef WITH_XF86VIDMODE
#include <X11/extensions/xf86vmode.h>
#endif
+#endif
#include <msp/core/except.h>
#include <msp/strings/formatter.h>
#include <msp/strings/lexicalcast.h>
XSetErrorHandler(x_error_handler);
+#ifdef WITH_XF86VIDMODE
int screen=DefaultScreen(priv->display);
int nmodes;
if(modeline.htotal && modeline.vtotal)
orig_mode.rate=dotclock/(modeline.htotal*modeline.vtotal);
#endif
+#endif
}
Display::~Display()
void Display::set_mode(const VideoMode &mode)
{
-#ifdef WIN32
+#if defined(WIN32)
DEVMODE info;
info.dmSize=sizeof(DEVMODE);
info.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT;
}
ChangeDisplaySettings(&info, CDS_FULLSCREEN);
-#else
+#elif defined(WITH_XF86VIDMODE)
int screen=DefaultScreen(priv->display);
int nmodes;
}
throw InvalidParameterValue("Requested mode not supported");
+#else
+ (void)mode;
+ throw Exception("Video mode switching not supported");
#endif
}
if(pending==0)
break;
- for(int i=0; i<pending; ++i)
+ for(; pending--;)
{
Window::Event event;
XNextEvent(priv->display, &event.xevent);
map<WindowHandle, Window *>::iterator j=priv->windows.find(event.xevent.xany.window);
if(j!=priv->windows.end())
{
+ /* Filter keyboard autorepeat. If this packet is a KeyRelease and
+ the next one is a KeyPress with the exact same parameters, they
+ indicate autorepeat and must be dropped. */
+ if(event.xevent.type==KeyRelease && !j->second->get_keyboard_autorepeat() && pending>0)
+ {
+ XKeyEvent &kev=event.xevent.xkey;
+ XEvent ev2;
+ XPeekEvent(priv->display, &ev2);
+ if(ev2.type==KeyPress)
+ {
+ XKeyEvent &kev2=ev2.xkey;
+ if(kev2.window==kev.window && kev2.time==kev.time && kev2.keycode==kev.keycode)
+ {
+ XNextEvent(priv->display, &ev2);
+ --pending;
+ continue;
+ }
+ }
+ }
+
j->second->event(event);
}
}