aboutsummaryrefslogtreecommitdiffstats
path: root/src/haiku_support.cc
diff options
context:
space:
mode:
authorPo Lu2022-04-13 00:47:00 +0000
committerPo Lu2022-04-13 00:51:13 +0000
commit2e0a2ecc294aa2273ffbef27f49706db2cf40062 (patch)
treedac4ecc80fb38252570fc8efabfbd3bf639a2cdb /src/haiku_support.cc
parent33cc12498b0f9191437d1f273d0467d0f69d48f3 (diff)
downloademacs-2e0a2ecc294aa2273ffbef27f49706db2cf40062.tar.gz
emacs-2e0a2ecc294aa2273ffbef27f49706db2cf40062.zip
Fix freezes when trying to accelerate menu bar on Haiku
* src/haiku_support.cc (class EmacsWindow): New field `menus_begun'. (MenusBeginning): Don't send menu bar open events when that is set, instead set it to true. (BMenuBar_start_tracking): Stop locking the menu bar here and send a special BE_MENU_BAR_OPEN event instead. * src/haiku_support.h (struct haiku_menu_bar_state_event): Delete field `no_lock'. * src/haikumenu.c (Fhaiku_menu_bar_open): * src/haikuterm.c (haiku_read_socket): Update accordingly.
Diffstat (limited to 'src/haiku_support.cc')
-rw-r--r--src/haiku_support.cc72
1 files changed, 51 insertions, 21 deletions
diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index cb38a572f7c..826e1c21005 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -87,6 +87,8 @@ enum
87 WAIT_FOR_RELEASE = 3001, 87 WAIT_FOR_RELEASE = 3001,
88 RELEASE_NOW = 3002, 88 RELEASE_NOW = 3002,
89 CANCEL_DROP = 3003, 89 CANCEL_DROP = 3003,
90 SHOW_MENU_BAR = 3004,
91 BE_MENU_BAR_OPEN = 3005,
90 }; 92 };
91 93
92static color_space dpy_color_space = B_NO_COLOR_SPACE; 94static color_space dpy_color_space = B_NO_COLOR_SPACE;
@@ -423,6 +425,7 @@ public:
423 pthread_cond_t menu_update_cv = PTHREAD_COND_INITIALIZER; 425 pthread_cond_t menu_update_cv = PTHREAD_COND_INITIALIZER;
424 bool menu_updated_p = false; 426 bool menu_updated_p = false;
425 int window_id; 427 int window_id;
428 bool *menus_begun = NULL;
426 429
427 EmacsWindow () : BWindow (BRect (0, 0, 0, 0), "", B_TITLED_WINDOW_LOOK, 430 EmacsWindow () : BWindow (BRect (0, 0, 0, 0), "", B_TITLED_WINDOW_LOOK,
428 B_NORMAL_WINDOW_FEEL, B_NO_SERVER_SIDE_WINDOW_MODIFIERS) 431 B_NORMAL_WINDOW_FEEL, B_NO_SERVER_SIDE_WINDOW_MODIFIERS)
@@ -902,19 +905,14 @@ public:
902 MenusBeginning () 905 MenusBeginning ()
903 { 906 {
904 struct haiku_menu_bar_state_event rq; 907 struct haiku_menu_bar_state_event rq;
905 int lock_count = 0; 908 int lock_count;
906 thread_id current_thread = find_thread (NULL);
907 thread_id window_thread = Thread ();
908 rq.window = this;
909 rq.no_lock = false;
910
911 if (window_thread != current_thread)
912 rq.no_lock = true;
913 909
914 haiku_write (MENU_BAR_OPEN, &rq); 910 rq.window = this;
911 lock_count = 0;
915 912
916 if (!rq.no_lock) 913 if (!menus_begun)
917 { 914 {
915 haiku_write (MENU_BAR_OPEN, &rq);
918 while (IsLocked ()) 916 while (IsLocked ())
919 { 917 {
920 ++lock_count; 918 ++lock_count;
@@ -932,6 +930,9 @@ public:
932 gui_abort ("Failed to lock after cv signal denoting menu update"); 930 gui_abort ("Failed to lock after cv signal denoting menu update");
933 } 931 }
934 } 932 }
933 else
934 *menus_begun = true;
935
935 menu_bar_active_p = true; 936 menu_bar_active_p = true;
936 } 937 }
937 938
@@ -1244,6 +1245,37 @@ public:
1244 1245
1245 BMenuBar::MouseMoved (point, transit, msg); 1246 BMenuBar::MouseMoved (point, transit, msg);
1246 } 1247 }
1248
1249 void
1250 MessageReceived (BMessage *msg)
1251 {
1252 BRect frame;
1253 BPoint pt, l;
1254 EmacsWindow *window;
1255 bool menus_begun;
1256
1257 if (msg->what == SHOW_MENU_BAR)
1258 {
1259 window = (EmacsWindow *) Window ();
1260 frame = Frame ();
1261 pt = frame.LeftTop ();
1262 l = pt;
1263 menus_begun = false;
1264 Parent ()->ConvertToScreen (&pt);
1265
1266 window->menus_begun = &menus_begun;
1267 set_mouse_position (pt.x, pt.y);
1268 MouseDown (l);
1269 window->menus_begun = NULL;
1270
1271 if (!menus_begun)
1272 msg->SendReply (msg);
1273 else
1274 msg->SendReply (BE_MENU_BAR_OPEN);
1275 }
1276 else
1277 BMenuBar::MessageReceived (msg);
1278 }
1247}; 1279};
1248 1280
1249class EmacsView : public BView 1281class EmacsView : public BView
@@ -3748,20 +3780,18 @@ EmacsWindow_unzoom (void *window)
3748 w->UnZoom (); 3780 w->UnZoom ();
3749} 3781}
3750 3782
3751/* Move the pointer into MBAR and start tracking. */ 3783/* Move the pointer into MBAR and start tracking. Return whether the
3752void 3784 menu bar was opened correctly. */
3785bool
3753BMenuBar_start_tracking (void *mbar) 3786BMenuBar_start_tracking (void *mbar)
3754{ 3787{
3755 EmacsMenuBar *mb = (EmacsMenuBar *) mbar; 3788 EmacsMenuBar *mb = (EmacsMenuBar *) mbar;
3756 if (!mb->LockLooper ()) 3789 BMessenger messenger (mb);
3757 gui_abort ("Couldn't lock menubar"); 3790 BMessage reply;
3758 BRect frame = mb->Frame (); 3791
3759 BPoint pt = frame.LeftTop (); 3792 messenger.SendMessage (SHOW_MENU_BAR, &reply);
3760 BPoint l = pt; 3793
3761 mb->Parent ()->ConvertToScreen (&pt); 3794 return reply.what == BE_MENU_BAR_OPEN;
3762 set_mouse_position (pt.x, pt.y);
3763 mb->MouseDown (l);
3764 mb->UnlockLooper ();
3765} 3795}
3766 3796
3767#ifdef HAVE_NATIVE_IMAGE_API 3797#ifdef HAVE_NATIVE_IMAGE_API