Code cleanup: simplify subwindow code.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 14 Feb 2018 02:08:58 +0000 (03:08 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 14 Feb 2018 11:31:13 +0000 (12:31 +0100)
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_screen.h
source/blender/editors/screen/area.c
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_subwindow.c
source/blender/windowmanager/wm_subwindow.h

index a5370313a93558264efcd47cf2487731980de7ea..c70c483097197c9d23961eb392fb55e6e7091587 100644 (file)
@@ -6494,7 +6494,6 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
 
                win->ghostwin = NULL;
                win->eventstate = NULL;
-               win->curswin = NULL;
                win->tweak = NULL;
 #ifdef WIN32
                win->ime_data = NULL;
index 8fa043499f894c663749919b65a6b79d542255d2..01c1e308fb016a279bf1ef94c7da216289065ec9 100644 (file)
@@ -66,7 +66,6 @@ void    ED_region_do_listen(
 void    ED_region_do_draw(struct bContext *C, struct ARegion *ar);
 void    ED_region_exit(struct bContext *C, struct ARegion *ar);
 void    ED_region_pixelspace(struct ARegion *ar);
-void    ED_region_set(const struct bContext *C, struct ARegion *ar);
 void    ED_region_update_rect(struct bContext *C, struct ARegion *ar);
 void    ED_region_init(struct bContext *C, struct ARegion *ar);
 void    ED_region_tag_redraw(struct ARegion *ar);
index 274dbcc73cb60629c72331e89a327c8bf8b65b14..57278307d0b556a409adfde682f9a51bd6d5efcf 100644 (file)
@@ -495,23 +495,6 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
        glDisable(GL_BLEND);
 }
 
-/* only exported for WM */
-/* makes region ready for drawing, sets pixelspace */
-void ED_region_set(const bContext *C, ARegion *ar)
-{
-       wmWindow *win = CTX_wm_window(C);
-       ScrArea *sa = CTX_wm_area(C);
-       
-       ar->drawrct = ar->winrct;
-       
-       /* note; this sets state, so we can use wmOrtho and friends */
-       wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, true);
-       
-       UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0);
-       
-       ED_region_pixelspace(ar);
-}
-
 /* Follow wmMsgNotifyFn spec */
 void ED_region_do_msg_notify_tag_redraw(
         bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)
index 9ec34ac38233591214fe6d60de0259d4b0ef6a7e..698d7dfd621024515cae7f92f2b0212da9dc6a6b 100644 (file)
@@ -208,8 +208,6 @@ typedef struct wmWindow {
 
        struct wmEvent *eventstate;   /* storage for event system */
 
-       struct wmSubWindow *curswin;  /* internal for wm_subwindow.c only */
-
        struct wmGesture *tweak;      /* internal for wm_operators.c */
 
        /* Input Method Editor data - complex character input (esp. for asian character input)
index d103f2291bfc7359823dcd8eb5686e03311e818d..eaee2dae3ac2955f5e5ceefa9f6e5f3f1db78e96 100644 (file)
@@ -616,7 +616,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
                                        CTX_wm_region_set(C, ar);
 
                                        /* make region ready for draw, scissor, pixelspace */
-                                       ED_region_set(C, ar);
+                                       wmSubWindowScissorSet(win, ar->swinid, &ar->winrct, true);
                                        wm_paintcursor_draw(C, ar);
 
                                        CTX_wm_region_set(C, NULL);
@@ -791,7 +791,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
                                        CTX_wm_region_set(C, ar);
 
                                        /* make region ready for draw, scissor, pixelspace */
-                                       ED_region_set(C, ar);
+                                       wmSubWindowScissorSet(win, ar->swinid, &ar->winrct, true);
                                        wm_paintcursor_draw(C, ar);
 
                                        CTX_wm_region_set(C, NULL);
index 1a8f71891c01a86d36d59847e8a8c46799981472..17d69a13aff1fd443beac73c6d446b6aebe652b3 100644 (file)
@@ -91,13 +91,6 @@ void wm_subwindows_free(wmWindow *win)
 }
 
 
-int wm_subwindow_get_id(wmWindow *win)
-{
-       if (win->curswin)
-               return win->curswin->swinid;
-       return 0;
-}
-
 static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid)
 {
        wmSubWindow *swin;
@@ -204,7 +197,7 @@ int wm_subwindow_open(wmWindow *win, const rcti *winrct, bool activate)
                if (freewinid <= swin->swinid)
                        freewinid = swin->swinid + 1;
 
-       win->curswin = swin = MEM_callocN(sizeof(wmSubWindow), "swinopen");
+       swin = MEM_callocN(sizeof(wmSubWindow), "swinopen");
        BLI_addtail(&win->subwindows, swin);
        
        swin->swinid = freewinid;
@@ -228,8 +221,6 @@ void wm_subwindow_close(wmWindow *win, int swinid)
        wmSubWindow *swin = swin_from_swinid(win, swinid);
 
        if (swin) {
-               if (swin == win->curswin)
-                       win->curswin = NULL;
                wm_subwindow_free(swin);
                BLI_remlink(&win->subwindows, swin);
                MEM_freeN(swin);
@@ -285,26 +276,19 @@ void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct, bool a
 /* ---------------- WM versions of OpenGL style API calls ------------------------ */
 /* ----------------- exported in WM_api.h ------------------------------------------------------ */
 
-/* internal state, no threaded opengl! XXX */
-static wmWindow *_curwindow = NULL;
-static wmSubWindow *_curswin = NULL;
-
 void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool srct_pad)
 {
        int width, height;
-       _curswin = swin_from_swinid(win, swinid);
+       wmSubWindow *swin = swin_from_swinid(win, swinid);
        
-       if (_curswin == NULL) {
+       if (swin == NULL) {
                printf("%s %d: doesn't exist\n", __func__, swinid);
                return;
        }
        
-       win->curswin = _curswin;
-       _curwindow = win;
-       
-       width  = BLI_rcti_size_x(&_curswin->winrct) + 1;
-       height = BLI_rcti_size_y(&_curswin->winrct) + 1;
-       glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
+       width  = BLI_rcti_size_x(&swin->winrct) + 1;
+       height = BLI_rcti_size_y(&swin->winrct) + 1;
+       glViewport(swin->winrct.xmin, swin->winrct.ymin, width, height);
        
        if (srct) {
                int scissor_width  = BLI_rcti_size_x(srct);
@@ -320,12 +304,10 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool src
                glScissor(srct->xmin, srct->ymin, scissor_width, scissor_height);
        }
        else
-               glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
+               glScissor(swin->winrct.xmin, swin->winrct.ymin, width, height);
        
        wmOrtho2_pixelspace(width, height);
        gpuLoadIdentity();
-       
-       glFlush();
 }
 
 /* enable the WM versions of opengl calls */
index cc9abf87514774c67654129104286f376ded45d7..77c44d763f7cf634d8707b32f1614929e14987d2 100644 (file)
@@ -38,7 +38,6 @@ void  wm_subwindows_free(wmWindow *win);
 
 int            wm_subwindow_open(wmWindow *win, const rcti *winrct, bool activate);
 void   wm_subwindow_close(wmWindow *win, int swinid);
-int            wm_subwindow_get_id(wmWindow *win);                             /* returns id */
 
 void   wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct, bool activate);