@@ -801,11 +801,48 @@ void platform_support::update_window()
801
801
XSync (xc->display , m_wait_mode);
802
802
}
803
803
804
- static Bool is_configure_pred (Display *d, XEvent *ev, XPointer arg)
804
+ static Bool is_configure_or_expose (Display *d, XEvent *ev, XPointer arg)
805
805
{
806
- return ev->type == ConfigureNotify ? True : False;
806
+ return ( ev->type == ConfigureNotify || ev-> type == Expose) ? True : False;
807
807
}
808
808
809
+ struct loop_state {
810
+ XEvent config;
811
+ XEvent expose;
812
+
813
+ loop_state () {
814
+ config.type = 0 ;
815
+ expose.type = 0 ;
816
+ }
817
+ };
818
+
819
+ static XEvent x_get_event (Display *d, loop_state& current)
820
+ {
821
+ XEvent xev;
822
+ if (current.expose .type == Expose) {
823
+ xev = current.expose ;
824
+ current.expose .type = 0 ;
825
+ return xev;
826
+ }
827
+ while (XCheckIfEvent (d, &xev, is_configure_or_expose, NULL ) == True) {
828
+ if (xev.type == ConfigureNotify) {
829
+ current.config = xev;
830
+ current.expose .type = 0 ;
831
+ } else {
832
+ current.expose = xev;
833
+ }
834
+ }
835
+ if (current.config .type == ConfigureNotify) {
836
+ xev = current.config ;
837
+ current.config .type = 0 ;
838
+ } else if (current.expose .type == Expose) {
839
+ xev = current.expose ;
840
+ current.expose .type = 0 ;
841
+ } else {
842
+ XNextEvent (d, &xev);
843
+ }
844
+ return xev;
845
+ }
809
846
810
847
// ------------------------------------------------------------------------
811
848
int platform_support::run ()
@@ -820,6 +857,7 @@ int platform_support::run()
820
857
821
858
platform_specific *ps = m_specific;
822
859
860
+ loop_state event_loop;
823
861
while (!quit)
824
862
{
825
863
if (ps->m_update_flag && ps->m_is_mapped )
@@ -835,13 +873,7 @@ int platform_support::run()
835
873
if (ps->m_is_mapped )
836
874
{
837
875
ps->m_mutex .unlock ();
838
- XNextEvent (xc->display , &x_event);
839
- if (x_event.type == ConfigureNotify) {
840
- XEvent xpk;
841
- while (XCheckIfEvent (xc->display , &xpk, is_configure_pred, NULL ) == True) {
842
- x_event = xpk;
843
- }
844
- }
876
+ x_event = x_get_event (xc->display , event_loop);
845
877
ps->m_mutex .lock ();
846
878
}
847
879
else
0 commit comments