LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0569-Let-wxwidgets-check-events.patch of Package erlang (Project home:Ledest:erlang:20)

From 57e980c90bd8d4c8eaa90f7dcc0246d4dc22af70 Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Wed, 12 Dec 2018 13:15:58 +0100
Subject: [PATCH 1/5] Let wxwidgets check events

Check events more often not just inside batches but also when X
commands have been processed.
---
 lib/wx/c_src/wxe_impl.cpp | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index bd22502d00..43b5476073 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -267,7 +267,7 @@ int WxeApp::dispatch_cmds()
   return more;
 }
 
-#define BREAK_BATCH 10000
+#define CHECK_EVENTS 10000
 
 int WxeApp::dispatch(wxeFifo * batch)
 {
@@ -278,13 +278,14 @@ int WxeApp::dispatch(wxeFifo * batch)
   erl_drv_mutex_lock(wxe_batch_locker_m);
   while(true) {
     while((event = batch->Get()) != NULL) {
+      wait += 1;
       erl_drv_mutex_unlock(wxe_batch_locker_m);
       switch(event->op) {
       case WXE_BATCH_END:
 	if(blevel>0) {
           blevel--;
           if(blevel==0)
-            wait += BREAK_BATCH/4;
+            wait += CHECK_EVENTS/4;
         }
 	break;
       case WXE_BATCH_BEGIN:
@@ -314,21 +315,18 @@ int WxeApp::dispatch(wxeFifo * batch)
 	break;
       }
       event->Delete();
+      if(wait > CHECK_EVENTS)
+        return 1; // Let wx check for events
       erl_drv_mutex_lock(wxe_batch_locker_m);
       batch->Cleanup();
     }
-    if(blevel <= 0 || wait >= BREAK_BATCH) {
+    if(blevel <= 0) {
       erl_drv_mutex_unlock(wxe_batch_locker_m);
-      if(blevel > 0) {
-        return 1; // We are still in a batch but we can let wx check for events
-      } else {
-        return 0;
-      }
+      return 0;
     }
     // sleep until something happens
     // fprintf(stderr, "%s:%d sleep %d %d %d\r\n", __FILE__, __LINE__, batch->m_n, blevel, wait);fflush(stderr);
     wxe_needs_signal = 1;
-    wait += 1;
     while(batch->m_n == 0) {
       erl_drv_cond_wait(wxe_batch_locker_c, wxe_batch_locker_m);
     }
-- 
2.16.4