Fix active region flickering in some cases, now always update before draw.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 21 Apr 2018 15:39:34 +0000 (17:39 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 21 Apr 2018 15:42:49 +0000 (17:42 +0200)
source/blender/editors/include/ED_screen.h
source/blender/editors/screen/screen_edit.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c

index eb8221ac6c9ac9181b9c4005bb60fc5dc084ab36..0f4fb6b8cc36ee42d395f55b11705ce1ca0a0ed0 100644 (file)
@@ -160,7 +160,7 @@ void    ED_screen_update_after_scene_change(
         const struct bScreen *screen,
         struct Scene *scene_new,
         struct ViewLayer *view_layer);
-void    ED_screen_set_active_region(struct bContext *C, const struct wmEvent *event);
+void    ED_screen_set_active_region(struct bContext *C, const int xy[2]);
 void    ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
 void    ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable);
 void    ED_screen_animation_timer_update(struct bScreen *screen, int redraws, int refresh);
index 6f7d7632a3c4c083e6a6e84df5f0958c98ea6da7..6a27964165dd7d0dd247b5f3219f96186bba91c3 100644 (file)
@@ -986,14 +986,14 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
 /* *********************************** */
 
 /* case when on area-edge or in azones, or outside window */
-static void screen_cursor_set(wmWindow *win, const wmEvent *event)
+static void screen_cursor_set(wmWindow *win, const int xy[2])
 {
        const bScreen *screen = WM_window_get_active_screen(win);
        AZone *az = NULL;
        ScrArea *sa;
        
        for (sa = screen->areabase.first; sa; sa = sa->next)
-               if ((az = is_in_area_actionzone(sa, &event->x)))
+               if ((az = is_in_area_actionzone(sa, xy)))
                        break;
        
        if (sa) {
@@ -1007,7 +1007,7 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event)
                }
        }
        else {
-               ScrEdge *actedge = screen_find_active_scredge(win, screen, event->x, event->y);
+               ScrEdge *actedge = screen_find_active_scredge(win, screen, xy[0], xy[1]);
 
                if (actedge) {
                        if (scredge_is_horizontal(actedge))
@@ -1023,7 +1023,7 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event)
 
 /* called in wm_event_system.c. sets state vars in screen, cursors */
 /* event type is mouse move */
-void ED_screen_set_active_region(bContext *C, const wmEvent *event)
+void ED_screen_set_active_region(bContext *C, const int xy[2])
 {
        wmWindow *win = CTX_wm_window(C);
        bScreen *scr = WM_window_get_active_screen(win);
@@ -1034,9 +1034,9 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
                ARegion *old_ar = scr->active_region;
 
                ED_screen_areas_iter(win, scr, area_iter) {
-                       if (event->x > area_iter->totrct.xmin && event->x < area_iter->totrct.xmax) {
-                               if (event->y > area_iter->totrct.ymin && event->y < area_iter->totrct.ymax) {
-                                       if (is_in_area_actionzone(area_iter, &event->x) == NULL) {
+                       if (xy[0] > area_iter->totrct.xmin && xy[0] < area_iter->totrct.xmax) {
+                               if (xy[1] > area_iter->totrct.ymin && xy[1] < area_iter->totrct.ymax) {
+                                       if (is_in_area_actionzone(area_iter, xy) == NULL) {
                                                sa = area_iter;
                                                break;
                                        }
@@ -1046,7 +1046,7 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
                if (sa) {
                        /* make overlap active when mouse over */
                        for (ar = sa->regionbase.first; ar; ar = ar->next) {
-                               if (BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) {
+                               if (BLI_rcti_isect_pt_v(&ar->winrct, xy)) {
                                        scr->active_region = ar;
                                        break;
                                }
@@ -1079,7 +1079,7 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
                
                /* cursors, for time being set always on edges, otherwise aregion doesnt switch */
                if (scr->active_region == NULL) {
-                       screen_cursor_set(win, event);
+                       screen_cursor_set(win, xy);
                }
                else {
                        /* notifier invokes freeing the buttons... causing a bit too much redraws */
index 99319e009c8420661e6133d52988bc8a9413ad50..b3e9eaeec45ac7b1c9e8d5ff88153bf7f1175f25 100644 (file)
@@ -960,6 +960,7 @@ void wm_draw_update(bContext *C)
                        wm_window_make_drawable(wm, win);
 
                        /* notifiers for screen redraw */
+                       ED_screen_set_active_region(C, &win->eventstate->x);
                        ED_screen_ensure_updated(wm, win, screen);
 
                        int drawmethod = wm_automatic_draw_method(win);
index 218f48e9be66e2b43076949ca567eb741ec67ccd..95ead3befdcab703e3827bf8d46c8381f70aafba 100644 (file)
@@ -2768,7 +2768,7 @@ void wm_event_do_handlers(bContext *C)
                                /* Note: setting subwin active should be done here, after modal handlers have been done */
                                if (event->type == MOUSEMOVE) {
                                        /* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */
-                                       ED_screen_set_active_region(C, event);
+                                       ED_screen_set_active_region(C, &event->x);
                                        /* for regions having custom cursors */
                                        wm_paintcursor_test(C, event);
                                }