X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgbase%2Fdisplay.cpp;h=cb0cecc59869fbd6aca14c5b8171bd7d63784349;hb=dfa13b10b63d0a813db378c4212e90a32ee4d65c;hp=3a755014c1996fe29083c2fda93e7958ad259c13;hpb=fcd5f24311fcfe772825a75678e038749401a9be;p=libs%2Fgui.git diff --git a/source/gbase/display.cpp b/source/gbase/display.cpp index 3a75501..cb0cecc 100644 --- a/source/gbase/display.cpp +++ b/source/gbase/display.cpp @@ -8,8 +8,10 @@ Distributed under the LGPL #include #ifndef WIN32 #include +#ifdef WITH_XF86VIDMODE #include #endif +#endif #include #include #include @@ -86,6 +88,7 @@ Display::Display(const string &disp_name): XSetErrorHandler(x_error_handler); +#ifdef WITH_XF86VIDMODE int screen=DefaultScreen(priv->display); int nmodes; @@ -110,6 +113,7 @@ Display::Display(const string &disp_name): if(modeline.htotal && modeline.vtotal) orig_mode.rate=dotclock/(modeline.htotal*modeline.vtotal); #endif +#endif } Display::~Display() @@ -132,7 +136,7 @@ void Display::remove_window(Window &wnd) void Display::set_mode(const VideoMode &mode) { -#ifdef WIN32 +#if defined(WIN32) DEVMODE info; info.dmSize=sizeof(DEVMODE); info.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT; @@ -145,7 +149,7 @@ void Display::set_mode(const VideoMode &mode) } ChangeDisplaySettings(&info, CDS_FULLSCREEN); -#else +#elif defined(WITH_XF86VIDMODE) int screen=DefaultScreen(priv->display); int nmodes; @@ -167,6 +171,9 @@ void Display::set_mode(const VideoMode &mode) } throw InvalidParameterValue("Requested mode not supported"); +#else + (void)mode; + throw Exception("Video mode switching not supported"); #endif } @@ -187,7 +194,7 @@ void Display::tick() if(pending==0) break; - for(int i=0; idisplay, &event.xevent); @@ -197,6 +204,26 @@ void Display::tick() map::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); } }