@@ -269,35 +269,24 @@ Boolean MCScreenDC::handle(Boolean dispatch, Boolean anyevent, Boolean& abort, B
269269 // Loop until both the pending event queue and GDK event queue are empty
270270 abort = reset = False;
271271 bool t_handled = false ;
272- while (dispatch || g_main_context_pending (NULL ) || gdk_events_pending ())
272+ while (true || dispatch || g_main_context_pending (NULL ) || gdk_events_pending ())
273273 {
274- // Run the GLib event loop to exhaustion
275- while (g_main_context_iteration (NULL , FALSE ))
276- ;
274+ // Place all events onto the pending event queue
275+ EnqueueGdkEvents ();
277276
278- bool t_live;
279277 bool t_queue = false ;
280278 if (dispatch && pendingevents != NULL )
281279 {
282280 // Get the next event from the queue
283281 t_event = gdk_event_copy (pendingevents->event );
284282 MCEventnode *tptr = (MCEventnode *)pendingevents->remove (pendingevents);
285283 delete tptr;
286- t_live = false ;
287- }
288- else
289- {
290- // In theory, all events should have already been queued as pending
291- // through the GLib main loop. However, that only applies to those
292- // that the server has already sent - this function call prompts the
293- // server to send any events queued on its end.
294- t_event = gdk_event_get ();
295- t_live = true ;
296284 }
297285
298- // Make sure we have an event
299286 if (t_event == NULL )
287+ {
300288 break ;
289+ }
301290
302291 // What type of event are we dealing with?
303292 switch (t_event->type )
@@ -312,7 +301,9 @@ Boolean MCScreenDC::handle(Boolean dispatch, Boolean anyevent, Boolean& abort, B
312301 case GDK_DAMAGE :
313302 {
314303 // Handled separately
315- gdk_display_put_event (dpy, t_event);
304+ // fprintf(stderr, "GDK_EXPOSE (window %p)\n", t_event->expose.window);
305+ MCEventnode *t_node = new MCEventnode (gdk_event_copy (t_event));
306+ t_node->appendto (pendingevents);
316307 expose ();
317308 break ;
318309 }
@@ -911,8 +902,10 @@ void MCScreenDC::EnqueueGdkEvents()
911902 while (true )
912903 {
913904 // Run the GLib main loop
905+ gdk_threads_leave ();
914906 while (g_main_context_iteration (NULL , FALSE ))
915907 ;
908+ gdk_threads_enter ();
916909
917910 // Enqueue any further GDK events
918911 GdkEvent *t_event = gdk_event_get ();
@@ -1003,7 +996,7 @@ void DnDClientEvent(GdkEvent* p_event)
1003996 {
1004997 case GDK_DRAG_ENTER :
1005998 {
1006- fprintf (stderr, " DND: drag enter\n " );
999+ // fprintf(stderr, "DND: drag enter\n");
10071000 // Get the selection atom for this drag event
10081001 GdkAtom t_selection;
10091002 t_selection = gdk_drag_get_selection (p_event->dnd .context );
@@ -1040,7 +1033,7 @@ void DnDClientEvent(GdkEvent* p_event)
10401033
10411034 case GDK_DRAG_LEAVE :
10421035 {
1043- fprintf (stderr, " DND: drag leave\n " );
1036+ // fprintf(stderr, "DND: drag leave\n");
10441037 // The drag is no longer relevant to us
10451038 MCdispatcher->wmdragleave (p_event->dnd .window );
10461039 MCtransferstore->cleartypes ();
@@ -1049,7 +1042,7 @@ void DnDClientEvent(GdkEvent* p_event)
10491042
10501043 case GDK_DRAG_MOTION :
10511044 {
1052- fprintf (stderr, " DND: drag motion\n " );
1045+ // fprintf(stderr, "DND: drag motion\n");
10531046 // Translate the position from root to relative coordinates
10541047 uint32_t wx, wy; // Window-relative coordinates
10551048 gint ox, oy; // Window origin in root coordinates
@@ -1088,7 +1081,7 @@ void DnDClientEvent(GdkEvent* p_event)
10881081
10891082 case GDK_DROP_START :
10901083 {
1091- fprintf (stderr, " DND: drop start\n " );
1084+ // fprintf(stderr, "DND: drop start\n");
10921085 // Temporarily adopt the asynchronous modifier state
10931086 uint16_t t_old_modstate = MCmodifierstate;
10941087 MCmodifierstate = MCscreen->querymods ();
0 commit comments