Commit: a97607dcfa25149c70972ad868fbc1eee9f88b9a
Author: Campbell Barton
Date:   Sun Feb 5 21:21:04 2023 +1100
Branches: master
https://developer.blender.org/rBa97607dcfa25149c70972ad868fbc1eee9f88b9a

Cleanup: use typed enum for the handler flag in wm_event_system

===================================================================

M       source/blender/windowmanager/intern/wm_event_system.cc

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_event_system.cc 
b/source/blender/windowmanager/intern/wm_event_system.cc
index 590b0c72b79..406ca7f16d4 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -99,13 +99,15 @@
 /**
  * Return value of handler-operator call.
  */
-enum {
-  WM_HANDLER_CONTINUE = 0,
+using eHandlerActionFlag = enum eHandlerActionFlag {
   WM_HANDLER_BREAK = 1 << 0,
   WM_HANDLER_HANDLED = 1 << 1,
   /** `WM_HANDLER_MODAL | WM_HANDLER_BREAK` means unhandled. */
   WM_HANDLER_MODAL = 1 << 2,
 };
+ENUM_OPERATORS(eHandlerActionFlag, WM_HANDLER_MODAL);
+/** Comparison, for readability. */
+#define WM_HANDLER_CONTINUE ((eHandlerActionFlag)0)
 
 static void wm_notifier_clear(wmNotifier *note);
 static bool wm_notifier_is_clear(const wmNotifier *note);
@@ -740,7 +742,7 @@ static bool wm_event_always_pass(const wmEvent *event)
  */
 BLI_INLINE void wm_event_handler_return_value_check(const bContext *C,
                                                     const wmEvent *event,
-                                                    const int action)
+                                                    const eHandlerActionFlag 
action)
 {
 #ifndef NDEBUG
   if (C == nullptr || CTX_wm_window(C)) {
@@ -757,10 +759,10 @@ BLI_INLINE void wm_event_handler_return_value_check(const 
bContext *C,
 /** \name UI Handling
  * \{ */
 
-static int wm_handler_ui_call(bContext *C,
-                              wmEventHandler_UI *handler,
-                              const wmEvent *event,
-                              int always_pass)
+static eHandlerActionFlag wm_handler_ui_call(bContext *C,
+                                             wmEventHandler_UI *handler,
+                                             const wmEvent *event,
+                                             int always_pass)
 {
   ScrArea *area = CTX_wm_area(C);
   ARegion *region = CTX_wm_region(C);
@@ -789,7 +791,7 @@ static int wm_handler_ui_call(bContext *C,
   /* Don't block file-select events. Those are triggered by a separate file 
browser window.
    * See T75292. */
   if (event->type == EVT_FILESELECT) {
-    return WM_UI_HANDLER_CONTINUE;
+    return WM_HANDLER_CONTINUE;
   }
 
   /* We set context to where UI handler came from. */
@@ -2405,12 +2407,12 @@ static void wm_event_modalkeymap_end(wmEvent *event, 
const wmEvent_ModalMapStore
 /**
  * \warning this function removes a modal handler, when finished.
  */
-static int wm_handler_operator_call(bContext *C,
-                                    ListBase *handlers,
-                                    wmEventHandler *handler_base,
-                                    wmEvent *event,
-                                    PointerRNA *properties,
-                                    const char *kmi_idname)
+static eHandlerActionFlag wm_handler_operator_call(bContext *C,
+                                                   ListBase *handlers,
+                                                   wmEventHandler 
*handler_base,
+                                                   wmEvent *event,
+                                                   PointerRNA *properties,
+                                                   const char *kmi_idname)
 {
   int retval = OPERATOR_PASS_THROUGH;
 
@@ -2616,13 +2618,13 @@ static void wm_operator_free_for_fileselect(wmOperator 
*file_operator)
  * File-select handlers are only in the window queue,
  * so it's safe to switch screens or area types.
  */
-static int wm_handler_fileselect_do(bContext *C,
-                                    ListBase *handlers,
-                                    wmEventHandler_Op *handler,
-                                    int val)
+static eHandlerActionFlag wm_handler_fileselect_do(bContext *C,
+                                                   ListBase *handlers,
+                                                   wmEventHandler_Op *handler,
+                                                   int val)
 {
   wmWindowManager *wm = CTX_wm_manager(C);
-  int action = WM_HANDLER_CONTINUE;
+  eHandlerActionFlag action = WM_HANDLER_CONTINUE;
 
   switch (val) {
     case EVT_FILESELECT_FULL_OPEN: {
@@ -2841,12 +2843,12 @@ static int wm_handler_fileselect_do(bContext *C,
   return action;
 }
 
-static int wm_handler_fileselect_call(bContext *C,
-                                      ListBase *handlers,
-                                      wmEventHandler_Op *handler,
-                                      const wmEvent *event)
+static eHandlerActionFlag wm_handler_fileselect_call(bContext *C,
+                                                     ListBase *handlers,
+                                                     wmEventHandler_Op 
*handler,
+                                                     const wmEvent *event)
 {
-  int action = WM_HANDLER_CONTINUE;
+  eHandlerActionFlag action = WM_HANDLER_CONTINUE;
 
   if (event->type != EVT_FILESELECT) {
     return action;
@@ -2858,12 +2860,12 @@ static int wm_handler_fileselect_call(bContext *C,
   return wm_handler_fileselect_do(C, handlers, handler, event->val);
 }
 
-static bool wm_action_not_handled(int action)
+static bool wm_action_not_handled(const eHandlerActionFlag action)
 {
   return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | 
WM_HANDLER_MODAL);
 }
 
-static const char *keymap_handler_log_action_str(const int action)
+static const char *keymap_handler_log_action_str(const eHandlerActionFlag 
action)
 {
   if (action & WM_HANDLER_BREAK) {
     return "handled";
@@ -2912,7 +2914,7 @@ static const char *keymap_handler_log_kmi_op_str(bContext 
*C,
   if (do_debug_handler) \
   printf
 
-static int wm_handlers_do_keymap_with_keymap_handler(
+static eHandlerActionFlag wm_handlers_do_keymap_with_keymap_handler(
     /* From 'wm_handlers_do_intern'. */
     bContext *C,
     wmEvent *event,
@@ -2922,7 +2924,7 @@ static int wm_handlers_do_keymap_with_keymap_handler(
     wmKeyMap *keymap,
     const bool do_debug_handler)
 {
-  int action = WM_HANDLER_CONTINUE;
+  eHandlerActionFlag action = WM_HANDLER_CONTINUE;
 
   if (keymap == nullptr) {
     /* Only callback is allowed to have nullptr key-maps. */
@@ -2970,7 +2972,7 @@ static int wm_handlers_do_keymap_with_keymap_handler(
   return action;
 }
 
-static int wm_handlers_do_keymap_with_gizmo_handler(
+static eHandlerActionFlag wm_handlers_do_keymap_with_gizmo_handler(
     /* From 'wm_handlers_do_intern' */
     bContext *C,
     wmEvent *event,
@@ -2982,7 +2984,7 @@ static int wm_handlers_do_keymap_with_gizmo_handler(
     const bool do_debug_handler,
     bool *r_keymap_poll)
 {
-  int action = WM_HANDLER_CONTINUE;
+  eHandlerActionFlag action = WM_HANDLER_CONTINUE;
   bool keymap_poll = false;
 
   PRINT("%s:   checking '%s' ...", __func__, keymap->idname);
@@ -3030,12 +3032,12 @@ static int wm_handlers_do_keymap_with_gizmo_handler(
   return action;
 }
 
-static int wm_handlers_do_gizmo_handler(bContext *C,
-                                        wmWindowManager *wm,
-                                        wmEventHandler_Gizmo *handler,
-                                        wmEvent *event,
-                                        ListBase *handlers,
-                                        const bool do_debug_handler)
+static eHandlerActionFlag wm_handlers_do_gizmo_handler(bContext *C,
+                                                       wmWindowManager *wm,
+                                                       wmEventHandler_Gizmo 
*handler,
+                                                       wmEvent *event,
+                                                       ListBase *handlers,
+                                                       const bool 
do_debug_handler)
 {
   /* Drag events use the previous click location to highlight the gizmos,
    * Get the highlight again in case the user dragged off the gizmo. */
@@ -3046,7 +3048,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
    * was initiated over a gizmo. */
   const bool restore_highlight_unless_activated = is_event_drag;
 
-  int action = WM_HANDLER_CONTINUE;
+  eHandlerActionFlag action = WM_HANDLER_CONTINUE;
   ScrArea *area = CTX_wm_area(C);
   ARegion *region = CTX_wm_region(C);
   wmGizmoMap *gzmap = handler->gizmo_map;
@@ -3217,7 +3219,10 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
 /** \name Handle Single Event (All Handler Types)
  * \{ */
 
-static int wm_handlers_do_intern(bContext *C, wmWindow *win, wmEvent *event, 
ListBase *handlers)
+static eHandlerActionFlag wm_handlers_do_intern(bContext *C,
+                                                wmWindow *win,
+                                                wmEvent *event,
+                                                ListBase *handlers)
 {
   const bool do_debug_handler =
       (G.debug & G_DEBUG_HANDLERS) &&
@@ -3225,7 +3230,7 @@ static int wm_handlers_do_intern(bContext *C, wmWindow 
*win, wmEvent *event, Lis
       !ISMOUSE_MOTION(event->type);
 
   wmWindowManager *wm = CTX_wm_manager(C);
-  int action = WM_HANDLER_CONTINUE;
+  eHandlerActionFlag action = WM_HANDLER_CONTINUE;
 
   if (handlers == nullptr) {
     wm_event_handler_return_value_check(C, event, action);
@@ -3262,7 +3267,7 @@ static int wm_handlers_do_intern(bContext *C, wmWindow 
*win, wmEvent *event, Lis
         wmEventHandler_Keymap *handler = (wmEventHandler_Keymap *)handler_base;
         wmEventHandler_KeymapResult km_result;
         WM_event_get_keymaps_from_handler(wm, win, handler, &km_result);
-        int action_iter = WM_HANDLER_CONTINUE;
+        eHandlerActionFlag action_iter = WM_HANDLER_CONTINUE;
         for (int km_index = 0; km_index < km_result.keymaps_len; km_index++) {
           wmKeyMap *keymap = km_result.keymaps[km_index];
           action_iter |= wm_handlers_do_keymap_with_keymap_handler(
@@ -3401,9 +3406,9 @@ static int wm_handlers_do_intern(bContext *C, wmWindow 
*win, wmEvent *event, Lis
 #undef PRINT
 
 /* This calls handlers twice - to solve (double-)click events. */
-static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
+static eHandlerActionFlag wm_handlers_do(bContext *C, wmEven

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to