add api call for initializing events from the windows eventstate.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 29 Jul 2013 08:29:04 +0000 (08:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 29 Jul 2013 08:29:04 +0000 (08:29 +0000)
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c

index 6504c198b21a3aa470fa2ad8383f17b8282eba1c..21a63183c1a27e5ec42c50ee73f0c08de929c757 100644 (file)
@@ -3964,7 +3964,8 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but)
 {
        wmEvent event;
        
-       event = *(win->eventstate);
+       wm_event_init_from_window(win, &event);
+
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index 8efad17133f904e0e91387da2010ace51d484fde..b3df719d95abe016c9c65ccb3e0522c893dbd01e 100644 (file)
@@ -6193,7 +6193,7 @@ void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but)
        
        button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index 4670d6598860fdd1d544d65e7db51ba9763f6764..3066b733fc52a333bfee0048c55daa6db284df51 100644 (file)
@@ -649,7 +649,8 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
        
        sad->modifier = RNA_int_get(op->ptr, "modifier");
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
+
        if (type == AZONE_AREA)
                event.type = EVT_ACTIONZONE_AREA;
        else
index bd0c9848b239d83abdadfc34c6a3a2ca0e7e3bf0..e17699309ef9bf127f63557776a2427862c1c266 100644 (file)
@@ -926,7 +926,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op)
        uiEndBlock(C, block);
        
        //      uiButActiveOnly(C, ar, block, but); XXX using this here makes Blender hang - investigate
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index 81207deea0172d0c58188baca97254ed2b59197b..666cf00280d87f794907e0b1bc957b9cf0adff41 100644 (file)
@@ -811,7 +811,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
        uiBlockSetDirection(block, UI_DOWN);
        uiEndBlock(C, block);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index f5f59c935df426badcfc46f74db8169d0b7955ce..bdb203ab003121a4b9f2600df391d11d035b3d8c 100644 (file)
@@ -195,7 +195,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
        uiBlockSetDirection(block, UI_DOWN);
        uiEndBlock(C, block);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
index 7cb24daaaefa55287a522e75303881d108f4b052..76fb88c8d25398e547f00b2380bece246516b584 100644 (file)
@@ -187,6 +187,8 @@ __attribute__ ((format(printf, 3, 4)))
 ;
 
 void           wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add);
+void           wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
+
 
                        /* at maximum, every timestep seconds it triggers event_type events */
 struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep);
index c33e67e00bd69ea6aa75b65a782bce786dad882a..862e4a41cf04efa6ef9f0648fdf0ab0f5e3ea8c2 100644 (file)
@@ -132,6 +132,14 @@ void wm_event_free_all(wmWindow *win)
        }
 }
 
+void wm_event_init_from_window(wmWindow *win, wmEvent *event)
+{
+       /* make sure we don't copy any owned pointers */
+       BLI_assert(win->eventstate->tablet_data == NULL);
+
+       *event = *(win->eventstate);
+}
+
 /* ********************* notifiers, listeners *************** */
 
 static int wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, void *reference)
@@ -445,7 +453,9 @@ static void wm_handler_ui_cancel(bContext *C)
                nexthandler = handler->next;
 
                if (handler->ui_handle) {
-                       wmEvent event = *(win->eventstate);
+                       wmEvent event;
+
+                       wm_event_init_from_window(win, &event);
                        event.type = EVT_BUT_CANCEL;
                        handler->ui_handle(C, &event, handler->ui_userdata);
                }
index 39584882d0e956f80acb4c152744bedcf434b376..f1a9f6dc007b9843d22879e02b2fbae96b24f614 100644 (file)
@@ -978,7 +978,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op)
        uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
        uiEndBlock(C, block);
 
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
@@ -1751,7 +1751,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_
        uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
        uiEndBlock(C, block);
        
-       event = *(win->eventstate);  /* XXX huh huh? make api call */
+       wm_event_init_from_window(win, &event);
        event.type = EVT_BUT_OPEN;
        event.val = KM_PRESS;
        event.customdata = but;
@@ -2988,7 +2988,7 @@ static void tweak_gesture_modal(bContext *C, const wmEvent *event)
                        if ((val = wm_gesture_evaluate(gesture))) {
                                wmEvent tevent;
 
-                               tevent = *(window->eventstate);
+                               wm_event_init_from_window(window, &tevent);
                                if (gesture->event_type == LEFTMOUSE)
                                        tevent.type = EVT_TWEAK_L;
                                else if (gesture->event_type == RIGHTMOUSE)
index e0595e3c8ab40910cd46f897f9479179992d28a5..70541f7cec5b8055ead5113444af71bdb970cb87 100644 (file)
@@ -808,7 +808,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
                                 * currently it seems to be common practice to generate new event for, but probably
                                 * we'll need utility function for this? (sergey)
                                 */
-                               event = *(win->eventstate);
+                               wm_event_init_from_window(win, &event);
                                event.type = MOUSEMOVE;
                                event.prevx = event.x;
                                event.prevy = event.y;
@@ -957,7 +957,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
                                win->eventstate->x = wx;
                                win->eventstate->y = wy;
                                
-                               event = *(win->eventstate);  /* copy last state, like mouse coords */
+                               wm_event_init_from_window(win, &event);  /* copy last state, like mouse coords */
                                
                                /* activate region */
                                event.type = MOUSEMOVE;
@@ -1065,7 +1065,8 @@ static int wm_window_timer(const bContext *C)
                                else if (wt->event_type == TIMERAUTOSAVE)
                                        wm_autosave_timer(C, wm, wt);
                                else if (win) {
-                                       wmEvent event = *(win->eventstate);
+                                       wmEvent event;
+                                       wm_event_init_from_window(win, &event);
                                        
                                        event.type = wt->event_type;
                                        event.val = 0;