style cleanup: wm, mosyly adding space around ops
authorCampbell Barton <ideasman42@gmail.com>
Tue, 27 Mar 2012 01:24:16 +0000 (01:24 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 27 Mar 2012 01:24:16 +0000 (01:24 +0000)
14 files changed:
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_apple.c
source/blender/windowmanager/intern/wm_cursors.c
source/blender/windowmanager/intern/wm_dragdrop.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_gesture.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_jobs.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_subwindow.c
source/blender/windowmanager/intern/wm_window.c

index 9fd9def..638dd4c 100644 (file)
@@ -69,7 +69,7 @@
 
 /* ****************************************************** */
 
-#define MAX_OP_REGISTERED      32
+#define MAX_OP_REGISTERED   32
 
 void WM_operator_free(wmOperator *op)
 {
@@ -83,7 +83,7 @@ void WM_operator_free(wmOperator *op)
 #endif
 
        if (op->ptr) {
-               op->properties= op->ptr->data;
+               op->properties = op->ptr->data;
                MEM_freeN(op->ptr);
        }
 
@@ -99,7 +99,7 @@ void WM_operator_free(wmOperator *op)
 
        if (op->macro.first) {
                wmOperator *opm, *opmnext;
-               for (opm= op->macro.first; opm; opm= opmnext) {
+               for (opm = op->macro.first; opm; opm = opmnext) {
                        opmnext = opm->next;
                        WM_operator_free(opm);
                }
@@ -118,22 +118,22 @@ static void wm_reports_free(wmWindowManager *wm)
 /* called on event handling by event_system.c */
 void wm_operator_register(bContext *C, wmOperator *op)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        int tot;
 
        BLI_addtail(&wm->operators, op);
-       tot= BLI_countlist(&wm->operators);
+       tot = BLI_countlist(&wm->operators);
        
-       while (tot>MAX_OP_REGISTERED) {
-               wmOperator *opt= wm->operators.first;
+       while (tot > MAX_OP_REGISTERED) {
+               wmOperator *opt = wm->operators.first;
                BLI_remlink(&wm->operators, opt);
                WM_operator_free(opt);
                tot--;
        }
        
        /* so the console is redrawn */
-       WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO_REPORT, NULL);
-       WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL);
+       WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
+       WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL);
 }
 
 
@@ -141,24 +141,24 @@ void WM_operator_stack_clear(wmWindowManager *wm)
 {
        wmOperator *op;
        
-       while ((op= wm->operators.first)) {
+       while ((op = wm->operators.first)) {
                BLI_remlink(&wm->operators, op);
                WM_operator_free(op);
        }
        
-       WM_main_add_notifier(NC_WM|ND_HISTORY, NULL);
+       WM_main_add_notifier(NC_WM | ND_HISTORY, NULL);
 }
 
 /* ****************************************** */
 
-static GHash *menutypes_hash= NULL;
+static GHash *menutypes_hash = NULL;
 
 MenuType *WM_menutype_find(const char *idname, int quiet)
 {
-       MenuTypemt;
+       MenuType *mt;
 
        if (idname[0]) {
-               mt= BLI_ghash_lookup(menutypes_hash, idname);
+               mt = BLI_ghash_lookup(menutypes_hash, idname);
                if (mt)
                        return mt;
        }
@@ -169,13 +169,13 @@ MenuType *WM_menutype_find(const char *idname, int quiet)
        return NULL;
 }
 
-int WM_menutype_add(MenuTypemt)
+int WM_menutype_add(MenuType *mt)
 {
        BLI_ghash_insert(menutypes_hash, (void *)mt->idname, mt);
        return 1;
 }
 
-void WM_menutype_freelink(MenuTypemt)
+void WM_menutype_freelink(MenuType *mt)
 {
        BLI_ghash_remove(menutypes_hash, mt->idname, NULL, (GHashValFreeFP)MEM_freeN);
 }
@@ -183,15 +183,15 @@ void WM_menutype_freelink(MenuType* mt)
 /* called on initialize WM_init() */
 void WM_menutype_init(void)
 {
-       menutypes_hash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh");
+       menutypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh");
 }
 
 void WM_menutype_free(void)
 {
-       GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash);
+       GHashIterator *iter = BLI_ghashIterator_new(menutypes_hash);
 
-       for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
-               MenuType *mt= BLI_ghashIterator_getValue(iter);
+       for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+               MenuType *mt = BLI_ghashIterator_getValue(iter);
                if (mt->ext.free) {
                        mt->ext.free(mt->ext.data);
                }
@@ -199,22 +199,22 @@ void WM_menutype_free(void)
        BLI_ghashIterator_free(iter);
 
        BLI_ghash_free(menutypes_hash, NULL, (GHashValFreeFP)MEM_freeN);
-       menutypes_hash= NULL;
+       menutypes_hash = NULL;
 }
 
 /* ****************************************** */
 
 void WM_keymap_init(bContext *C)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
 
        /* create standard key configs */
        if (!wm->defaultconf)
-               wm->defaultconf= WM_keyconfig_new(wm, "Blender");
+               wm->defaultconf = WM_keyconfig_new(wm, "Blender");
        if (!wm->addonconf)
-               wm->addonconf= WM_keyconfig_new(wm, "Blender Addon");
+               wm->addonconf = WM_keyconfig_new(wm, "Blender Addon");
        if (!wm->userconf)
-               wm->userconf= WM_keyconfig_new(wm, "Blender User");
+               wm->userconf = WM_keyconfig_new(wm, "Blender User");
        
        /* initialize only after python init is done, for keymaps that
         * use python operators */
@@ -237,15 +237,15 @@ void WM_keymap_init(bContext *C)
 
 void WM_check(bContext *C)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        
        /* wm context */
-       if (wm==NULL) {
-               wm= CTX_data_main(C)->wm.first;
+       if (wm == NULL) {
+               wm = CTX_data_main(C)->wm.first;
                CTX_wm_manager_set(C, wm);
        }
-       if (wm==NULL) return;
-       if (wm->windows.first==NULL) return;
+       if (wm == NULL) return;
+       if (wm->windows.first == NULL) return;
 
        if (!G.background) {
                /* case: fileread */
@@ -268,18 +268,18 @@ void WM_check(bContext *C)
 
 void wm_clear_default_size(bContext *C)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win;
        
        /* wm context */
-       if (wm==NULL) {
-               wm= CTX_data_main(C)->wm.first;
+       if (wm == NULL) {
+               wm = CTX_data_main(C)->wm.first;
                CTX_wm_manager_set(C, wm);
        }
-       if (wm==NULL) return;
-       if (wm->windows.first==NULL) return;
+       if (wm == NULL) return;
+       if (wm->windows.first == NULL) return;
        
-       for (win= wm->windows.first; win; win= win->next) {
+       for (win = wm->windows.first; win; win = win->next) {
                win->sizex = 0;
                win->sizey = 0;
                win->posx = 0;
@@ -291,18 +291,18 @@ void wm_clear_default_size(bContext *C)
 /* on startup, it adds all data, for matching */
 void wm_add_default(bContext *C)
 {
-       wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan");
+       wmWindowManager *wm = alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan");
        wmWindow *win;
-       bScreen *screen= CTX_wm_screen(C); /* XXX from file read hrmf */
+       bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */
        
        CTX_wm_manager_set(C, wm);
-       win= wm_window_new(C);
-       win->screen= screen;
-       screen->winid= win->winid;
-       BLI_strncpy(win->screenname, screen->id.name+2, sizeof(win->screenname));
+       win = wm_window_new(C);
+       win->screen = screen;
+       screen->winid = win->winid;
+       BLI_strncpy(win->screenname, screen->id.name + 2, sizeof(win->screenname));
        
-       wm->winactive= win;
-       wm->file_saved= 1;
+       wm->winactive = win;
+       wm->file_saved = 1;
        wm_window_make_drawable(C, win); 
 }
 
@@ -317,19 +317,19 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
        if (wm->autosavetimer)
                wm_autosave_timer_ended(wm);
 
-       while ((win= wm->windows.first)) {
+       while ((win = wm->windows.first)) {
                BLI_remlink(&wm->windows, win);
-               win->screen= NULL; /* prevent draw clear to use screen */
+               win->screen = NULL; /* prevent draw clear to use screen */
                wm_draw_window_clear(win);
                wm_window_free(C, wm, win);
        }
        
-       while ((op= wm->operators.first)) {
+       while ((op = wm->operators.first)) {
                BLI_remlink(&wm->operators, op);
                WM_operator_free(op);
        }
 
-       while ((keyconf=wm->keyconfigs.first)) {
+       while ((keyconf = wm->keyconfigs.first)) {
                BLI_remlink(&wm->keyconfigs, keyconf);
                WM_keyconfig_free(keyconf);
        }
@@ -341,14 +341,14 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
        
        wm_reports_free(wm);
        
-       if (C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL);
+       if (C && CTX_wm_manager(C) == wm) CTX_wm_manager_set(C, NULL);
 }
 
 void wm_close_and_free_all(bContext *C, ListBase *wmlist)
 {
        wmWindowManager *wm;
        
-       while ((wm=wmlist->first)) {
+       while ((wm = wmlist->first)) {
                wm_close_and_free(C, wm);
                BLI_remlink(wmlist, wm);
                MEM_freeN(wm);
index a79d20f..1617253 100644 (file)
@@ -62,23 +62,23 @@ static int checkAppleVideoCard(void)
        long value;
        long maxvram = 0;   /* we get always more than 1 renderer, check one, at least, has 8 Mo */
        
-       display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() );     
+       display_mask = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID() );
        
-       theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend);
+       theErr = CGLQueryRendererInfo(display_mask, &rend, &nrend);
        if (theErr == 0) {
-               theErr = CGLDescribeRenderer (rend, 0, kCGLRPRendererCount, &nrend);
+               theErr = CGLDescribeRenderer(rend, 0, kCGLRPRendererCount, &nrend);
                if (theErr == 0) {
                        for (j = 0; j < nrend; j++) {
-                               theErr = CGLDescribeRenderer (rend, j, kCGLRPVideoMemory, &value); 
+                               theErr = CGLDescribeRenderer(rend, j, kCGLRPVideoMemory, &value);
                                if (value > maxvram)
                                        maxvram = value;
                                if ((theErr == 0) && (value >= 20000000)) {
-                                       theErr = CGLDescribeRenderer (rend, j, kCGLRPAccelerated, &value); 
+                                       theErr = CGLDescribeRenderer(rend, j, kCGLRPAccelerated, &value);
                                        if ((theErr == 0) && (value != 0)) {
-                                               theErr = CGLDescribeRenderer (rend, j, kCGLRPCompliant, &value); 
+                                               theErr = CGLDescribeRenderer(rend, j, kCGLRPCompliant, &value);
                                                if ((theErr == 0) && (value != 0)) {
                                                        /*fprintf(stderr,"make it big\n");*/
-                                                       CGLDestroyRendererInfo (rend);
+                                                       CGLDestroyRendererInfo(rend);
                                                        macPrefState = 8;
                                                        return 1;
                                                }
@@ -87,18 +87,18 @@ static int checkAppleVideoCard(void)
                        }
                }
        }
-       if (maxvram < 7500000 ) {       /* put a standard alert and quit*/ 
+       if (maxvram < 7500000) {        /* put a standard alert and quit*/
                SInt16 junkHit;
-               char  inError[] = "* Not enough VRAM    ";
-               char  inText[] = "* blender needs at least 8Mb    ";
+               char inError[] = "* Not enough VRAM    ";
+               char inText[] = "* blender needs at least 8Mb    ";
                inError[0] = 16;
                inText[0] = 28;
                
                fprintf(stderr, " vram is %li . not enough, aborting\n", maxvram);
-               StandardAlert (   kAlertStopAlert, (ConstStr255Param) &inError, (ConstStr255Param)&inText,NULL,&junkHit);
+               StandardAlert(kAlertStopAlert, (ConstStr255Param) & inError, (ConstStr255Param) & inText, NULL, &junkHit);
                abort();
        }
-       CGLDestroyRendererInfo (rend);
+       CGLDestroyRendererInfo(rend);
        return 0;
 }
 
@@ -106,7 +106,7 @@ static void getMacAvailableBounds(short *top, short *left, short *bottom, short
 {
        Rect outAvailableRect;
        
-       GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
+       GetAvailableWindowPositioningBounds(GetMainDevice(), &outAvailableRect);
        
        *top = outAvailableRect.top;  
        *left = outAvailableRect.left;
@@ -124,14 +124,14 @@ void wm_set_apple_prefsize(int scr_x, int scr_y)
                short top, left, bottom, right;
                
                getMacAvailableBounds(&top, &left, &bottom, &right);
-               WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
-               G.windowstate= 0;
+               WM_setprefsize(left + 10, scr_y - bottom + 10, right - left - 20, bottom - 64);
+               G.windowstate = 0;
                
        }
        else {
                
                /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
                WM_setprefsize(120, 40, 850, 684);
-               G.windowstate= 0;
+               G.windowstate = 0;
        }
 }
index 2f0a118..80a2591 100644 (file)
 /* Some simple ghost <-> blender conversions */
 static GHOST_TStandardCursor convert_cursor(int curs) 
 {
-       switch(curs) {
+       switch (curs) {
                default:
-               case CURSOR_STD:                return GHOST_kStandardCursorDefault;
-               case CURSOR_FACESEL:    return GHOST_kStandardCursorRightArrow;
-               case CURSOR_WAIT:               return GHOST_kStandardCursorWait;
-               case CURSOR_EDIT:               return GHOST_kStandardCursorCrosshair;
+               case CURSOR_STD:        return GHOST_kStandardCursorDefault;
+               case CURSOR_FACESEL:    return GHOST_kStandardCursorRightArrow;
+               case CURSOR_WAIT:       return GHOST_kStandardCursorWait;
+               case CURSOR_EDIT:       return GHOST_kStandardCursorCrosshair;
                case CURSOR_HELP:               
 #ifdef __APPLE__
                        return GHOST_kStandardCursorLeftRight;
 #else
                        return GHOST_kStandardCursorHelp;
 #endif
-               case CURSOR_X_MOVE:             return GHOST_kStandardCursorLeftRight;
-               case CURSOR_Y_MOVE:             return GHOST_kStandardCursorUpDown;
-               case CURSOR_PENCIL:             return GHOST_kStandardCursorPencil;
-               case CURSOR_COPY:               return GHOST_kStandardCursorCopy;
+               case CURSOR_X_MOVE:     return GHOST_kStandardCursorLeftRight;
+               case CURSOR_Y_MOVE:     return GHOST_kStandardCursorUpDown;
+               case CURSOR_PENCIL:     return GHOST_kStandardCursorPencil;
+               case CURSOR_COPY:       return GHOST_kStandardCursorCopy;
        }
 }
 
 static void window_set_custom_cursor(wmWindow *win, unsigned char mask[16][2], 
-                                                         unsigned char bitmap[16][2], int hotx, int hoty) 
+                                     unsigned char bitmap[16][2], int hotx, int hoty)
 {
        GHOST_SetCustomCursorShape(win->ghostwin, bitmap, mask, hotx, hoty);
 }
@@ -84,17 +84,17 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB
 {
        if (useBig) {
                GHOST_SetCustomCursorShapeEx(win->ghostwin, 
-                                                                        (GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask, 
-                                                                        cursor->big_sizex,cursor->big_sizey,
-                                                                        cursor->big_hotx,cursor->big_hoty,
-                                                                        cursor->fg_color, cursor->bg_color);
+                                            (GHOST_TUns8 *)cursor->big_bm, (GHOST_TUns8 *)cursor->big_mask,
+                                            cursor->big_sizex, cursor->big_sizey,
+                                            cursor->big_hotx, cursor->big_hoty,
+                                            cursor->fg_color, cursor->bg_color);
        }
        else {
                GHOST_SetCustomCursorShapeEx(win->ghostwin, 
-                                                                        (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask, 
-                                                                        cursor->small_sizex,cursor->small_sizey,
-                                                                        cursor->small_hotx,cursor->small_hoty,
-                                                                        cursor->fg_color, cursor->bg_color);
+                                            (GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask,
+                                            cursor->small_sizex, cursor->small_sizey,
+                                            cursor->small_hotx, cursor->small_hoty,
+                                            cursor->fg_color, cursor->bg_color);
        }
 }
 
@@ -105,9 +105,9 @@ static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs
 void WM_cursor_set(wmWindow *win, int curs)
 {
 
-       if (win==NULL) return; /* Can't set custom cursor before Window init */
+       if (win == NULL) return;  /* Can't set custom cursor before Window init */
 
-       if (curs==CURSOR_NONE) {
+       if (curs == CURSOR_NONE) {
                GHOST_SetCursorVisibility(win->ghostwin, 0);
                return;
        }
@@ -115,28 +115,28 @@ void WM_cursor_set(wmWindow *win, int curs)
 #ifdef _WIN32
        /* the default win32 cross cursor is barely visible,
         * only 1 pixel thick, use another one instead */
-       if (curs==CURSOR_EDIT)
-               curs= BC_CROSSCURSOR;
+       if (curs == CURSOR_EDIT)
+               curs = BC_CROSSCURSOR;
 #endif
 
        GHOST_SetCursorVisibility(win->ghostwin, 1);
        
        if (curs == CURSOR_STD && win->modalcursor)
-               curs= win->modalcursor;
+               curs = win->modalcursor;
        
-       win->cursor= curs;
+       win->cursor = curs;
        
        /* detect if we use system cursor or Blender cursor */
-       if (curs>=BC_GHOST_CURSORS) {
+       if (curs >= BC_GHOST_CURSORS) {
                GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs));
        }
        else {
-               if ((curs<SYSCURSOR) || (curs>=BC_NUMCURSORS)) return;  
+               if ((curs < SYSCURSOR) || (curs >= BC_NUMCURSORS)) return;
 
-               if (curs==SYSCURSOR) {  /* System default Cursor */
+               if (curs == SYSCURSOR) {  /* System default Cursor */
                        GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD));
                }
-               else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) {
+               else if ( (U.curssize == 0) || (BlenderCursor[curs]->big_bm == NULL) ) {
                        window_set_custom_cursor_ex(win, BlenderCursor[curs], 0);
                }
                else {
@@ -165,10 +165,10 @@ void WM_cursor_restore(wmWindow *win)
 void WM_cursor_wait(int val)
 {
        if (!G.background) {
-               wmWindowManager *wm= G.main->wm.first;
-               wmWindow *win= wm?wm->windows.first:NULL; 
+               wmWindowManager *wm = G.main->wm.first;
+               wmWindow *win = wm ? wm->windows.first : NULL;
                
-               for (; win; win= win->next) {
+               for (; win; win = win->next) {
                        if (val) {
                                WM_cursor_modal(win, BC_WAITCURSOR);
                        }
@@ -186,11 +186,11 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds)
         * */
        GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
 
-       if (hide)               mode = GHOST_kGrabHide;
-       else if (wrap)  mode = GHOST_kGrabWrap;
+       if (hide) mode = GHOST_kGrabHide;
+       else if (wrap) mode = GHOST_kGrabWrap;
        if ((G.f & G_DEBUG) == 0) {
                if (win && win->ghostwin) {
-                       const GHOST_TabletData *tabletdata= GHOST_GetTabletData(win->ghostwin);
+                       const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin);
                        // Note: There is no tabletdata on Windows if no tablet device is connected.
                        if (!tabletdata)
                                GHOST_SetCursorGrab(win->ghostwin, mode, bounds);
@@ -215,22 +215,22 @@ void WM_cursor_ungrab(wmWindow *win)
 /* give it a modal keymap one day? */
 int wm_cursor_arrow_move(wmWindow *win, wmEvent *event)
 {
-       if (win && event->val==KM_PRESS) {
+       if (win && event->val == KM_PRESS) {
                
-               if (event->type==UPARROWKEY) {
-                       WM_cursor_warp(win, event->x, event->y+1);
+               if (event->type == UPARROWKEY) {
+                       WM_cursor_warp(win, event->x, event->y + 1);
                        return 1;
                }
-               else if (event->type==DOWNARROWKEY) {
-                       WM_cursor_warp(win, event->x, event->y-1);
+               else if (event->type == DOWNARROWKEY) {
+                       WM_cursor_warp(win, event->x, event->y - 1);
                        return 1;
                }
-               else if (event->type==LEFTARROWKEY) {
-                       WM_cursor_warp(win, event->x-1, event->y);
+               else if (event->type == LEFTARROWKEY) {
+                       WM_cursor_warp(win, event->x - 1, event->y);
                        return 1;
                }
-               else if (event->type==RIGHTARROWKEY) {
-                       WM_cursor_warp(win, event->x+1, event->y);
+               else if (event->type == RIGHTARROWKEY) {
+                       WM_cursor_warp(win, event->x + 1, event->y);
                        return 1;
                }
        }
@@ -242,36 +242,36 @@ int wm_cursor_arrow_move(wmWindow *win, wmEvent *event)
 void WM_timecursor(wmWindow *win, int nr)
 {
        /* 10 8x8 digits */
-       static char number_bitmaps[10][8]= {
-       {0,  56,  68,  68,  68,  68,  68,  56}, 
-       {0,  24,  16,  16,  16,  16,  16,  56}, 
-       {0,  60,  66,  32,  16,   8,   4, 126}, 
-       {0, 124,  32,  16,  56,  64,  66,  60}, 
-       {0,  32,  48,  40,  36, 126,  32,  32}, 
-       {0, 124,   4,  60,  64,  64,  68,  56}, 
-       {0,  56,   4,   4,  60,  68,  68,  56}, 
-       {0, 124,  64,  32,  16,   8,   8,   8}, 
-       {0,  60,  66,  66,  60,  66,  66,  60}, 
-       {0,  56,  68,  68, 120,  64,  68,  56} 
+       static char number_bitmaps[10][8] = {
+               {0,  56,  68,  68,  68,  68,  68,  56},
+               {0,  24,  16,  16,  16,  16,  16,  56},
+               {0,  60,  66,  32,  16,   8,   4, 126},
+               {0, 124,  32,  16,  56,  64,  66,  60},
+               {0,  32,  48,  40,  36, 126,  32,  32},
+               {0, 124,   4,  60,  64,  64,  68,  56},
+               {0,  56,   4,   4,  60,  68,  68,  56},
+               {0, 124,  64,  32,  16,   8,   8,   8},
+               {0,  60,  66,  66,  60,  66,  66,  60},
+               {0,  56,  68,  68, 120,  64,  68,  56}
        };
        unsigned char mask[16][2];
-       unsigned char bitmap[16][2]= {{0}};
+       unsigned char bitmap[16][2] = {{0}};
        int i, idx;
        
        if (win->lastcursor == 0)
-               win->lastcursor= win->cursor; 
+               win->lastcursor = win->cursor;
        
        memset(&mask, 0xFF, sizeof(mask));
        
        /* print number bottom right justified */
-       for (idx= 3; nr && idx>=0; idx--) {
-               char *digit= number_bitmaps[nr%10];
-               int x = idx%2;
-               int y = idx/2;
-               
-               for (i=0; i<8; i++)
-                       bitmap[i + y*8][x]= digit[i];
-               nr/= 10;
+       for (idx = 3; nr && idx >= 0; idx--) {
+               char *digit = number_bitmaps[nr % 10];
+               int x = idx % 2;
+               int y = idx / 2;
+
+               for (i = 0; i < 8; i++)
+                       bitmap[i + y * 8][x] = digit[i];
+               nr /= 10;
        }
        
        window_set_custom_cursor(win, mask, bitmap, 7, 7);
@@ -324,78 +324,78 @@ void wm_init_cursor_data(void)
 {
        /********************** NW_ARROW Cursor **************************/
 BEGIN_CURSOR_BLOCK
-               static char nw_sbm[]={
-                       0x03,  0x00,  0x05,  0x00,  0x09,  0x00,  0x11,  0x00,
-                               0x21,  0x00,  0x41,  0x00,  0x81,  0x00,  0x01,  0x01,
-                               0x01,  0x02,  0xc1,  0x03,  0x49,  0x00,  0x8d,  0x00,
-                               0x8b,  0x00,  0x10,  0x01,  0x90,  0x01,  0x60,  0x00,
-               };
-
-               static char nw_smsk[]={
-                       0x03,  0x00,  0x07,  0x00,  0x0f,  0x00,  0x1f,  0x00,
-                               0x3f,  0x00,  0x7f,  0x00,  0xff,  0x00,  0xff,  0x01,
-                               0xff,  0x03,  0xff,  0x03,  0x7f,  0x00,  0xff,  0x00,
-                               0xfb,  0x00,  0xf0,  0x01,  0xf0,  0x01,  0x60,  0x00,
-               };
-
-               static BCursor NWArrowCursor = {
-                       /*small*/
-                       nw_sbm, nw_smsk,
-                               16, 16, 
-                               6,  7,
-                               /*big*/
-                               NULL, NULL,
-                               32,32, 
-                               15, 15,
-                               /*color*/
-                               BC_BLACK, BC_WHITE
-               };
-
-               BlenderCursor[BC_NW_ARROWCURSOR]=&NWArrowCursor;
+       static char nw_sbm[] = {
+               0x03,  0x00,  0x05,  0x00,  0x09,  0x00,  0x11,  0x00,
+               0x21,  0x00,  0x41,  0x00,  0x81,  0x00,  0x01,  0x01,
+               0x01,  0x02,  0xc1,  0x03,  0x49,  0x00,  0x8d,  0x00,
+               0x8b,  0x00,  0x10,  0x01,  0x90,  0x01,  0x60,  0x00,
+       };
+
+       static char nw_smsk[] = {
+               0x03,  0x00,  0x07,  0x00,  0x0f,  0x00,  0x1f,  0x00,
+               0x3f,  0x00,  0x7f,  0x00,  0xff,  0x00,  0xff,  0x01,
+               0xff,  0x03,  0xff,  0x03,  0x7f,  0x00,  0xff,  0x00,
+               0xfb,  0x00,  0xf0,  0x01,  0xf0,  0x01,  0x60,  0x00,
+       };
+
+       static BCursor NWArrowCursor = {
+               /*small*/
+               nw_sbm, nw_smsk,
+               16, 16,
+               6,  7,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_NW_ARROWCURSOR] = &NWArrowCursor;
 END_CURSOR_BLOCK
 
        ///********************** NS_ARROW Cursor *************************/
 BEGIN_CURSOR_BLOCK
-               static char ns_sbm[]={
-                       0x40,  0x01,  0x20,  0x02,  0x10,  0x04,  0x08,  0x08,
-                               0x04,  0x10,  0x3c,  0x1e,  0x20,  0x02,  0x20,  0x02,
-                               0x20,  0x02,  0x20,  0x02,  0x3c,  0x1e,  0x04,  0x10,
-                               0x08,  0x08,  0x10,  0x04,  0x20,  0x02,  0x40,  0x01
-               };
-
-               static char ns_smsk[]={
-                       0xc0,  0x01,  0xe0,  0x03,  0xf0,  0x07,  0xf8,  0x0f,
-                               0xfc,  0x1f,  0xfc,  0x1f,  0xe0,  0x03,  0xe0,  0x03,
-                               0xe0,  0x03,  0xe0,  0x03,  0xfc,  0x1f,  0xfc,  0x1f,
-                               0xf8,  0x0f,  0xf0,  0x07,  0xe0,  0x03,  0xc0,  0x01
-               };
-
-               static BCursor NSArrowCursor = {
-                       /*small*/
-                       ns_sbm, ns_smsk,
-                               16, 16, 
-                               6,  7,
-                               /*big*/
-                               NULL, NULL,
-                               32,32, 
-                               15, 15,
-                               /*color*/
-                               BC_BLACK, BC_WHITE
-               };
-
-               BlenderCursor[BC_NS_ARROWCURSOR]=&NSArrowCursor;
+       static char ns_sbm[] = {
+               0x40,  0x01,  0x20,  0x02,  0x10,  0x04,  0x08,  0x08,
+               0x04,  0x10,  0x3c,  0x1e,  0x20,  0x02,  0x20,  0x02,
+               0x20,  0x02,  0x20,  0x02,  0x3c,  0x1e,  0x04,  0x10,
+               0x08,  0x08,  0x10,  0x04,  0x20,  0x02,  0x40,  0x01
+       };
+
+       static char ns_smsk[] = {
+               0xc0,  0x01,  0xe0,  0x03,  0xf0,  0x07,  0xf8,  0x0f,
+               0xfc,  0x1f,  0xfc,  0x1f,  0xe0,  0x03,  0xe0,  0x03,
+               0xe0,  0x03,  0xe0,  0x03,  0xfc,  0x1f,  0xfc,  0x1f,
+               0xf8,  0x0f,  0xf0,  0x07,  0xe0,  0x03,  0xc0,  0x01
+       };
+
+       static BCursor NSArrowCursor = {
+               /*small*/
+               ns_sbm, ns_smsk,
+               16, 16,
+               6,  7,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_NS_ARROWCURSOR] = &NSArrowCursor;
                
 END_CURSOR_BLOCK
        /********************** EW_ARROW Cursor *************************/
 BEGIN_CURSOR_BLOCK
-       static char ew_sbm[]={
+       static char ew_sbm[] = {
                0x00,  0x00,  0x00,  0x00,  0x10,  0x08,  0x38,  0x1c,
                0x2c,  0x34,  0xe6,  0x67,  0x03,  0xc0,  0x01,  0x80,
                0x03,  0xc0,  0xe6,  0x67,  0x2c,  0x34,  0x38,  0x1c,
                0x10,  0x08,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
        };
 
-       static char ew_smsk[]={
+       static char ew_smsk[] = {
                0x00,  0x00,  0x00,  0x00,  0x10,  0x08,  0x38,  0x1c,
                0x3c,  0x3c,  0xfe,  0x7f,  0xff,  0xff,  0xff,  0xff,
                0xff,  0xff,  0xfe,  0x7f,  0x3c,  0x3c,  0x38,  0x1c,
@@ -409,32 +409,32 @@ BEGIN_CURSOR_BLOCK
                7,  6,
                /*big*/
                NULL, NULL,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_EW_ARROWCURSOR]=&EWArrowCursor;
+       BlenderCursor[BC_EW_ARROWCURSOR] = &EWArrowCursor;
 END_CURSOR_BLOCK
 
        /********************** Wait Cursor *****************************/
 BEGIN_CURSOR_BLOCK
-       static char wait_sbm[]={
+       static char wait_sbm[] = {
                0xfe,  0x7f,  0x02,  0x40,  0x02,  0x40,  0x84,  0x21,
                0xc8,  0x13,  0xd0,  0x0b,  0xa0,  0x04,  0x20,  0x05,
                0xa0,  0x04,  0x10,  0x09,  0x88,  0x11,  0xc4,  0x23,
                0xe2,  0x47,  0xfa,  0x5f,  0x02,  0x40,  0xfe,  0x7f,
        };
 
-       static char wait_smsk[]={
+       static char wait_smsk[] = {
                0xfe,  0x7f,  0xfe,  0x7f,  0x06,  0x60,  0x8c,  0x31,
                0xd8,  0x1b,  0xf0,  0x0f,  0xe0,  0x06,  0x60,  0x07,
                0xe0,  0x06,  0x30,  0x0d,  0x98,  0x19,  0xcc,  0x33,
                0xe6,  0x67,  0xfe,  0x7f,  0xfe,  0x7f,  0xfe,  0x7f,
        };
 
-       static char wait_lbm[]={
+       static char wait_lbm[] = {
                0xfc,  0xff,  0xff,  0x3f,  0xfc,  0xff,  0xff,  0x3f,
                0x0c,  0x00,  0x00,  0x30,  0x0c,  0x00,  0x00,  0x30,
                0x0c,  0x00,  0x00,  0x30,  0x0c,  0x00,  0x00,  0x18,
@@ -453,7 +453,7 @@ BEGIN_CURSOR_BLOCK
                0xfc,  0xff,  0xff,  0x3f,  0xfc,  0xff,  0xff,  0x3f,
        };
 
-       static char wait_lmsk[]={
+       static char wait_lmsk[] = {
                0xfc,  0xff,  0xff,  0x3f,  0xfc,  0xff,  0xff,  0x3f,
                0xfc,  0xff,  0xff,  0x3f,  0xfc,  0xff,  0xff,  0x3f,
                0x3c,  0x00,  0x00,  0x3c,  0x3c,  0x00,  0x00,  0x1e,
@@ -474,36 +474,36 @@ BEGIN_CURSOR_BLOCK
 
        static BCursor WaitCursor = {
                /*small*/
-       wait_sbm, wait_smsk,
+               wait_sbm, wait_smsk,
                16, 16, 
                7,  7,
                /*big*/
                wait_lbm, wait_lmsk,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_WAITCURSOR]=&WaitCursor;
+       BlenderCursor[BC_WAITCURSOR] = &WaitCursor;
 END_CURSOR_BLOCK
 
        /********************** Cross Cursor ***************************/
 BEGIN_CURSOR_BLOCK
-       static char cross_sbm[]={
+       static char cross_sbm[] = {
                0x00,  0x00,  0x80,  0x01,  0x80,  0x01,  0x80,  0x01,
                0x80,  0x01,  0x80,  0x01,  0x80,  0x01,  0x7e,  0x7e,
                0x7e,  0x7e,  0x80,  0x01,  0x80,  0x01,  0x80,  0x01,
                0x80,  0x01,  0x80,  0x01,  0x80,  0x01,  0x00,  0x00,
        };
 
-       static char cross_smsk[]={
+       static char cross_smsk[] = {
                0x80,  0x01,  0x80,  0x01,  0x80,  0x01,  0x80,  0x01,
                0x80,  0x01,  0x80,  0x01,  0xc0,  0x03,  0x7f,  0xfe,
                0x7f,  0xfe,  0xc0,  0x03,  0x80,  0x01,  0x80,  0x01,
                0x80,  0x01,  0x80,  0x01,  0x80,  0x01,  0x80,  0x01,
        };
-       static char cross_lbm[]={
+       static char cross_lbm[] = {
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
                0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
                0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
@@ -522,7 +522,7 @@ BEGIN_CURSOR_BLOCK
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
        };
 
-       static char cross_lmsk[]={
+       static char cross_lmsk[] = {
                0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
                0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
                0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
@@ -548,25 +548,25 @@ BEGIN_CURSOR_BLOCK
                7,  7,
                /*big*/
                cross_lbm, cross_lmsk,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_CROSSCURSOR]=&CrossCursor;
+       BlenderCursor[BC_CROSSCURSOR] = &CrossCursor;
 END_CURSOR_BLOCK
 
        /********************** EditCross Cursor ***********************/       
 BEGIN_CURSOR_BLOCK
-       static char editcross_sbm[]={
+       static char editcross_sbm[] = {
                0x0e,  0x00,  0x11,  0x00,  0x1d,  0x00,  0x19,  0x03,
                0x1d,  0x03,  0x11,  0x03,  0x0e,  0x03,  0x00,  0x03,
                0xf8,  0x7c,  0xf8,  0x7c,  0x00,  0x03,  0x00,  0x03,
                0x00,  0x03,  0x00,  0x03,  0x00,  0x03,  0x00,  0x00,
        };
 
-       static char editcross_smsk[]={
+       static char editcross_smsk[] = {
                0x0e,  0x00,  0x1f,  0x00,  0x1f,  0x03,  0x1f,  0x03,
                0x1f,  0x03,  0x1f,  0x03,  0x0e,  0x03,  0x80,  0x07,
                0xfc,  0xfc,  0xfc,  0xfc,  0x80,  0x07,  0x00,  0x03,
@@ -580,26 +580,26 @@ BEGIN_CURSOR_BLOCK
                9,  8,
                /*big*/
                NULL, NULL,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_EDITCROSSCURSOR]=&EditCrossCursor;
+       BlenderCursor[BC_EDITCROSSCURSOR] = &EditCrossCursor;
 END_CURSOR_BLOCK
 
        /********************** Box Select *************************/
 BEGIN_CURSOR_BLOCK
-       static char box_sbm[32]={
-       0x7f,  0x00,  0x41,  0x00,  0x41,  0x00,  0x41,  0x06,
+       static char box_sbm[32] = {
+               0x7f,  0x00,  0x41,  0x00,  0x41,  0x00,  0x41,  0x06,
                0x41,  0x06,  0x41,  0x06,  0x7f,  0x06,  0x00,  0x06,
                0xe0,  0x79,  0xe0,  0x79,  0x00,  0x06,  0x00,  0x06,
                0x00,  0x06,  0x00,  0x06,  0x00,  0x06,  0x00,  0x00,
        };
 
-       static char box_smsk[32]={
-       0x7f,  0x00,  0x7f,  0x00,  0x63,  0x06,  0x63,  0x06,
+       static char box_smsk[32] = {
+               0x7f,  0x00,  0x7f,  0x00,  0x63,  0x06,  0x63,  0x06,
                0x63,  0x06,  0x7f,  0x06,  0x7f,  0x06,  0x00,  0x0f,
                0xf0,  0xf9,  0xf0,  0xf9,  0x00,  0x0f,  0x00,  0x06,
                0x00,  0x06,  0x00,  0x06,  0x00,  0x06,  0x00,  0x06,
@@ -613,32 +613,32 @@ BEGIN_CURSOR_BLOCK
                9,  8,
                /*big*/
                NULL, NULL,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_BOXSELCURSOR]=&BoxSelCursor;
+       BlenderCursor[BC_BOXSELCURSOR] = &BoxSelCursor;
 
 END_CURSOR_BLOCK
        /********************** Knife Cursor ***********************/
 BEGIN_CURSOR_BLOCK
-       static char knife_sbm[]={
+       static char knife_sbm[] = {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x2c,
                0x00, 0x5a, 0x00, 0x34, 0x00, 0x2a, 0x00, 0x17,
                0x80, 0x06, 0x40, 0x03, 0xa0, 0x03, 0xd0, 0x01,
                0x68, 0x00, 0x1c, 0x00, 0x06, 0x00, 0x00, 0x00
        };
 
-       static char knife_smsk[]={
+       static char knife_smsk[] = {
                0x00, 0x60, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0xfe,
                0x00, 0xfe, 0x00, 0x7e, 0x00, 0x7f, 0x80, 0x3f,
                0xc0, 0x0e, 0x60, 0x07, 0xb0, 0x07, 0xd8, 0x03,
                0xec, 0x01, 0x7e, 0x00, 0x1f, 0x00, 0x07, 0x00
        };
 
-       static char knife_lbm[]={
+       static char knife_lbm[] = {
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
                0x00,  0x00,  0x00,  0x08,  0x00,  0x00,  0x00,  0x1c,
@@ -658,7 +658,7 @@ BEGIN_CURSOR_BLOCK
 
        };
 
-       static char knife_lmsk[]={
+       static char knife_lmsk[] = {
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x18,
                0x00,  0x00,  0x00,  0x3c,  0x00,  0x00,  0x00,  0x7e,
@@ -680,41 +680,41 @@ BEGIN_CURSOR_BLOCK
 
        static BCursor KnifeCursor = {
                /*small*/
-       knife_sbm, knife_smsk,
+               knife_sbm, knife_smsk,
                16, 16, 
                0,  15,
                /*big*/
                knife_lbm, knife_lmsk,
-               32,32, 
+               32, 32,
                0, 31,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_KNIFECURSOR]=&KnifeCursor;
+       BlenderCursor[BC_KNIFECURSOR] = &KnifeCursor;
 
 END_CURSOR_BLOCK
        
        /********************** Loop Select Cursor ***********************/
 BEGIN_CURSOR_BLOCK
 
-static char vloop_sbm[]={
+       static char vloop_sbm[] = {
                0x00,  0x00,  0x7e,  0x00,  0x3e,  0x00,  0x1e,  0x00,
                0x0e,  0x00,  0x66,  0x60,  0x62,  0x6f,  0x00,  0x00,
                0x20,  0x20,  0x20,  0x20,  0x20,  0x20,  0x20,  0x20,
                0x00,  0x00,  0x60,  0x60,  0x60,  0x6f,  0x00,  0x00,
-};
+       };
 
-static char vloop_smsk[]={
+       static char vloop_smsk[] = {
                0xff,  0x01,  0xff,  0x00,  0x7f,  0x00,  0x3f,  0x00,
                0xff,  0xf0,  0xff,  0xff,  0xf7,  0xff,  0xf3,  0xf0,
                0x61,  0x60,  0x60,  0x60,  0x60,  0x60,  0x60,  0x60,
                0xf0,  0xf0,  0xf0,  0xff,  0xf0,  0xff,  0xf0,  0xf0,
-};
+       };
 
 
 
-static char vloop_lbm[]={
+       static char vloop_lbm[] = {
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
                0xfc,  0x3f,  0x00,  0x00,  0xfc,  0x3f,  0x00,  0x00,
                0xfc,  0x0f,  0x00,  0x00,  0xfc,  0x0f,  0x00,  0x00,
@@ -731,9 +731,9 @@ static char vloop_lbm[]={
                0x00,  0x3c,  0x00,  0x3c,  0x00,  0x3c,  0x00,  0x3c,
                0x00,  0x3c,  0xff,  0x3c,  0x00,  0x3c,  0xff,  0x3c,
                0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
-};
+       };
 
-static char vloop_lmsk[]={
+       static char vloop_lmsk[] = {
                0xff,  0xff,  0x03,  0x00,  0xff,  0xff,  0x03,  0x00,
                0xff,  0xff,  0x00,  0x00,  0xff,  0xff,  0x00,  0x00,
                0xff,  0x3f,  0x00,  0x00,  0xff,  0x3f,  0x00,  0x00,
@@ -750,38 +750,38 @@ static char vloop_lmsk[]={
                0x00,  0xff,  0xff,  0xff,  0x00,  0xff,  0xff,  0xff,
                0x00,  0xff,  0xff,  0xff,  0x00,  0xff,  0xff,  0xff,
                0x00,  0xff,  0x00,  0xff,  0x00,  0xff,  0x00,  0xff,
-};
+       };
 
 
 
        static BCursor VLoopCursor = {
                /*small*/
-       vloop_sbm, vloop_smsk,
+               vloop_sbm, vloop_smsk,
                16, 16, 
                0,  0,
                /*big*/
                vloop_lbm, vloop_lmsk,
-               32,32, 
+               32, 32,
                0, 0,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_VLOOPCURSOR]=&VLoopCursor;
+       BlenderCursor[BC_VLOOPCURSOR] = &VLoopCursor;
 
-END_CURSOR_BLOCK       
+END_CURSOR_BLOCK
        
 
        /********************** TextEdit Cursor ***********************/        
 BEGIN_CURSOR_BLOCK
-       static char textedit_sbm[]={
+       static char textedit_sbm[] = {
                0xe0,  0x03,  0x10,  0x04,  0x60,  0x03,  0x40,  0x01,
                0x40,  0x01,  0x40,  0x01,  0x40,  0x01,  0x40,  0x01,
                0x40,  0x01,  0x40,  0x01,  0x40,  0x01,  0x40,  0x01,
                0x40,  0x01,  0x60,  0x03,  0x10,  0x04,  0xe0,  0x03,
        };
 
-       static char textedit_smsk[]={
+       static char textedit_smsk[] = {
                0xe0,  0x03,  0xf0,  0x07,  0xe0,  0x03,  0xc0,  0x01,
                0xc0,  0x01,  0xc0,  0x01,  0xc0,  0x01,  0xc0,  0x01,
                0xc0,  0x01,  0xc0,  0x01,  0xc0,  0x01,  0xc0,  0x01,
@@ -795,19 +795,19 @@ BEGIN_CURSOR_BLOCK
                9,  8,
                /*big*/
                NULL, NULL,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_TEXTEDITCURSOR]=&TextEditCursor;
+       BlenderCursor[BC_TEXTEDITCURSOR] = &TextEditCursor;
 END_CURSOR_BLOCK
 
 
        /********************** Paintbrush Cursor ***********************/      
 BEGIN_CURSOR_BLOCK
-       static char paintbrush_sbm[]={
+       static char paintbrush_sbm[] = {
 
                0x00,  0xe0,  0x00,  0x98,  0x00,  0x44,  0x00,  0x42,
                0x00,  0x21,  0x80,  0x20,  0x40,  0x13,  0x40,  0x17,
@@ -818,7 +818,7 @@ BEGIN_CURSOR_BLOCK
 
        };
 
-       static char paintbrush_smsk[]={
+       static char paintbrush_smsk[] = {
                0x00,  0xe0,  0x00,  0xf8,  0x00,  0x7c,  0x00,  0x7e,
                0x00,  0x3f,  0x80,  0x3f,  0xc0,  0x1f,  0xc0,  0x1f,
                0xe0,  0x0f,  0xf8,  0x07,  0xfc,  0x03,  0xfe,  0x01,
@@ -834,83 +834,83 @@ BEGIN_CURSOR_BLOCK
                0,  15,
                /*big*/
                NULL, NULL,
-               32,32, 
+               32, 32,
                15, 15,
                /*color*/
                BC_BLACK, BC_WHITE
        };
 
-       BlenderCursor[BC_PAINTBRUSHCURSOR]=&PaintBrushCursor;
+       BlenderCursor[BC_PAINTBRUSHCURSOR] = &PaintBrushCursor;
 END_CURSOR_BLOCK
 
 
 /********************** Hand Cursor ***********************/
 BEGIN_CURSOR_BLOCK
 
-static char hand_sbm[]={ 
-       0x00,  0x00,  0x00,  0x00,  0x80,  0x01,  0x80,  0x0d,  
-       0x98,  0x6d,  0x98,  0x6d,  0xb0,  0x6d,  0xb0,  0x6d,  
-       0xe0,  0x6f,  0xe6,  0x7f,  0xee,  0x7f,  0xfc,  0x3f,  
-       0xf8,  0x3f,  0xf0,  0x1f,  0xc0,  0x1f,  0xc0,  0x1f,  
-};
-
-static char hand_smsk[]={ 
-       0x00,  0x00,  0x80,  0x01,  0xc0,  0x0f,  0xd8,  0x7f,  
-       0xfc,  0xff,  0xfc,  0xff,  0xf8,  0xff,  0xf8,  0xff,  
-       0xf6,  0xff,  0xff,  0xff,  0xff,  0xff,  0xfe,  0x7f,  
-       0xfc,  0x7f,  0xf8,  0x3f,  0xf0,  0x3f,  0xe0,  0x3f,  
-};
-
-
-static BCursor HandCursor = {
-       /*small*/
-       hand_sbm, hand_smsk,
-       16, 16, 
-       8,  8,
-       /*big*/
-       NULL, NULL,
-       32,32, 
-       15, 15,
-       /*color*/
-       BC_BLACK, BC_WHITE
-};
-
-BlenderCursor[BC_HANDCURSOR]=&HandCursor;
+       static char hand_sbm[] = {
+               0x00,  0x00,  0x00,  0x00,  0x80,  0x01,  0x80,  0x0d,
+               0x98,  0x6d,  0x98,  0x6d,  0xb0,  0x6d,  0xb0,  0x6d,
+               0xe0,  0x6f,  0xe6,  0x7f,  0xee,  0x7f,  0xfc,  0x3f,
+               0xf8,  0x3f,  0xf0,  0x1f,  0xc0,  0x1f,  0xc0,  0x1f,
+       };
+
+       static char hand_smsk[] = {
+               0x00,  0x00,  0x80,  0x01,  0xc0,  0x0f,  0xd8,  0x7f,
+               0xfc,  0xff,  0xfc,  0xff,  0xf8,  0xff,  0xf8,  0xff,
+               0xf6,  0xff,  0xff,  0xff,  0xff,  0xff,  0xfe,  0x7f,
+               0xfc,  0x7f,  0xf8,  0x3f,  0xf0,  0x3f,  0xe0,  0x3f,
+       };
+
+
+       static BCursor HandCursor = {
+               /*small*/
+               hand_sbm, hand_smsk,
+               16, 16,
+               8,  8,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_HANDCURSOR] = &HandCursor;
 
 END_CURSOR_BLOCK
 
 /********************** NSEW Scroll Cursor ***********************/
 BEGIN_CURSOR_BLOCK
 
-static char nsewscroll_sbm[]={ 
-       0x00,  0x00,  0x80,  0x01,  0xc0,  0x03,  0xc0,  0x03,  
-       0x00,  0x00,  0x00,  0x00,  0x0c,  0x30,  0x0e,  0x70,  
-       0x0e,  0x70,  0x0c,  0x30,  0x00,  0x00,  0x00,  0x00,  
-       0xc0,  0x03,  0xc0,  0x03,  0x80,  0x01,  0x00,  0x00, 
-};
-
-static char nsewscroll_smsk[]={ 
-       0x80,  0x01,  0xc0,  0x03,  0xe0,  0x07,  0xe0,  0x07,  
-       0xc0,  0x03,  0x0c,  0x30,  0x1e,  0x78,  0x1f,  0xf8,  
-       0x1f,  0xf8,  0x1e,  0x78,  0x0c,  0x30,  0xc0,  0x03,  
-       0xe0,  0x07,  0xe0,  0x07,  0xc0,  0x03,  0x80,  0x01, 
-};
-
-
-static BCursor NSEWScrollCursor = {
-       /*small*/
-       nsewscroll_sbm, nsewscroll_smsk,
-       16, 16, 
-       8, 8,
-       /*big*/
-       NULL, NULL,
-       32,32, 
-       15, 15,
-       /*color*/
-       BC_BLACK, BC_WHITE
-};
-
-BlenderCursor[BC_NSEW_SCROLLCURSOR]=&NSEWScrollCursor;
+       static char nsewscroll_sbm[] = {
+               0x00,  0x00,  0x80,  0x01,  0xc0,  0x03,  0xc0,  0x03,
+               0x00,  0x00,  0x00,  0x00,  0x0c,  0x30,  0x0e,  0x70,
+               0x0e,  0x70,  0x0c,  0x30,  0x00,  0x00,  0x00,  0x00,
+               0xc0,  0x03,  0xc0,  0x03,  0x80,  0x01,  0x00,  0x00,
+       };
+
+       static char nsewscroll_smsk[] = {
+               0x80,  0x01,  0xc0,  0x03,  0xe0,  0x07,  0xe0,  0x07,
+               0xc0,  0x03,  0x0c,  0x30,  0x1e,  0x78,  0x1f,  0xf8,
+               0x1f,  0xf8,  0x1e,  0x78,  0x0c,  0x30,  0xc0,  0x03,
+               0xe0,  0x07,  0xe0,  0x07,  0xc0,  0x03,  0x80,  0x01,
+       };
+
+
+       static BCursor NSEWScrollCursor = {
+               /*small*/
+               nsewscroll_sbm, nsewscroll_smsk,
+               16, 16,
+               8, 8,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_NSEW_SCROLLCURSOR] = &NSEWScrollCursor;
 
 END_CURSOR_BLOCK
 
@@ -918,35 +918,35 @@ END_CURSOR_BLOCK
 /********************** NS Scroll Cursor ***********************/
 BEGIN_CURSOR_BLOCK
 
-static char nsscroll_sbm[]={ 
-       0x00,  0x00,  0x80,  0x01,  0xc0,  0x03,  0xc0,  0x03,  
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  
-       0xc0,  0x03,  0xc0,  0x03,  0x80,  0x01,  0x00,  0x00,
-};
-
-static char nsscroll_smsk[]={ 
-       0x80,  0x01,  0xc0,  0x03,  0xe0,  0x07,  0xe0,  0x07,  
-       0xc0,  0x03,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0xc0,  0x03,  
-       0xe0,  0x07,  0xe0,  0x07,  0xc0,  0x03,  0x80,  0x01,
-};
-
-
-static BCursor NSScrollCursor = {
-       /*small*/
-       nsscroll_sbm, nsscroll_smsk,
-       16, 16, 
-       8, 8,
-       /*big*/
-       NULL, NULL,
-       32,32, 
-       15, 15,
-       /*color*/
-       BC_BLACK, BC_WHITE
-};
-
-BlenderCursor[BC_NS_SCROLLCURSOR]=&NSScrollCursor;
+       static char nsscroll_sbm[] = {
+               0x00,  0x00,  0x80,  0x01,  0xc0,  0x03,  0xc0,  0x03,
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+               0xc0,  0x03,  0xc0,  0x03,  0x80,  0x01,  0x00,  0x00,
+       };
+
+       static char nsscroll_smsk[] = {
+               0x80,  0x01,  0xc0,  0x03,  0xe0,  0x07,  0xe0,  0x07,
+               0xc0,  0x03,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0xc0,  0x03,
+               0xe0,  0x07,  0xe0,  0x07,  0xc0,  0x03,  0x80,  0x01,
+       };
+
+
+       static BCursor NSScrollCursor = {
+               /*small*/
+               nsscroll_sbm, nsscroll_smsk,
+               16, 16,
+               8, 8,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_NS_SCROLLCURSOR] = &NSScrollCursor;
 
 END_CURSOR_BLOCK
 
@@ -954,110 +954,105 @@ END_CURSOR_BLOCK
 /********************** EW Scroll Cursor ***********************/
 BEGIN_CURSOR_BLOCK
 
-static char ewscroll_sbm[]={ 
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  
-       0x00,  0x00,  0x00,  0x00,  0x0c,  0x30,  0x0e,  0x70,  
-       0x0e,  0x70,  0x0c,  0x30,  0x00,  0x00,  0x00,  0x00,  
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
-};
-
-static char ewscroll_smsk[]={ 
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  
-       0x00,  0x00,  0x0c,  0x30,  0x1e,  0x78,  0x1f,  0xf8,  
-       0x1f,  0xf8,  0x1e,  0x78,  0x0c,  0x30,  0x00,  0x00,  
-       0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
-};
-
-
-static BCursor EWScrollCursor = {
-       /*small*/
-       ewscroll_sbm, ewscroll_smsk,
-       16, 16, 
-       8, 8,
-       /*big*/
-       NULL, NULL,
-       32,32, 
-       15, 15,
-       /*color*/
-       BC_BLACK, BC_WHITE
-};
-
-BlenderCursor[BC_EW_SCROLLCURSOR]=&EWScrollCursor;
+       static char ewscroll_sbm[] = {
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+               0x00,  0x00,  0x00,  0x00,  0x0c,  0x30,  0x0e,  0x70,
+               0x0e,  0x70,  0x0c,  0x30,  0x00,  0x00,  0x00,  0x00,
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+       };
+
+       static char ewscroll_smsk[] = {
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+               0x00,  0x00,  0x0c,  0x30,  0x1e,  0x78,  0x1f,  0xf8,
+               0x1f,  0xf8,  0x1e,  0x78,  0x0c,  0x30,  0x00,  0x00,
+               0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+       };
+
+
+       static BCursor EWScrollCursor = {
+               /*small*/
+               ewscroll_sbm, ewscroll_smsk,
+               16, 16,
+               8, 8,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_EW_SCROLLCURSOR] = &EWScrollCursor;
 
 END_CURSOR_BLOCK
 
 /********************** Eyedropper Cursor ***********************/
 BEGIN_CURSOR_BLOCK
 
-static char eyedropper_sbm[]={ 
-       0x00,  0x30,  0x00,  0x48,  0x00,  0x85,  0x80,  0x82,  
-       0x40,  0x40,  0x80,  0x20,  0x40,  0x11,  0xa0,  0x23,  
-       0xd0,  0x15,  0xe8,  0x0a,  0x74,  0x01,  0xb4,  0x00,  
-       0x4a,  0x00,  0x35,  0x00,  0x08,  0x00,  0x04,  0x00,
-};
-
-static char eyedropper_smsk[]={ 
-       0x00,  0x30,  0x00,  0x78,  0x00,  0xfd,  0x80,  0xff,  
-       0xc0,  0x7f,  0x80,  0x3f,  0xc0,  0x1f,  0xe0,  0x3f,  
-       0xf0,  0x1f,  0xf8,  0x0b,  0xfc,  0x01,  0xfc,  0x00,  
-       0x7e,  0x00,  0x3f,  0x00,  0x0c,  0x00,  0x04,  0x00, 
-};
-
-
-static BCursor EyedropperCursor = {
-       /*small*/
-       eyedropper_sbm, eyedropper_smsk,
-       16, 16, 
-       1, 15,
-       /*big*/
-       NULL, NULL,
-       32,32, 
-       15, 15,
-       /*color*/
-       BC_BLACK, BC_WHITE
-};
-
-BlenderCursor[BC_EYEDROPPER_CURSOR]=&EyedropperCursor;
+       static char eyedropper_sbm[] = {
+               0x00,  0x30,  0x00,  0x48,  0x00,  0x85,  0x80,  0x82,
+               0x40,  0x40,  0x80,  0x20,  0x40,  0x11,  0xa0,  0x23,
+               0xd0,  0x15,  0xe8,  0x0a,  0x74,  0x01,  0xb4,  0x00,
+               0x4a,  0x00,  0x35,  0x00,  0x08,  0x00,  0x04,  0x00,
+       };
+
+       static char eyedropper_smsk[] = {
+               0x00,  0x30,  0x00,  0x78,  0x00,  0xfd,  0x80,  0xff,
+               0xc0,  0x7f,  0x80,  0x3f,  0xc0,  0x1f,  0xe0,  0x3f,
+               0xf0,  0x1f,  0xf8,  0x0b,  0xfc,  0x01,  0xfc,  0x00,
+               0x7e,  0x00,  0x3f,  0x00,  0x0c,  0x00,  0x04,  0x00,
+       };
+
+       
+       static BCursor EyedropperCursor = {
+               /*small*/
+               eyedropper_sbm, eyedropper_smsk,
+               16, 16,
+               1, 15,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_BLACK, BC_WHITE
+       };
+
+       BlenderCursor[BC_EYEDROPPER_CURSOR] = &EyedropperCursor;
 
 END_CURSOR_BLOCK
 
 /********************** Swap Area Cursor ***********************/
 BEGIN_CURSOR_BLOCK
-static char swap_sbm[]={
-       0xc0,  0xff,  0x40,  0x80,  0x40,  0x80,  0x40,  0x9c,
-       0x40,  0x98,  0x40,  0x94,  0x00,  0x82,  0xfe,  0x80,
-       0x7e,  0xfd,  0xbe,  0x01,  0xda,  0x01,  0xe2,  0x01,
-       0xe2,  0x01,  0xc2,  0x01,  0xfe,  0x01,  0x00,  0x00,
-};
-
-static char swap_smsk[]={
-       0xc0,  0xff,  0xc0,  0xff,  0xc0,  0xff,  0xc0,  0xff,
-       0xc0,  0xff,  0xc0,  0xff,  0xff,  0xff,  0xff,  0xff,
-       0xff,  0xff,  0xff,  0x03,  0xff,  0x03,  0xff,  0x03,
-       0xff,  0x03,  0xff,  0x03,  0xff,  0x03,  0xff,  0x03,
-};
-
-static BCursor SwapCursor = {
-       /*small*/
-       swap_sbm, swap_smsk,
-       16, 16, 
-       8,  8,
-       /*big*/
-       NULL, NULL,
-       32,32, 
-       15, 15,
-       /*color*/
-       BC_YELLOW, BC_BLUE
-};
-
-BlenderCursor[BC_SWAPAREA_CURSOR]=&SwapCursor;
-
-END_CURSOR_BLOCK
-/********************** Put the cursors in the array ***********************/
-       
+       static char swap_sbm[] = {
+               0xc0,  0xff,  0x40,  0x80,  0x40,  0x80,  0x40,  0x9c,
+               0x40,  0x98,  0x40,  0x94,  0x00,  0x82,  0xfe,  0x80,
+               0x7e,  0xfd,  0xbe,  0x01,  0xda,  0x01,  0xe2,  0x01,
+               0xe2,  0x01,  0xc2,  0x01,  0xfe,  0x01,  0x00,  0x00,
+       };
 
+       static char swap_smsk[] = {
+               0xc0,  0xff,  0xc0,  0xff,  0xc0,  0xff,  0xc0,  0xff,
+               0xc0,  0xff,  0xc0,  0xff,  0xff,  0xff,  0xff,  0xff,
+               0xff,  0xff,  0xff,  0x03,  0xff,  0x03,  0xff,  0x03,
+               0xff,  0x03,  0xff,  0x03,  0xff,  0x03,  0xff,  0x03,
+       };
 
-}
+       static BCursor SwapCursor = {
+               /*small*/
+               swap_sbm, swap_smsk,
+               16, 16,
+               8,  8,
+               /*big*/
+               NULL, NULL,
+               32, 32,
+               15, 15,
+               /*color*/
+               BC_YELLOW, BC_BLUE
+       };
 
+       BlenderCursor[BC_SWAPAREA_CURSOR] = &SwapCursor;
 
+END_CURSOR_BLOCK
+/********************** Put the cursors in the array ***********************/
 
+}
index d60a97a..5283bc0 100644 (file)
@@ -63,7 +63,7 @@
 
 /* ****************************************************** */
 
-static ListBase dropboxes= {NULL, NULL};
+static ListBase dropboxes = {NULL, NULL};
 
 /* drop box maps are stored global for now */
 /* these are part of blender's UI/space specs, and not like keymaps */
@@ -83,15 +83,15 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
 {
        wmDropBoxMap *dm;
        
-       for (dm= dropboxes.first; dm; dm= dm->next)
-               if (dm->spaceid==spaceid && dm->regionid==regionid)
-                       if (0==strncmp(idname, dm->idname, KMAP_MAX_NAME))
+       for (dm = dropboxes.first; dm; dm = dm->next)
+               if (dm->spaceid == spaceid && dm->regionid == regionid)
+                       if (0 == strncmp(idname, dm->idname, KMAP_MAX_NAME))
                                return &dm->dropboxes;
        
-       dm= MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
+       dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
        BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME);
-       dm->spaceid= spaceid;
-       dm->regionid= regionid;
+       dm->spaceid = spaceid;
+       dm->regionid = regionid;
        BLI_addtail(&dropboxes, dm);
        
        return &dm->dropboxes;
@@ -100,16 +100,16 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
 
 
 wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext *, wmDrag *, wmEvent *),
-                                                 void (*copy)(wmDrag *, wmDropBox *))
+                          void (*copy)(wmDrag *, wmDropBox *))
 {
-       wmDropBox *drop= MEM_callocN(sizeof(wmDropBox), "wmDropBox");
+       wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox");
        
-       drop->poll= poll;
-       drop->copy= copy;
-       drop->ot= WM_operatortype_find(idname, 0);
-       drop->opcontext= WM_OP_INVOKE_DEFAULT;
+       drop->poll = poll;
+       drop->copy = copy;
+       drop->ot = WM_operatortype_find(idname, 0);
+       drop->opcontext = WM_OP_INVOKE_DEFAULT;
        
-       if (drop->ot==NULL) {
+       if (drop->ot == NULL) {
                MEM_freeN(drop);
                printf("Error: dropbox with unknown operator: %s\n", idname);
                return NULL;
@@ -125,10 +125,10 @@ void wm_dropbox_free(void)
 {
        wmDropBoxMap *dm;
        
-       for (dm= dropboxes.first; dm; dm= dm->next) {
+       for (dm = dropboxes.first; dm; dm = dm->next) {
                wmDropBox *drop;
                
-               for (drop= dm->dropboxes.first; drop; drop= drop->next) {
+               for (drop = dm->dropboxes.first; drop; drop = drop->next) {
                        if (drop->ptr) {
                                WM_operator_properties_free(drop->ptr);
                                MEM_freeN(drop->ptr);
@@ -145,40 +145,40 @@ void wm_dropbox_free(void)
 /* note that the pointer should be valid allocated and not on stack */
 wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin, double value)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
-       wmDrag *drag= MEM_callocN(sizeof(struct wmDrag), "new drag");
+       wmWindowManager *wm = CTX_wm_manager(C);
+       wmDrag *drag = MEM_callocN(sizeof(struct wmDrag), "new drag");
        
        /* keep track of future multitouch drag too, add a mousepointer id or so */
        /* if multiple drags are added, they're drawn as list */
        
        BLI_addtail(&wm->drags, drag);
-       drag->icon= icon;
-       drag->type= type;
-       if (type==WM_DRAG_PATH)
+       drag->icon = icon;
+       drag->type = type;
+       if (type == WM_DRAG_PATH)
                BLI_strncpy(drag->path, poin, FILE_MAX);
        else
-               drag->poin= poin;
-       drag->value= value;
+               drag->poin = poin;
+       drag->value = value;
        
        return drag;
 }
 
 void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy)
 {
-       drag->imb= imb;
-       drag->scale= scale;
-       drag->sx= sx;
-       drag->sy= sy;
+       drag->imb = imb;
+       drag->scale = scale;
+       drag->sx = sx;
+       drag->sy = sy;
 }
 
 
 static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event)
 {
-       wmEventHandler *handler= handlers->first;
-       for (; handler; handler= handler->next) {
+       wmEventHandler *handler = handlers->first;
+       for (; handler; handler = handler->next) {
                if (handler->dropboxes) {
-                       wmDropBox *drop= handler->dropboxes->first;
-                       for (; drop; drop= drop->next) {
+                       wmDropBox *drop = handler->dropboxes->first;
+                       for (; drop; drop = drop->next) {
                                if (drop->poll(C, drag, event)) 
                                        return drop->ot->name;
                        }
@@ -190,18 +190,18 @@ static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag,
 /* return active operator name when mouse is in box */
 static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event)
 {
-       wmWindow *win= CTX_wm_window(C);
-       ScrArea *sa= CTX_wm_area(C);
-       ARegion *ar= CTX_wm_region(C);
+       wmWindow *win = CTX_wm_window(C);
+       ScrArea *sa = CTX_wm_area(C);
+       ARegion *ar = CTX_wm_region(C);
        const char *name;
        
-       name= dropbox_active(C, &win->handlers, drag, event);
+       name = dropbox_active(C, &win->handlers, drag, event);
        if (name) return name;
        
-       name= dropbox_active(C, &sa->handlers, drag, event);
+       name = dropbox_active(C, &sa->handlers, drag, event);
        if (name) return name;
        
-       name= dropbox_active(C, &ar->handlers, drag, event);
+       name = dropbox_active(C, &ar->handlers, drag, event);
        if (name) return name;
 
        return NULL;
@@ -210,20 +210,20 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event)
 
 static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event)
 {
-       wmWindow *win= CTX_wm_window(C);
+       wmWindow *win = CTX_wm_window(C);
        
        /* for multiwin drags, we only do this if mouse inside */
-       if (event->x<0 || event->y<0 || event->x>win->sizex || event->y>win->sizey)
+       if (event->x < 0 || event->y < 0 || event->x > win->sizex || event->y > win->sizey)
                return;
        
-       drag->opname[0]= 0;
+       drag->opname[0] = 0;
        
        /* check buttons (XXX todo rna and value) */
-       if ( UI_but_active_drop_name(C) ) {
+       if (UI_but_active_drop_name(C) ) {
                strcpy(drag->opname, "Paste name");
        }
        else {
-               const char *opname= wm_dropbox_active(C, drag, event);
+               const char *opname = wm_dropbox_active(C, drag, event);
                
                if (opname) {
                        BLI_strncpy(drag->opname, opname, FILE_MAX);
@@ -238,10 +238,10 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event)
 /* called in inner handler loop, region context */
 void wm_drags_check_ops(bContext *C, wmEvent *event)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmDrag *drag;
        
-       for (drag= wm->drags.first; drag; drag= drag->next) {
+       for (drag = wm->drags.first; drag; drag = drag->next) {
                wm_drop_operator_options(C, drag, event);
        }
 }
@@ -250,7 +250,7 @@ void wm_drags_check_ops(bContext *C, wmEvent *event)
 
 static void wm_drop_operator_draw(const char *name, int x, int y)
 {
-       int width= UI_GetStringWidth(name);
+       int width = UI_GetStringWidth(name);
        
        glColor4ub(0, 0, 0, 50);
        
@@ -258,16 +258,16 @@ static void wm_drop_operator_draw(const char *name, int x, int y)
        uiRoundBox(x, y, x + width + 8, y + 15, 4);
        
        glColor4ub(255, 255, 255, 255);
-       UI_DrawString(x+4, y+4, name);
+       UI_DrawString(x + 4, y + 4, name);
 }
 
 static const char *wm_drag_name(wmDrag *drag)
 {
-       switch(drag->type) {
+       switch (drag->type) {
                case WM_DRAG_ID:
                {
-                       ID *id= (ID *)drag->poin;
-                       return id->name+2;
+                       ID *id = (ID *)drag->poin;
+                       return id->name + 2;
                }
                case WM_DRAG_PATH:
                        return drag->path;
@@ -293,12 +293,12 @@ static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2)
 /* if rect set, do not draw */
 void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmDrag *drag;
        int cursorx, cursory, x, y;
        
-       cursorx= win->eventstate->x;
-       cursory= win->eventstate->y;
+       cursorx = win->eventstate->x;
+       cursory = win->eventstate->y;
        if (rect) {
                rect->xmin = rect->xmax = cursorx;
                rect->ymin = rect->ymax = cursory;
@@ -306,44 +306,44 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
        
        /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */
        glEnable(GL_BLEND);
-       for (drag= wm->drags.first; drag; drag= drag->next) {
+       for (drag = wm->drags.first; drag; drag = drag->next) {
                
                /* image or icon */
                if (drag->imb) {
-                       x= cursorx - drag->sx/2;
-                       y= cursory - drag->sy/2;
+                       x = cursorx - drag->sx / 2;
+                       y = cursory - drag->sy / 2;
                        
                        if (rect)
-                               drag_rect_minmax(rect, x, y, x+drag->sx, y+drag->sy);
+                               drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy);
                        else {
-                               glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */
+                               glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */
                                glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale);
                        }
                }
                else {
-                       x= cursorx - 8;
-                       y= cursory - 2;
+                       x = cursorx - 8;
+                       y = cursory - 2;
                        
                        /* icons assumed to be 16 pixels */
                        if (rect)
-                               drag_rect_minmax(rect, x, y, x+16, y+16);
+                               drag_rect_minmax(rect, x, y, x + 16, y + 16);
                        else
                                UI_icon_draw_aspect(x, y, drag->icon, 1.0, 0.8);
                }
                
                /* item name */
                if (drag->imb) {
-                       x= cursorx - drag->sx/2;
-                       y= cursory - drag->sy/2 - 16;
+                       x = cursorx - drag->sx / 2;
+                       y = cursory - drag->sy / 2 - 16;
                }
                else {
-                       x= cursorx + 10;
-                       y= cursory + 1;
+                       x = cursorx + 10;
+                       y = cursory + 1;
                }
                
                if (rect) {
-                       int w=  UI_GetStringWidth(wm_drag_name(drag));
-                       drag_rect_minmax(rect, x, y, x+w, y+16);
+                       int w =  UI_GetStringWidth(wm_drag_name(drag));
+                       drag_rect_minmax(rect, x, y, x + w, y + 16);
                }
                else {
                        glColor4ub(255, 255, 255, 255);
@@ -353,17 +353,17 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
                /* operator name with roundbox */
                if (drag->opname[0]) {
                        if (drag->imb) {
-                               x= cursorx - drag->sx/2;
-                               y= cursory + drag->sy/2 + 4;
+                               x = cursorx - drag->sx / 2;
+                               y = cursory + drag->sy / 2 + 4;
                        }
                        else {
-                               x= cursorx - 8;
-                               y= cursory + 16;
+                               x = cursorx - 8;
+                               y = cursory + 16;
                        }
                        
                        if (rect) {
-                               int w=  UI_GetStringWidth(wm_drag_name(drag));
-                               drag_rect_minmax(rect, x, y, x+w, y+16);
+                               int w =  UI_GetStringWidth(wm_drag_name(drag));
+                               drag_rect_minmax(rect, x, y, x + w, y + 16);
                        }
                        else 
                                wm_drop_operator_draw(drag->opname, x, y);
index 588839a..66cadf1 100644 (file)
 #include "wm_event_system.h"
 
 /* swap */
-#define WIN_NONE_OK            0
+#define WIN_NONE_OK     0
 #define WIN_BACK_OK     1
 #define WIN_FRONT_OK    2
-#define WIN_BOTH_OK            3
+#define WIN_BOTH_OK     3
 
 /* ******************* drawing, overlays *************** */
 
 
 static void wm_paintcursor_draw(bContext *C, ARegion *ar)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        
        if (wm->paintcursors.first) {
-               wmWindow *win= CTX_wm_window(C);
-               bScreen *screen= win->screen;
+               wmWindow *win = CTX_wm_window(C);
+               bScreen *screen = win->screen;
                wmPaintCursor *pc;
 
                if (screen->subwinactive == ar->swinid) {
-                       for (pc= wm->paintcursors.first; pc; pc= pc->next) {
+                       for (pc = wm->paintcursors.first; pc; pc = pc->next) {
                                if (pc->poll == NULL || pc->poll(C)) {
-                                       ARegion *ar_other= CTX_wm_region(C);
+                                       ARegion *ar_other = CTX_wm_region(C);
                                        if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
                                                int x = 0, y = 0;
                                                wm_get_cursor_position(win, &x, &y);
@@ -112,13 +112,13 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
 static void wm_area_mark_invalid_backbuf(ScrArea *sa)
 {
        if (sa->spacetype == SPACE_VIEW3D)
-               ((View3D*)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF;
+               ((View3D *)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF;
 }
 
 static int wm_area_test_invalid_backbuf(ScrArea *sa)
 {
        if (sa->spacetype == SPACE_VIEW3D)
-               return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF);
+               return (((View3D *)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF);
        else
                return 1;
 }
@@ -127,7 +127,7 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar)
 {
        if (sa->spacetype == SPACE_VIEW3D) {
                RegionView3D *rv3d = ar->regiondata;
-               RenderEngine *engine = (rv3d)? rv3d->render_engine: NULL;
+               RenderEngine *engine = (rv3d) ? rv3d->render_engine : NULL;
 
                if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
                        ar->do_draw = 1;
@@ -141,15 +141,15 @@ static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar)
 
 static void wm_method_draw_full(bContext *C, wmWindow *win)
 {
-       bScreen *screen= win->screen;
+       bScreen *screen = win->screen;
        ScrArea *sa;
        ARegion *ar;
 
        /* draw area regions */
-       for (sa= screen->areabase.first; sa; sa= sa->next) {
+       for (sa = screen->areabase.first; sa; sa = sa->next) {
                CTX_wm_area_set(C, sa);
 
-               for (ar=sa->regionbase.first; ar; ar= ar->next) {
+               for (ar = sa->regionbase.first; ar; ar = ar->next) {
                        if (ar->swinid) {
                                CTX_wm_region_set(C, ar);
                                ED_region_do_draw(C, ar);
@@ -167,7 +167,7 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
        ED_area_overdraw(C);
 
        /* draw overlapping regions */
-       for (ar=screen->regionbase.first; ar; ar= ar->next) {
+       for (ar = screen->regionbase.first; ar; ar = ar->next) {
                if (ar->swinid) {
                        CTX_wm_menu_set(C, ar);
                        ED_region_do_draw(C, ar);
@@ -191,12 +191,12 @@ static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
        ScrArea *sa;
        ARegion *ar;
 
-       for (sa= screen->areabase.first; sa; sa= sa->next) {
-               for (ar= sa->regionbase.first; ar; ar= ar->next) {
+       for (sa = screen->areabase.first; sa; sa = sa->next) {
+               for (ar = sa->regionbase.first; ar; ar = ar->next) {
                        if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
-                               ar->do_draw= RGN_DRAW;
+                               ar->do_draw = RGN_DRAW;
                                memset(&ar->drawrct, 0, sizeof(ar->drawrct));
-                               ar->swap= WIN_NONE_OK;
+                               ar->swap = WIN_NONE_OK;
                        }
                }
        }
@@ -207,50 +207,50 @@ static void wm_flush_regions_up(bScreen *screen, rcti *dirty)
 {
        ARegion *ar;
        
-       for (ar= screen->regionbase.first; ar; ar= ar->next) {
+       for (ar = screen->regionbase.first; ar; ar = ar->next) {
                if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
-                       ar->do_draw= RGN_DRAW;
+                       ar->do_draw = RGN_DRAW;
                        memset(&ar->drawrct, 0, sizeof(ar->drawrct));
-                       ar->swap= WIN_NONE_OK;
+                       ar->swap = WIN_NONE_OK;
                }
        }
 }
 
 static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
-       bScreen *screen= win->screen;
+       wmWindowManager *wm = CTX_wm_manager(C);
+       bScreen *screen = win->screen;
        ScrArea *sa;
        ARegion *ar;
-       static rcti rect= {0, 0, 0, 0};
+       static rcti rect = {0, 0, 0, 0};
 
        /* after backbuffer selection draw, we need to redraw */
-       for (sa= screen->areabase.first; sa; sa= sa->next)
-               for (ar= sa->regionbase.first; ar; ar= ar->next)
+       for (sa = screen->areabase.first; sa; sa = sa->next)
+               for (ar = sa->regionbase.first; ar; ar = ar->next)
                        if (ar->swinid && !wm_area_test_invalid_backbuf(sa))
                                ED_region_tag_redraw(ar);
 
        /* flush overlapping regions */
        if (screen->regionbase.first) {
                /* flush redraws of area regions up to overlapping regions */
-               for (sa= screen->areabase.first; sa; sa= sa->next)
-                       for (ar= sa->regionbase.first; ar; ar= ar->next)
+               for (sa = screen->areabase.first; sa; sa = sa->next)
+                       for (ar = sa->regionbase.first; ar; ar = ar->next)
                                if (ar->swinid && ar->do_draw)
                                        wm_flush_regions_up(screen, &ar->winrct);
                
                /* flush between overlapping regions */
-               for (ar= screen->regionbase.last; ar; ar= ar->prev)
+               for (ar = screen->regionbase.last; ar; ar = ar->prev)
                        if (ar->swinid && ar->do_draw)
                                wm_flush_regions_up(screen, &ar->winrct);
                
                /* flush redraws of overlapping regions down to area regions */
-               for (ar= screen->regionbase.last; ar; ar= ar->prev)
+               for (ar = screen->regionbase.last; ar; ar = ar->prev)
                        if (ar->swinid && ar->do_draw)
                                wm_flush_regions_down(screen, &ar->winrct);
        }
 
        /* flush drag item */
-       if (rect.xmin!=rect.xmax) {
+       if (rect.xmin != rect.xmax) {
                wm_flush_regions_down(screen, &rect);
                rect.xmin = rect.xmax = 0;
        }
@@ -260,10 +260,10 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
        }
        
        /* draw marked area regions */
-       for (sa= screen->areabase.first; sa; sa= sa->next) {
+       for (sa = screen->areabase.first; sa; sa = sa->next) {
                CTX_wm_area_set(C, sa);
 
-               for (ar=sa->regionbase.first; ar; ar= ar->next) {
+               for (ar = sa->regionbase.first; ar; ar = ar->next) {
                        if (ar->swinid) {
                                if (ar->do_draw) {
                                        CTX_wm_region_set(C, ar);
@@ -273,7 +273,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
                                        CTX_wm_region_set(C, NULL);
 
                                        if (exchange)
-                                               ar->swap= WIN_FRONT_OK;
+                                               ar->swap = WIN_FRONT_OK;
                                }
                                else if (exchange) {
                                        if (ar->swap == WIN_FRONT_OK) {
@@ -283,12 +283,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
                                                ED_area_overdraw_flush(sa, ar);
                                                CTX_wm_region_set(C, NULL);
 
-                                               ar->swap= WIN_BOTH_OK;
+                                               ar->swap = WIN_BOTH_OK;
                                        }
                                        else if (ar->swap == WIN_BACK_OK)
-                                               ar->swap= WIN_FRONT_OK;
+                                               ar->swap = WIN_FRONT_OK;
                                        else if (ar->swap == WIN_BOTH_OK)
-                                               ar->swap= WIN_BOTH_OK;
+                                               ar->swap = WIN_BOTH_OK;
                                }
                        }
                }
@@ -302,23 +302,23 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
                ED_screen_draw(win);
 
                if (exchange)
-                       screen->swap= WIN_FRONT_OK;
+                       screen->swap = WIN_FRONT_OK;
        }
        else if (exchange) {
-               if (screen->swap==WIN_FRONT_OK) {
+               if (screen->swap == WIN_FRONT_OK) {
                        ED_screen_draw(win);
-                       screen->swap= WIN_BOTH_OK;
+                       screen->swap = WIN_BOTH_OK;
                }
-               else if (screen->swap==WIN_BACK_OK)
-                       screen->swap= WIN_FRONT_OK;
-               else if (screen->swap==WIN_BOTH_OK)
-                       screen->swap= WIN_BOTH_OK;
+               else if (screen->swap == WIN_BACK_OK)
+                       screen->swap = WIN_FRONT_OK;
+               else if (screen->swap == WIN_BOTH_OK)
+                       screen->swap = WIN_BOTH_OK;
        }
 
        ED_area_overdraw(C);
 
        /* draw marked overlapping regions */
-       for (ar=screen->regionbase.first; ar; ar= ar->next) {
+       for (ar = screen->regionbase.first; ar; ar = ar->next) {
                if (ar->swinid && ar->do_draw) {
                        CTX_wm_menu_set(C, ar);
                        ED_region_do_draw(C, ar);
@@ -357,7 +357,7 @@ static void wm_method_draw_damage(bContext *C, wmWindow *win)
 #define MAX_N_TEX 3
 
 typedef struct wmDrawTriple {
-       GLuint bind[MAX_N_TEX*MAX_N_TEX];
+       GLuint bind[MAX_N_TEX * MAX_N_TEX];
        int x[MAX_N_TEX], y[MAX_N_TEX];
        int nx, ny;
        GLenum target;
@@ -369,46 +369,46 @@ static void split_width(int x, int n, int *splitx, int *nx)
 
        /* if already power of two just use it */
        if (is_power_of_2_i(x)) {
-               splitx[0]= x;
+               splitx[0] = x;
                (*nx)++;
                return;
        }
 
        if (n == 1) {
                /* last part, we have to go larger */
-               splitx[0]= power_of_2_max_i(x);
+               splitx[0] = power_of_2_max_i(x);
                (*nx)++;
        }
        else {
                /* two or more parts to go, use smaller part */
-               splitx[0]= power_of_2_min_i(x);
-               newnx= ++(*nx);
-               split_width(x-splitx[0], n-1, splitx+1, &newnx);
+               splitx[0] = power_of_2_min_i(x);
+               newnx = ++(*nx);
+               split_width(x - splitx[0], n - 1, splitx + 1, &newnx);
 
-               for (waste=0, a=0; a<n; a++)
+               for (waste = 0, a = 0; a < n; a++)
                        waste += splitx[a];
 
                /* if we waste more space or use the same amount,
                 * revert deeper splits and just use larger */
                if (waste >= power_of_2_max_i(x)) {
-                       splitx[0]= power_of_2_max_i(x);
-                       memset(splitx+1, 0, sizeof(int)*(n-1));
+                       splitx[0] = power_of_2_max_i(x);
+                       memset(splitx + 1, 0, sizeof(int) * (n - 1));
                }
                else
-                       *nx= newnx;
+                       *nx = newnx;
        }
 }
 
 static void wm_draw_triple_free(wmWindow *win)
 {
        if (win->drawdata) {
-               wmDrawTriple *triple= win->drawdata;
+               wmDrawTriple *triple = win->drawdata;
 
-               glDeleteTextures(triple->nx*triple->ny, triple->bind);
+               glDeleteTextures(triple->nx * triple->ny, triple->bind);
 
                MEM_freeN(triple);
 
-               win->drawdata= NULL;
+               win->drawdata = NULL;
        }
 }
 
@@ -416,7 +416,7 @@ static void wm_draw_triple_fail(bContext *C, wmWindow *win)
 {
        wm_draw_window_clear(win);
 
-       win->drawfail= 1;
+       win->drawfail = 1;
        wm_method_draw_overlap_all(C, win, 0);
 }
 
@@ -427,29 +427,29 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
 
        /* compute texture sizes */
        if (GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) {
-               triple->target= GL_TEXTURE_RECTANGLE_ARB;
-               triple->nx= 1;
-               triple->ny= 1;
-               triple->x[0]= win->sizex;
-               triple->y[0]= win->sizey;
+               triple->target = GL_TEXTURE_RECTANGLE_ARB;
+               triple->nx = 1;
+               triple->ny = 1;
+               triple->x[0] = win->sizex;
+               triple->y[0] = win->sizey;
        }
        else if (GPU_non_power_of_two_support()) {
-               triple->target= GL_TEXTURE_2D;
-               triple->nx= 1;
-               triple->ny= 1;
-               triple->x[0]= win->sizex;
-               triple->y[0]= win->sizey;
+               triple->target = GL_TEXTURE_2D;
+               triple->nx = 1;
+               triple->ny = 1;
+               triple->x[0] = win->sizex;
+               triple->y[0] = win->sizey;
        }
        else {
-               triple->target= GL_TEXTURE_2D;
-               triple->nx= 0;
-               triple->ny= 0;
+               triple->target = GL_TEXTURE_2D;
+               triple->nx = 0;
+               triple->ny = 0;
                split_width(win->sizex, MAX_N_TEX, triple->x, &triple->nx);
                split_width(win->sizey, MAX_N_TEX, triple->y, &triple->ny);
        }
 
        /* generate texture names */
-       glGenTextures(triple->nx*triple->ny, triple->bind);
+       glGenTextures(triple->nx * triple->ny, triple->bind);
 
        if (!triple->bind[0]) {
                /* not the typical failure case but we handle it anyway */
@@ -457,8 +457,8 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
                return 0;
        }
 
-       for (y=0; y<triple->ny; y++) {
-               for (x=0; x<triple->nx; x++) {
+       for (y = 0; y < triple->ny; y++) {
+               for (x = 0; x < triple->nx; x++) {
                        /* proxy texture is only guaranteed to test for the cases that
                         * there is only one texture in use, which may not be the case */
                        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
@@ -471,7 +471,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
                        }
 
                        /* setup actual texture */
-                       glBindTexture(triple->target, triple->bind[x + y*triple->nx]);
+                       glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
                        glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
                        glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                        glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -497,16 +497,16 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
 
        glEnable(triple->target);
 
-       for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) {
-               for (x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) {
-                       sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x];
-                       sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y];
+       for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
+               for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
+                       sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
+                       sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
 
                        /* wmOrtho for the screen has this same offset */
-                       ratiox= sizex;
-                       ratioy= sizey;
-                       halfx= 0.375f;
-                       halfy= 0.375f;
+                       ratiox = sizex;
+                       ratioy = sizey;
+                       halfx = 0.375f;
+                       halfy = 0.375f;
 
                        /* texture rectangle has unnormalized coordinates */
                        if (triple->target == GL_TEXTURE_2D) {
@@ -516,21 +516,21 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
                                halfy /= triple->y[y];
                        }
 
-                       glBindTexture(triple->target, triple->bind[x + y*triple->nx]);
+                       glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
 
                        glColor3f(1.0f, 1.0f, 1.0f);
                        glBegin(GL_QUADS);
-                               glTexCoord2f(halfx, halfy);
-                               glVertex2f(offx, offy);
+                       glTexCoord2f(halfx, halfy);
+                       glVertex2f(offx, offy);
 
-                               glTexCoord2f(ratiox+halfx, halfy);
-                               glVertex2f(offx+sizex, offy);
+                       glTexCoord2f(ratiox + halfx, halfy);
+                       glVertex2f(offx + sizex, offy);
 
-                               glTexCoord2f(ratiox+halfx, ratioy+halfy);
-                               glVertex2f(offx+sizex, offy+sizey);
+                       glTexCoord2f(ratiox + halfx, ratioy + halfy);
+                       glVertex2f(offx + sizex, offy + sizey);
 
-                               glTexCoord2f(halfx, ratioy+halfy);
-                               glVertex2f(offx, offy+sizey);
+                       glTexCoord2f(halfx, ratioy + halfy);
+                       glVertex2f(offx, offy + sizey);
                        glEnd();
                }
        }
@@ -543,12 +543,12 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
 {
        int x, y, sizex, sizey, offx, offy;
 
-       for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) {
-               for (x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) {
-                       sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x];
-                       sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y];
+       for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
+               for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
+                       sizex = (x == triple->nx - 1) ? win->sizex - offx : triple->x[x];
+                       sizey = (y == triple->ny - 1) ? win->sizey - offy : triple->y[y];
 
-                       glBindTexture(triple->target, triple->bind[x + y*triple->nx]);
+                       glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
                        glCopyTexSubImage2D(triple->target, 0, 0, 0, offx, offy, sizex, sizey);
                }
        }
@@ -558,23 +558,23 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
 
 static void wm_method_draw_triple(bContext *C, wmWindow *win)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmDrawTriple *triple;
-       bScreen *screen= win->screen;
+       bScreen *screen = win->screen;
        ScrArea *sa;
        ARegion *ar;
-       int copytex= 0, paintcursor= 1;
+       int copytex = 0, paintcursor = 1;
 
        if (win->drawdata) {
                glClearColor(0, 0, 0, 0);
-               glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
                wmSubWindowSet(win, screen->mainwin);
 
                wm_triple_draw_textures(win, win->drawdata);
        }
        else {
-               win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
+               win->drawdata = MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
 
                if (!wm_triple_gen_textures(win, win->drawdata)) {
                        wm_draw_triple_fail(C, win);
@@ -582,19 +582,19 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
                }
        }
 
-       triple= win->drawdata;
+       triple = win->drawdata;
 
        /* draw marked area regions */
-       for (sa= screen->areabase.first; sa; sa= sa->next) {
+       for (sa = screen->areabase.first; sa; sa = sa->next) {
                CTX_wm_area_set(C, sa);
 
-               for (ar=sa->regionbase.first; ar; ar= ar->next) {
+               for (ar = sa->regionbase.first; ar; ar = ar->next) {
                        if (ar->swinid && ar->do_draw) {
                                CTX_wm_region_set(C, ar);
                                ED_region_do_draw(C, ar);
                                ED_area_overdraw_flush(sa, ar);
                                CTX_wm_region_set(C, NULL);
-                               copytex= 1;
+                               copytex = 1;
                        }
                }
                
@@ -613,13 +613,13 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
        ED_screen_draw(win);
 
        /* draw overlapping regions */
-       for (ar=screen->regionbase.first; ar; ar= ar->next) {
+       for (ar = screen->regionbase.first; ar; ar = ar->next) {
                if (ar->swinid) {
                        CTX_wm_menu_set(C, ar);
                        ED_region_do_draw(C, ar);
                        CTX_wm_menu_set(C, NULL);
                        /* when a menu is being drawn, don't do the paint cursors */
-                       paintcursor= 0;
+                       paintcursor = 0;
                }
        }
 
@@ -628,8 +628,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
                wm_gesture_draw(win);
 
        if (paintcursor && wm->paintcursors.first) {
-               for (sa= screen->areabase.first; sa; sa= sa->next) {
-                       for (ar=sa->regionbase.first; ar; ar= ar->next) {
+               for (sa = screen->areabase.first; sa; sa = sa->next) {
+                       for (ar = sa->regionbase.first; ar; ar = ar->next) {
                                if (ar->swinid == screen->subwinactive) {
                                        CTX_wm_area_set(C, sa);
                                        CTX_wm_region_set(C, ar);
@@ -661,19 +661,19 @@ static int wm_draw_update_test_window(wmWindow *win)
 {
        ScrArea *sa;
        ARegion *ar;
-       int do_draw= 0;
+       int do_draw = 0;
 
-       for (ar= win->screen->regionbase.first; ar; ar= ar->next) {
+       for (ar = win->screen->regionbase.first; ar; ar = ar->next) {
                if (ar->do_draw_overlay) {
                        wm_tag_redraw_overlay(win, ar);
-                       ar->do_draw_overlay= 0;
+                       ar->do_draw_overlay = 0;
                }
                if (ar->swinid && ar->do_draw)
-                       do_draw= 1;
+                       do_draw = 1;
        }
 
-       for (sa= win->screen->areabase.first; sa; sa= sa->next) {
-               for (ar=sa->regionbase.first; ar; ar= ar->next) {
+       for (sa = win->screen->areabase.first; sa; sa = sa->next) {
+               for (ar = sa->regionbase.first; ar; ar = ar->next) {
                        wm_region_test_render_do_draw(sa, ar);
 
                        if (ar->swinid && ar->do_draw)
@@ -737,22 +737,22 @@ void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar)
        if (ar && win) {
                if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE)
                        ED_region_tag_redraw(ar);
-               win->screen->do_draw_paintcursor= 1;
+               win->screen->do_draw_paintcursor = 1;
        }
 }
 
 void wm_draw_update(bContext *C)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win;
        int drawmethod;
 
        GPU_free_unused_buffers();
        
-       for (win= wm->windows.first; win; win= win->next) {
+       for (win = wm->windows.first; win; win = win->next) {
                if (win->drawmethod != U.wmdrawmethod) {
                        wm_draw_window_clear(win);
-                       win->drawmethod= U.wmdrawmethod;
+                       win->drawmethod = U.wmdrawmethod;
                }
 
                if (wm_draw_update_test_window(win)) {
@@ -765,7 +765,7 @@ void wm_draw_update(bContext *C)
                        if (win->screen->do_refresh)
                                ED_screen_refresh(wm, win);
 
-                       drawmethod= wm_automatic_draw_method(win);
+                       drawmethod = wm_automatic_draw_method(win);
 
                        if (win->drawfail)
                                wm_method_draw_overlap_all(C, win, 0);
@@ -778,9 +778,9 @@ void wm_draw_update(bContext *C)
                        else // if (drawmethod == USER_DRAW_TRIPLE)
                                wm_method_draw_triple(C, win);
 
-                       win->screen->do_draw_gesture= 0;
-                       win->screen->do_draw_paintcursor= 0;
-                       win->screen->do_draw_drag= 0;
+                       win->screen->do_draw_gesture = 0;
+                       win->screen->do_draw_paintcursor = 0;
+                       win->screen->do_draw_drag = 0;
                
                        wm_window_swap_buffers(win);
 
@@ -791,39 +791,39 @@ void wm_draw_update(bContext *C)
 
 void wm_draw_window_clear(wmWindow *win)
 {
-       bScreen *screen= win->screen;
+       bScreen *screen = win->screen;
        ScrArea *sa;
        ARegion *ar;
-       int drawmethod= wm_automatic_draw_method(win);
+       int drawmethod = wm_automatic_draw_method(win);
 
        if (drawmethod == USER_DRAW_TRIPLE)
                wm_draw_triple_free(win);
 
        /* clear screen swap flags */
        if (screen) {
-               for (sa= screen->areabase.first; sa; sa= sa->next)
-                       for (ar=sa->regionbase.first; ar; ar= ar->next)
-                               ar->swap= WIN_NONE_OK;
+               for (sa = screen->areabase.first; sa; sa = sa->next)
+                       for (ar = sa->regionbase.first; ar; ar = ar->next)
+                               ar->swap = WIN_NONE_OK;
                
-               screen->swap= WIN_NONE_OK;
+               screen->swap = WIN_NONE_OK;
        }
 }
 
 void wm_draw_region_clear(wmWindow *win, ARegion *ar)
 {
-       int drawmethod= wm_automatic_draw_method(win);
+       int drawmethod = wm_automatic_draw_method(win);
 
        if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP))
                wm_flush_regions_down(win->screen, &ar->winrct);
 
-       win->screen->do_draw= 1;
+       win->screen->do_draw = 1;
 }
 
 void WM_redraw_windows(bContext *C)
 {
-       wmWindow *win_prev= CTX_wm_window(C);
-       ScrArea *area_prev= CTX_wm_area(C);
-       ARegion *ar_prev= CTX_wm_region(C);
+       wmWindow *win_prev = CTX_wm_window(C);
+       ScrArea *area_prev = CTX_wm_area(C);
+       ARegion *ar_prev = CTX_wm_region(C);
 
        wm_draw_update(C);
 
index fb5a531..2327ca4 100644 (file)
@@ -89,9 +89,9 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
 
 void wm_event_add(wmWindow *win, wmEvent *event_to_add)
 {
-       wmEvent *event= MEM_callocN(sizeof(wmEvent), "wmEvent");
+       wmEvent *event = MEM_callocN(sizeof(wmEvent), "wmEvent");
        
-       *event= *event_to_add;
+       *event = *event_to_add;
        BLI_addtail(&win->queue, event);
 }
 
@@ -100,7 +100,7 @@ void wm_event_free(wmEvent *event)
        if (event->customdata) {
                if (event->customdatafree) {
                        /* note: pointer to listbase struct elsewhere */
-                       if (event->custom==EVT_DATA_LISTBASE)
+                       if (event->custom == EVT_DATA_LISTBASE)
                                BLI_freelistN(event->customdata);
                        else
                                MEM_freeN(event->customdata);
@@ -113,7 +113,7 @@ void wm_event_free_all(wmWindow *win)
 {
        wmEvent *event;
        
-       while ((event= win->queue.first)) {
+       while ((event = win->queue.first)) {
                BLI_remlink(&win->queue, event);
                wm_event_free(event);
        }
@@ -125,8 +125,8 @@ static int wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, vo
 {
        wmNotifier *note;
 
-       for (note=wm->queue.first; note; note=note->next)
-               if ((note->category|note->data|note->subtype|note->action) == type && note->reference == reference)
+       for (note = wm->queue.first; note; note = note->next)
+               if ((note->category | note->data | note->subtype | note->action) == type && note->reference == reference)
                        return 1;
        
        return 0;
@@ -135,47 +135,47 @@ static int wm_test_duplicate_notifier(wmWindowManager *wm, unsigned int type, vo
 /* XXX: in future, which notifiers to send to other windows? */
 void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference)
 {
-       wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier");
+       wmNotifier *note = MEM_callocN(sizeof(wmNotifier), "notifier");
        
-       note->wm= CTX_wm_manager(C);
+       note->wm = CTX_wm_manager(C);
        BLI_addtail(&note->wm->queue, note);
        
-       note->window= CTX_wm_window(C);
+       note->window = CTX_wm_window(C);
        
        if (CTX_wm_region(C))
-               note->swinid= CTX_wm_region(C)->swinid;
+               note->swinid = CTX_wm_region(C)->swinid;
        
-       note->category= type & NOTE_CATEGORY;
-       note->data= type & NOTE_DATA;
-       note->subtype= type & NOTE_SUBTYPE;
-       note->action= type & NOTE_ACTION;
+       note->category = type & NOTE_CATEGORY;
+       note->data = type & NOTE_DATA;
+       note->subtype = type & NOTE_SUBTYPE;
+       note->action = type & NOTE_ACTION;
        
-       note->reference= reference;
+       note->reference = reference;
 }
 
 void WM_main_add_notifier(unsigned int type, void *reference)
 {
-       Main *bmain= G.main;
-       wmWindowManager *wm= bmain->wm.first;
+       Main *bmain = G.main;
+       wmWindowManager *wm = bmain->wm.first;
 
        if (wm && !wm_test_duplicate_notifier(wm, type, reference)) {
-               wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier");
+               wmNotifier *note = MEM_callocN(sizeof(wmNotifier), "notifier");
                
-               note->wm= wm;
+               note->wm = wm;
                BLI_addtail(&note->wm->queue, note);
                
-               note->category= type & NOTE_CATEGORY;
-               note->data= type & NOTE_DATA;
-               note->subtype= type & NOTE_SUBTYPE;
-               note->action= type & NOTE_ACTION;
+               note->category = type & NOTE_CATEGORY;
+               note->data = type & NOTE_DATA;
+               note->subtype = type & NOTE_SUBTYPE;
+               note->action = type & NOTE_ACTION;
                
-               note->reference= reference;
+               note->reference = reference;
        }
 }
 
 static wmNotifier *wm_notifier_next(wmWindowManager *wm)
 {
-       wmNotifier *note= wm->queue.first;
+       wmNotifier *note = wm->queue.first;
        
        if (note) BLI_remlink(&wm->queue, note);
        return note;
@@ -184,40 +184,40 @@ static wmNotifier *wm_notifier_next(wmWindowManager *wm)
 /* called in mainloop */
 void wm_event_do_notifiers(bContext *C)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmNotifier *note, *next;
        wmWindow *win;
-       uint64_t win_combine_v3d_datamask= 0;
+       uint64_t win_combine_v3d_datamask = 0;
        
-       if (wm==NULL)
+       if (wm == NULL)
                return;
        
        /* cache & catch WM level notifiers, such as frame change, scene/screen set */
-       for (win= wm->windows.first; win; win= win->next) {
-               int do_anim= 0;
+       for (win = wm->windows.first; win; win = win->next) {
+               int do_anim = 0;
                
                CTX_wm_window_set(C, win);
                
-               for (note= wm->queue.first; note; note= next) {
-                       next= note->next;
+               for (note = wm->queue.first; note; note = next) {
+                       next = note->next;
 
-                       if (note->category==NC_WM) {
-                               if ( ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) {
-                                       wm->file_saved= 1;
+                       if (note->category == NC_WM) {
+                               if (ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) {
+                                       wm->file_saved = 1;
                                        wm_window_title(wm, win);
                                }
-                               else if (note->data==ND_DATACHANGED)
+                               else if (note->data == ND_DATACHANGED)
                                        wm_window_title(wm, win);
                        }
-                       if (note->window==win) {
-                               if (note->category==NC_SCREEN) {
-                                       if (note->data==ND_SCREENBROWSE) {
-                                               ED_screen_set(C, note->reference);      // XXX hrms, think this over!
+                       if (note->window == win) {
+                               if (note->category == NC_SCREEN) {
+                                       if (note->data == ND_SCREENBROWSE) {
+                                               ED_screen_set(C, note->reference);  // XXX hrms, think this over!
                                                if (G.f & G_DEBUG)
                                                        printf("screen set %p\n", note->reference);
                                        }
-                                       else if (note->data==ND_SCREENDELETE) {
-                                               ED_screen_delete(C, note->reference);   // XXX hrms, think this over!
+                                       else if (note->data == ND_SCREENDELETE) {
+                                               ED_screen_delete(C, note->reference);   // XXX hrms, think this over!
                                                if (G.f & G_DEBUG)
                                                        printf("screen delete %p\n", note->reference);
                                        }
@@ -225,16 +225,16 @@ void wm_event_do_notifiers(bContext *C)
                        }
 
                        if (note->window == win ||
-                               (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C))))
+                           (note->window == NULL && (note->reference == NULL || note->reference == CTX_data_scene(C))))
                        {
-                               if (note->category==NC_SCENE) {
-                                       if (note->data==ND_FRAME)
-                                               do_anim= 1;
+                               if (note->category == NC_SCENE) {
+                                       if (note->data == ND_FRAME)
+                                               do_anim = 1;
                                }
                        }
                        if (ELEM5(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE, NC_WM)) {
                                ED_info_stats_clear(CTX_data_scene(C));
-                               WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL);
+                               WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
                        }
                }
                if (do_anim) {
@@ -251,12 +251,12 @@ void wm_event_do_notifiers(bContext *C)
        }
        
        /* the notifiers are sent without context, to keep it clean */
-       while ( (note=wm_notifier_next(wm)) ) {
-               for (win= wm->windows.first; win; win= win->next) {
+       while ( (note = wm_notifier_next(wm)) ) {
+               for (win = wm->windows.first; win; win = win->next) {
                        
                        /* filter out notifiers */
-                       if (note->category==NC_SCREEN && note->reference && note->reference!=win->screen);
-                       else if (note->category==NC_SCENE && note->reference && note->reference!=win->screen->scene);
+                       if (note->category == NC_SCREEN && note->reference && note->reference != win->screen) ;
+                       else if (note->category == NC_SCENE && note->reference && note->reference != win->screen->scene) ;
                        else {
                                ScrArea *sa;
                                ARegion *ar;
@@ -267,13 +267,13 @@ void wm_event_do_notifiers(bContext *C)
                                /* printf("notifier win %d screen %s cat %x\n", win->winid, win->screen->id.name+2, note->category); */
                                ED_screen_do_listen(C, note);
 
-                               for (ar=win->screen->regionbase.first; ar; ar= ar->next) {
+                               for (ar = win->screen->regionbase.first; ar; ar = ar->next) {
                                        ED_region_do_listen(ar, note);
                                }
                                
-                               for (sa= win->screen->areabase.first; sa; sa= sa->next) {
+                               for (sa = win->screen->areabase.first; sa; sa = sa->next) {
                                        ED_area_do_listen(sa, note);
-                                       for (ar=sa->regionbase.first; ar; ar= ar->next) {
+                                       for (ar = sa->regionbase.first; ar; ar = ar->next) {
                                                ED_region_do_listen(ar, note);
                                        }
                                }
@@ -284,16 +284,16 @@ void wm_event_do_notifiers(bContext *C)
        }
        
        /* combine datamasks so 1 win doesn't disable UV's in another [#26448] */
-       for (win= wm->windows.first; win; win= win->next) {
+       for (win = wm->windows.first; win; win = win->next) {
                win_combine_v3d_datamask |= ED_view3d_screen_datamask(win->screen);
        }
 
        /* cached: editor refresh callbacks now, they get context */
-       for (win= wm->windows.first; win; win= win->next) {
+       for (win = wm->windows.first; win; win = win->next) {
                ScrArea *sa;
                
                CTX_wm_window_set(C, win);
-               for (sa= win->screen->areabase.first; sa; sa= sa->next) {
+               for (sa = win->screen->areabase.first; sa; sa = sa->next) {
                        if (sa->do_refresh) {
                                CTX_wm_area_set(C, sa);
                                ED_area_do_refresh(C, sa);
@@ -306,7 +306,7 @@ void wm_event_do_notifiers(bContext *C)
                        Main *bmain = CTX_data_main(C);
 
                        /* copied to set's in scene_update_tagged_recursive() */
-                       win->screen->scene->customdata_mask= win_combine_v3d_datamask;
+                       win->screen->scene->customdata_mask = win_combine_v3d_datamask;
 
                        /* XXX, hack so operators can enforce datamasks [#26482], gl render */
                        win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal;
@@ -328,20 +328,20 @@ static int wm_event_always_pass(wmEvent *event)
 
 static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *event, int always_pass)
 {
-       ScrArea *area= CTX_wm_area(C);
-       ARegion *region= CTX_wm_region(C);
-       ARegion *menu= CTX_wm_menu(C);
-       static int do_wheel_ui= 1;
-       int is_wheel= ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE);
+       ScrArea *area = CTX_wm_area(C);
+       ARegion *region = CTX_wm_region(C);
+       ARegion *menu = CTX_wm_menu(C);
+       static int do_wheel_ui = 1;
+       int is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE);
        int retval;
        
        /* UI is quite aggressive with swallowing events, like scrollwheel */
        /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
-       if (do_wheel_ui==0) {
+       if (do_wheel_ui == 0) {
                if (is_wheel)
                        return WM_HANDLER_CONTINUE;
-               else if (wm_event_always_pass(event)==0)
-                       do_wheel_ui= 1;
+               else if (wm_event_always_pass(event) == 0)
+                       do_wheel_ui = 1;
        }
        
        /* we set context to where ui handler came from */
@@ -349,7 +349,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
        if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region);
        if (handler->ui_menu) CTX_wm_menu_set(C, handler->ui_menu);
 
-       retval= handler->ui_handle(C, event, handler->ui_userdata);
+       retval = handler->ui_handle(C, event, handler->ui_userdata);
 
        /* putting back screen context */
        if ((retval != WM_UI_HANDLER_BREAK) || always_pass) {
@@ -369,26 +369,26 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
        
        /* event not handled in UI, if wheel then we temporarily disable it */
        if (is_wheel)
-               do_wheel_ui= 0;
+               do_wheel_ui = 0;
        
        return WM_HANDLER_CONTINUE;
 }
 
 static void wm_handler_ui_cancel(bContext *C)
 {
-       wmWindow *win= CTX_wm_window(C);
-       ARegion *ar= CTX_wm_region(C);
+       wmWindow *win = CTX_wm_window(C);
+       ARegion *ar = CTX_wm_region(C);
        wmEventHandler *handler, *nexthandler;
 
        if (!ar)
                return;
 
-       for (handler= ar->handlers.first; handler; handler= nexthandler) {
-               nexthandler= handler->next;
+       for (handler = ar->handlers.first; handler; handler = nexthandler) {
+               nexthandler = handler->next;
 
                if (handler->ui_handle) {
-                       wmEvent event= *(win->eventstate);
-                       event.type= EVT_BUT_CANCEL;
+                       wmEvent event = *(win->eventstate);
+                       event.type = EVT_BUT_CANCEL;
                        handler->ui_handle(C, &event, handler->ui_userdata);
                }
        }
@@ -400,10 +400,10 @@ int WM_operator_poll(bContext *C, wmOperatorType *ot)
 {
        wmOperatorTypeMacro *otmacro;
        
-       for (otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) {
-               wmOperatorType *ot_macro= WM_operatortype_find(otmacro->idname, 0);
+       for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
+               wmOperatorType *ot_macro = WM_operatortype_find(otmacro->idname, 0);
                
-               if (0==WM_operator_poll(C, ot_macro))
+               if (0 == WM_operator_poll(C, ot_macro))
                        return 0;
        }
        
@@ -436,9 +436,9 @@ static void wm_operator_print(bContext *C, wmOperator *op)
 void WM_event_print(wmEvent *event)
 {
        if (event) {
-               const char *unknown= "UNKNOWN";
-               const char *type_id= unknown;
-               const char *val_id= unknown;
+               const char *unknown = "UNKNOWN";
+               const char *type_id = unknown;
+               const char *val_id = unknown;
 
                RNA_enum_identifier(event_type_items, event->type, &type_id);
                RNA_enum_identifier(event_value_items, event->val, &val_id);
@@ -466,11 +466,11 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
        if (caller_owns_reports == FALSE) { /* popup */
                if (op->reports->list.first) {
                        /* FIXME, temp setting window, see other call to uiPupMenuReports for why */
-                       wmWindow *win_prev= CTX_wm_window(C);
-                       ScrArea *area_prev= CTX_wm_area(C);
-                       ARegion *ar_prev= CTX_wm_region(C);
+                       wmWindow *win_prev = CTX_wm_window(C);
+                       ScrArea *area_prev = CTX_wm_area(C);
+                       ARegion *ar_prev = CTX_wm_region(C);
 
-                       if (win_prev==NULL)
+                       if (win_prev == NULL)
                                CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
 
                        uiPupMenuReports(C, op->reports);
@@ -505,7 +505,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
        if (op->reports->list.first && (op->reports->flag & RPT_OP_HOLD) == 0) {
 
                wmWindowManager *wm = CTX_wm_manager(C);
-               ReportList *wm_reports= CTX_wm_reports(C);
+               ReportList *wm_reports = CTX_wm_reports(C);
                ReportTimerInfo *rti;
 
                /* add reports to the global list, otherwise they are not seen */
@@ -515,7 +515,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal
                WM_event_remove_timer(wm, NULL, wm_reports->reporttimer);
                
                /* Records time since last report was added */
-               wm_reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05);
+               wm_reports->reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05);
                
                rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
                wm_reports->reporttimer->customdata = rti;
@@ -532,9 +532,9 @@ static int wm_operator_register_check(wmWindowManager *wm, wmOperatorType *ot)
 
 static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
 
-       op->customdata= NULL;
+       op->customdata = NULL;
 
        /* we don't want to do undo pushes for operators that are being
         * called from operators that already do an undo push. usually
@@ -543,7 +543,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
                if (op->type->flag & OPTYPE_UNDO)
                        ED_undo_push_op(C, op);
        
-       if (repeat==0) {
+       if (repeat == 0) {
                if (G.f & G_DEBUG) {
                        char *buf = WM_operator_pystring(C, op->type, op->ptr, 1);
                        BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
@@ -560,29 +560,29 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
 /* if repeat is true, it doesn't register again, nor does it free */
 static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
-       int retval= OPERATOR_CANCELLED;
+       wmWindowManager *wm = CTX_wm_manager(C);
+       int retval = OPERATOR_CANCELLED;
        
        CTX_wm_operator_poll_msg_set(C, NULL);
        
-       if (op==NULL || op->type==NULL)
+       if (op == NULL || op->type == NULL)
                return retval;
        
-       if (0==WM_operator_poll(C, op->type))
+       if (0 == WM_operator_poll(C, op->type))
                return retval;
        
        if (op->type->exec) {
                if (op->type->flag & OPTYPE_UNDO)
                        wm->op_undo_depth++;
 
-               retval= op->type->exec(C, op);
+               retval = op->type->exec(C, op);
                OPERATOR_RETVAL_CHECK(retval);
 
                if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
                        wm->op_undo_depth--;
        }
        
-       if (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED) && repeat == 0)
+       if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) && repeat == 0)
                wm_operator_reports(C, op, retval, FALSE);
        
        if (retval & OPERATOR_FINISHED) {
@@ -593,7 +593,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
                }
                wm_operator_finished(C, op, repeat);
        }
-       else if (repeat==0) {
+       else if (repeat == 0) {
                WM_operator_free(op);
        }
        
@@ -604,12 +604,12 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
 /* simply calls exec with basic checks */
 static int wm_operator_exec_notest(bContext *C, wmOperator *op)
 {
-       int retval= OPERATOR_CANCELLED;
+       int retval = OPERATOR_CANCELLED;
 
-       if (op==NULL || op->type==NULL || op->type->exec==NULL)
+       if (op == NULL || op->type == NULL || op->type->exec == NULL)
                return retval;
 
-       retval= op->type->exec(C, op);
+       retval = op->type->exec(C, op);
        OPERATOR_RETVAL_CHECK(retval);
 
        return retval;
@@ -648,40 +648,40 @@ int WM_operator_repeat_check(const bContext *UNUSED(C), wmOperator *op)
 static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, PointerRNA *properties, ReportList *reports)
 {
        /* XXX operatortype names are static still. for debug */
-       wmOperator *op= MEM_callocN(sizeof(wmOperator), ot->idname);
+       wmOperator *op = MEM_callocN(sizeof(wmOperator), ot->idname);
        
        /* XXX adding new operator could be function, only happens here now */
-       op->type= ot;
+       op->type = ot;
        BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME);
        
        /* initialize properties, either copy or create */
-       op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
+       op->ptr = MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
        if (properties && properties->data) {
-               op->properties= IDP_CopyProperty(properties->data);
+               op->properties = IDP_CopyProperty(properties->data);
        }
        else {
                IDPropertyTemplate val = {0};
-               op->properties= IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
+               op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
        }
        RNA_pointer_create(&wm->id, ot->srna, op->properties, op->ptr);
 
        /* initialize error reports */
        if (reports) {
-               op->reports= reports; /* must be initialized already */
+               op->reports = reports; /* must be initialized already */
        }
        else {
-               op->reports= MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
-               BKE_reports_init(op->reports, RPT_STORE|RPT_FREE);
+               op->reports = MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
+               BKE_reports_init(op->reports, RPT_STORE | RPT_FREE);
        }
        
        /* recursive filling of operator macro list */
        if (ot->macro.first) {
-               static wmOperator *motherop= NULL;
+               static wmOperator *motherop = NULL;
                wmOperatorTypeMacro *otmacro;
                int root = 0;
                
                /* ensure all ops are in execution order in 1 list */
-               if (motherop==NULL) {
+               if (motherop == NULL) {
                        motherop = op;
                        root = 1;
                }
@@ -689,41 +689,42 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P
                
                /* if properties exist, it will contain everything needed */
                if (properties) {
-                       otmacro= ot->macro.first;
+                       otmacro = ot->macro.first;
 
-                       RNA_STRUCT_BEGIN(properties, prop) {
+                       RNA_STRUCT_BEGIN(properties, prop)
+                       {
 
                                if (otmacro == NULL)
                                        break;
 
                                /* skip invalid properties */
                                if (strcmp(RNA_property_identifier(prop), otmacro->idname) == 0) {
-                                       wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0);
+                                       wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0);
                                        PointerRNA someptr = RNA_property_pointer_get(properties, prop);
-                                       wmOperator *opm= wm_operator_create(wm, otm, &someptr, NULL);
+                                       wmOperator *opm = wm_operator_create(wm, otm, &someptr, NULL);
 
                                        IDP_ReplaceGroupInGroup(opm->properties, otmacro->properties);
 
                                        BLI_addtail(&motherop->macro, opm);
-                                       opm->opm= motherop; /* pointer to mom, for modal() */
+                                       opm->opm = motherop; /* pointer to mom, for modal() */
 
-                                       otmacro= otmacro->next;
+                                       otmacro = otmacro->next;
                                }
                        }
                        RNA_STRUCT_END;
                }
                else {
                        for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) {
-                               wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0);
-                               wmOperator *opm= wm_operator_create(wm, otm, otmacro->ptr, NULL);
+                               wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0);
+                               wmOperator *opm = wm_operator_create(wm, otm, otmacro->ptr, NULL);
 
                                BLI_addtail(&motherop->macro, opm);
-                               opm->opm= motherop; /* pointer to mom, for modal() */
+                               opm->opm = motherop; /* pointer to mom, for modal() */
                        }
                }
                
                if (root)
-                       motherop= NULL;
+                       motherop = NULL;
        }
        
        WM_operator_properties_sanitize(op->ptr, 0);
@@ -733,22 +734,22 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P
 
 static void wm_region_mouse_co(bContext *C, wmEvent *event)
 {
-       ARegion *ar= CTX_wm_region(C);
+       ARegion *ar = CTX_wm_region(C);
        if (ar) {
                /* compatibility convention */
-               event->mval[0]= event->x - ar->winrct.xmin;
-               event->mval[1]= event->y - ar->winrct.ymin;
+               event->mval[0] = event->x - ar->winrct.xmin;
+               event->mval[1] = event->y - ar->winrct.ymin;
        }
        else {
                /* these values are invalid (avoid odd behavior by relying on old mval values) */
-               event->mval[0]= -1;
-               event->mval[1]= -1;
+               event->mval[0] = -1;
+               event->mval[1] = -1;
        }
 }
 
 int WM_operator_last_properties_init(wmOperator *op)
 {
-       int change= FALSE;
+       int change = FALSE;
 
        if (op->type->last_properties) {
                PropertyRNA *iterprop;
@@ -758,11 +759,11 @@ int WM_operator_last_properties_init(wmOperator *op)
                iterprop = RNA_struct_iterator_property(op->type->srna);
 
                RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) {
-                       PropertyRNA *prop= itemptr.data;
+                       PropertyRNA *prop = itemptr.data;
                        if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
                                if (!RNA_property_is_set(op->ptr, prop)) { /* don't override a setting already set */
-                                       const char *identifier= RNA_property_identifier(prop);
-                                       IDProperty *idp_src= IDP_GetPropertyFromGroup(op->type->last_properties, identifier);
+                                       const char *identifier = RNA_property_identifier(prop);
+                                       IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, identifier);
                                        if (idp_src) {
                                                IDProperty *idp_dst = IDP_CopyProperty(idp_src);
 
@@ -771,7 +772,7 @@ int WM_operator_last_properties_init(wmOperator *op)
                                                idp_dst->flag |= IDP_FLAG_GHOST;
 
                                                IDP_ReplaceInGroup(op->properties, idp_dst);
-                                               change= TRUE;
+                                               change = TRUE;
                                        }
                                }
                        }
@@ -802,15 +803,15 @@ int WM_operator_last_properties_store(wmOperator *op)
 
 static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports, short poll_only)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
-       int retval= OPERATOR_PASS_THROUGH;
+       wmWindowManager *wm = CTX_wm_manager(C);
+       int retval = OPERATOR_PASS_THROUGH;
 
        /* this is done because complicated setup is done to call this function that is better not duplicated */
        if (poll_only)
                return WM_operator_poll(C, ot);
 
        if (WM_operator_poll(C, ot)) {
-               wmOperator *op= wm_operator_create(wm, ot, properties, reports); /* if reports==NULL, theyll be initialized */
+               wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports==NULL, theyll be initialized */
                const short is_nested_call = (wm->op_undo_depth != 0);
                
                /* initialize setting from previous run */
@@ -818,8 +819,8 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                        WM_operator_last_properties_init(op);
                }
 
-               if ((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE)
-                       printf("handle evt %d win %d op %s\n", event?event->type:0, CTX_wm_screen(C)->subwinactive, ot->idname); 
+               if ((G.f & G_DEBUG) && event && event->type != MOUSEMOVE)
+                       printf("handle evt %d win %d op %s\n", event ? event->type : 0, CTX_wm_screen(C)->subwinactive, ot->idname);
                
                if (op->type->invoke && event) {
                        wm_region_mouse_co(C, event);
@@ -827,7 +828,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                        if (op->type->flag & OPTYPE_UNDO)
                                wm->op_undo_depth++;
 
-                       retval= op->type->invoke(C, op, event);
+                       retval = op->type->invoke(C, op, event);
                        OPERATOR_RETVAL_CHECK(retval);
 
                        if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
@@ -837,7 +838,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                        if (op->type->flag & OPTYPE_UNDO)
                                wm->op_undo_depth++;
 
-                       retval= op->type->exec(C, op);
+                       retval = op->type->exec(C, op);
                        OPERATOR_RETVAL_CHECK(retval);
 
                        if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
@@ -850,13 +851,13 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                
                /* Note, if the report is given as an argument then assume the caller will deal with displaying them
                 * currently python only uses this */
-               if (!(retval & OPERATOR_HANDLED) && (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED))) {
+               if (!(retval & OPERATOR_HANDLED) && (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED))) {
                        /* only show the report if the report list was not given in the function */
                        wm_operator_reports(C, op, retval, (reports != NULL));
                }
 
                if (retval & OPERATOR_HANDLED)
-                       ; /* do nothing, wm_operator_exec() has been called somewhere */
+                       ;  /* do nothing, wm_operator_exec() has been called somewhere */
                else if (retval & OPERATOR_FINISHED) {
                        if (!is_nested_call) { /* not called by py script */
                                WM_operator_last_properties_store(op);
@@ -868,7 +869,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                         * Also check for macro
                         */
                        if (ot->flag & OPTYPE_BLOCKING || (op->opm && op->opm->type->flag & OPTYPE_BLOCKING)) {
-                               int bounds[4] = {-1,-1,-1,-1};
+                               int bounds[4] = {-1, -1, -1, -1};
                                int wrap;
 
                                if (op->opm) {
@@ -882,31 +883,31 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
 
                                /* exception, cont. grab in header is annoying */
                                if (wrap) {
-                                       ARegion *ar= CTX_wm_region(C);
+                                       ARegion *ar = CTX_wm_region(C);
                                        if (ar && ar->regiontype == RGN_TYPE_HEADER) {
-                                               wrap= FALSE;
+                                               wrap = FALSE;
                                        }
                                }
 
                                if (wrap) {
-                                       rcti *winrect= NULL;
-                                       ARegion *ar= CTX_wm_region(C);
-                                       ScrArea *sa= CTX_wm_area(C);
+                                       rcti *winrect = NULL;
+                                       ARegion *ar = CTX_wm_region(C);
+                                       ScrArea *sa = CTX_wm_area(C);
 
                                        if (ar && ar->regiontype == RGN_TYPE_WINDOW && event &&
                                            BLI_in_rcti(&ar->winrct, event->x, event->y))
                                        {
-                                               winrect= &ar->winrct;
+                                               winrect = &ar->winrct;
                                        }
                                        else if (sa) {
-                                               winrect= &sa->totrct;
+                                               winrect = &sa->totrct;
                                        }
 
                                        if (winrect) {
-                                               bounds[0]= winrect->xmin;
-                                               bounds[1]= winrect->ymax;
-                                               bounds[2]= winrect->xmax;
-                                               bounds[3]= winrect->ymin;
+                                               bounds[0] = winrect->xmin;
+                                               bounds[1] = winrect->ymax;
+                                               bounds[2] = winrect->xmax;
+                                               bounds[3] = winrect->ymin;
                                        }
                                }
 
@@ -919,8 +920,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                         * none to the UI handler */
                        wm_handler_ui_cancel(C);
                }
-               else
+               else {
                        WM_operator_free(op);
+               }
        }
 
        return retval;
@@ -933,7 +935,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
 static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports,
                                      short context, short poll_only)
 {
-       wmWindow *window= CTX_wm_window(C);
+       wmWindow *window = CTX_wm_window(C);
        wmEvent *event;
        
        int retval;
@@ -942,7 +944,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
 
        /* dummie test */
        if (ot && C) {
-               switch(context) {
+               switch (context) {
                        case WM_OP_INVOKE_DEFAULT:
                        case WM_OP_INVOKE_REGION_WIN:
                        case WM_OP_INVOKE_AREA:
@@ -951,13 +953,13 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
                                if (window == NULL)
                                        return 0;
                                else
-                                       event= window->eventstate;
+                                       event = window->eventstate;
                                break;
                        default:
                                event = NULL;
                }
 
-               switch(context) {
+               switch (context) {
                        
                        case WM_OP_EXEC_REGION_WIN:
                        case WM_OP_INVOKE_REGION_WIN: 
@@ -969,8 +971,8 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
                                /* forces operator to go to the region window/channels/preview, for header menus
                                 * but we stay in the same region if we are already in one 
                                 */
-                               ARegion *ar= CTX_wm_region(C);
-                               ScrArea *area= CTX_wm_area(C);
+                               ARegion *ar = CTX_wm_region(C);
+                               ScrArea *area = CTX_wm_area(C);
                                int type = RGN_TYPE_WINDOW;
                                
                                switch (context) {
@@ -992,12 +994,12 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
                                }
                                
                                if (!(ar && ar->regiontype == type) && area) {
-                                       ARegion *ar1= BKE_area_find_region_type(area, type);
+                                       ARegion *ar1 = BKE_area_find_region_type(area, type);
                                        if (ar1)
                                                CTX_wm_region_set(C, ar1);
                                }
                                
-                               retval= wm_operator_invoke(C, ot, event, properties, reports, poll_only);
+                               retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only);
                                
                                /* set region back */
                                CTX_wm_region_set(C, ar);
@@ -1007,11 +1009,11 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
                        case WM_OP_EXEC_AREA:
                        case WM_OP_INVOKE_AREA:
                        {
-                                       /* remove region from context */
-                               ARegion *ar= CTX_wm_region(C);
+                               /* remove region from context */
+                               ARegion *ar = CTX_wm_region(C);
 
                                CTX_wm_region_set(C, NULL);
-                               retval= wm_operator_invoke(C, ot, event, properties, reports, poll_only);
+                               retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only);
                                CTX_wm_region_set(C, ar);
 
                                return retval;
@@ -1020,12 +1022,12 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
                        case WM_OP_INVOKE_SCREEN:
                        {
                                /* remove region + area from context */
-                               ARegion *ar= CTX_wm_region(C);
-                               ScrArea *area= CTX_wm_area(C);
+                               ARegion *ar = CTX_wm_region(C);
+                               ScrArea *area = CTX_wm_area(C);
 
                                CTX_wm_region_set(C, NULL);
                                CTX_wm_area_set(C, NULL);
-                               retval= wm_operator_invoke(C, ot, event, properties, reports, poll_only);
+                               retval = wm_operator_invoke(C, ot, event, properties, reports, poll_only);
                                CTX_wm_area_set(C, area);
                                CTX_wm_region_set(C, ar);
 
@@ -1044,7 +1046,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
 /* invokes operator in context */
 int WM_operator_name_call(bContext *C, const char *opstring, int context, PointerRNA *properties)
 {
-       wmOperatorType *ot= WM_operatortype_find(opstring, 0);
+       wmOperatorType *ot = WM_operatortype_find(opstring, 0);
        if (ot)
                return wm_operator_call_internal(C, ot, properties, NULL, context, FALSE);
 
@@ -1058,17 +1060,17 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe
  */
 int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports)
 {
-       int retval= OPERATOR_CANCELLED;
+       int retval = OPERATOR_CANCELLED;
 
 #if 0
        wmOperator *op;
-       op= wm_operator_create(wm, ot, properties, reports);
+       op = wm_operator_create(wm, ot, properties, reports);
 
        if (op->type->exec) {
                if (op->type->flag & OPTYPE_UNDO)
                        wm->op_undo_depth++;
 
-               retval= op->type->exec(C, op);
+               retval = op->type->exec(C, op);
                OPERATOR_RETVAL_CHECK(retval);
 
                if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
@@ -1091,9 +1093,9 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA
        if (wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--;
 
        /* keep the reports around if needed later */
-       if (    (retval & OPERATOR_RUNNING_MODAL) ||
-                       ((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot))
-       {
+       if ((retval & OPERATOR_RUNNING_MODAL) ||
+           ((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot)))
+       {
                reports->flag |= RPT_FREE; /* let blender manage freeing */
        }
        
@@ -1112,28 +1114,28 @@ void wm_event_free_handler(wmEventHandler *handler)
 /* only set context when area/region is part of screen */
 static void wm_handler_op_context(bContext *C, wmEventHandler *handler)
 {
-       bScreen *screen= CTX_wm_screen(C);
+       bScreen *screen = CTX_wm_screen(C);
        
        if (screen && handler->op) {
-               if (handler->op_area==NULL)
+               if (handler->op_area == NULL)
                        CTX_wm_area_set(C, NULL);
                else {
                        ScrArea *sa;
                        
-                       for (sa= screen->areabase.first; sa; sa= sa->next)
-                               if (sa==handler->op_area)
+                       for (sa = screen->areabase.first; sa; sa = sa->next)
+                               if (sa == handler->op_area)
                                        break;
-                       if (sa==NULL) {
+                       if (sa == NULL) {
                                /* when changing screen layouts with running modal handlers (like render display), this
                                 * is not an error to print */
-                               if (handler->op==NULL)
+                               if (handler->op == NULL)
                                        printf("internal error: handler (%s) has invalid area\n", handler->op->type->idname);
                        }
                        else {
                                ARegion *ar;
                                CTX_wm_area_set(C, sa);
-                               for (ar= sa->regionbase.first; ar; ar= ar->next)
-                                       if (ar==handler->op_region)
+                               for (ar = sa->regionbase.first; ar; ar = ar->next)
+                                       if (ar == handler->op_region)
                                                break;
                                /* XXX no warning print here, after full-area and back regions are remade */
                                if (ar)
@@ -1147,16 +1149,16 @@ static void wm_handler_op_context(bContext *C, wmEventHandler *handler)
 void WM_event_remove_handlers(bContext *C, ListBase *handlers)
 {
        wmEventHandler *handler;
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        
        /* C is zero on freeing database, modal handlers then already were freed */
-       while ((handler=handlers->first)) {
+       while ((handler = handlers->first)) {
                BLI_remlink(handlers, handler);
                
                if (handler->op) {
                        if (handler->op->type->cancel) {
-                               ScrArea *area= CTX_wm_area(C);
-                               ARegion *region= CTX_wm_region(C);
+                               ScrArea *area = CTX_wm_area(C);
+                               ARegion *region = CTX_wm_region(C);
                                
                                wm_handler_op_context(C, handler);
 
@@ -1176,9 +1178,9 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
                        WM_operator_free(handler->op);
                }
                else if (handler->ui_remove) {
-                       ScrArea *area= CTX_wm_area(C);
-                       ARegion *region= CTX_wm_region(C);
-                       ARegion *menu= CTX_wm_menu(C);
+                       ScrArea *area = CTX_wm_area(C);
+                       ARegion *region = CTX_wm_region(C);
+                       ARegion *menu = CTX_wm_menu(C);
                        
                        if (handler->ui_area) CTX_wm_area_set(C, handler->ui_area);
                        if (handler->ui_region) CTX_wm_region_set(C, handler->ui_region);
@@ -1198,7 +1200,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
 /* do userdef mappings */
 int WM_userdef_event_map(int kmitype)
 {
-       switch(kmitype) {
+       switch (kmitype) {
                case SELECTMOUSE:
                        if (U.flag & USER_LMOUSESELECT)
                                return LEFTMOUSE;
@@ -1265,7 +1267,7 @@ static void wm_eventemulation(wmEvent *event)
 
        /* numpad emulation */
        if (U.flag & USER_NONUMPAD) {
-               switch(event->type) {
+               switch (event->type) {
                        case ZEROKEY: event->type = PAD0; break;
                        case ONEKEY: event->type = PAD1; break;
                        case TWOKEY: event->type = PAD2; break;
@@ -1285,37 +1287,37 @@ static void wm_eventemulation(wmEvent *event)
 
 static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi)
 {
-       int kmitype= WM_userdef_event_map(kmi->type);
+       int kmitype = WM_userdef_event_map(kmi->type);
 
        if (kmi->flag & KMI_INACTIVE) return 0;
 
        /* the matching rules */
-       if (kmitype==KM_TEXTINPUT)
+       if (kmitype == KM_TEXTINPUT)
                if (ISTEXTINPUT(winevent->type) && (winevent->ascii || winevent->utf8_buf[0])) return 1;
-       if (kmitype!=KM_ANY)
-               if (winevent->type!=kmitype) return 0;
+       if (kmitype != KM_ANY)
+               if (winevent->type != kmitype) return 0;
        
-       if (kmi->val!=KM_ANY)
-               if (winevent->val!=kmi->val) return 0;
+       if (kmi->val != KM_ANY)
+               if (winevent->val != kmi->val) return 0;
        
        /* modifiers also check bits, so it allows modifier order */
-       if (kmi->shift!=KM_ANY)
+       if (kmi->shift != KM_ANY)
                if (winevent->shift != kmi->shift && !(winevent->shift & kmi->shift)) return 0;
-       if (kmi->ctrl!=KM_ANY)
+       if (kmi->ctrl != KM_ANY)
                if (winevent->ctrl != kmi->ctrl && !(winevent->ctrl & kmi->ctrl)) return 0;
-       if (kmi->alt!=KM_ANY)
+       if (kmi->alt != KM_ANY)
                if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) return 0;
-       if (kmi->oskey!=KM_ANY)
+       if (kmi->oskey != KM_ANY)
                if (winevent->oskey != kmi->oskey && !(winevent->oskey & kmi->oskey)) return 0;
        
        if (kmi->keymodifier)
-               if (winevent->keymodifier!=kmi->keymodifier) return 0;
+               if (winevent->keymodifier != kmi->keymodifier) return 0;
                
        /* key modifiers always check when event has it */
        /* otherwise regular keypresses with keymodifier still work */
        if (winevent->keymodifier)
                if (ISTEXTINPUT(winevent->type)) 
-                       if (winevent->keymodifier!=kmi->keymodifier) return 0;
+                       if (winevent->keymodifier != kmi->keymodifier) return 0;
        
        return 1;
 }
@@ -1329,14 +1331,14 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve
                op = op->opm;
 
        if (op->type->modalkeymap) {
-               wmKeyMap *keymap= WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap);
+               wmKeyMap *keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap);
                wmKeyMapItem *kmi;
 
                for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
                        if (wm_eventmatch(event, kmi)) {
                                        
-                               event->type= EVT_MODAL_MAP;
-                               event->val= kmi->propvalue;
+                               event->type = EVT_MODAL_MAP;
+                               event->val = kmi->propvalue;
                        }
                }
        }
@@ -1346,18 +1348,18 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve
 static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler,
                                     wmEvent *event, PointerRNA *properties)
 {
-       int retval= OPERATOR_PASS_THROUGH;
+       int retval = OPERATOR_PASS_THROUGH;
        
        /* derived, modal or blocking operator */
        if (handler->op) {
-               wmOperator *op= handler->op;
-               wmOperatorType *ot= op->type;
+               wmOperator *op = handler->op;
+               wmOperatorType *ot = op->type;
 
                if (ot->modal) {
                        /* we set context to where modal handler came from */
-                       wmWindowManager *wm= CTX_wm_manager(C);
-                       ScrArea *area= CTX_wm_area(C);
-                       ARegion *region= CTX_wm_region(C);
+                       wmWindowManager *wm = CTX_wm_manager(C);
+                       ScrArea *area = CTX_wm_area(C);
+                       ARegion *region = CTX_wm_region(C);
                        
                        wm_handler_op_context(C, handler);
                        wm_region_mouse_co(C, event);
@@ -1366,7 +1368,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
                        if (ot->flag & OPTYPE_UNDO)
                                wm->op_undo_depth++;
 
-                       retval= ot->modal(C, op, event);
+                       retval = ot->modal(C, op, event);
                        OPERATOR_RETVAL_CHECK(retval);
 
                        /* when this is _not_ the case the modal modifier may have loaded
@@ -1388,20 +1390,20 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
                                        CTX_wm_region_set(C, NULL);
                                }
 
-                               if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED))
+                               if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED))
                                        wm_operator_reports(C, op, retval, FALSE);
 
                                if (retval & OPERATOR_FINISHED) {
                                        wm_operator_finished(C, op, 0);
-                                       handler->op= NULL;
+                                       handler->op = NULL;
                                }
-                               else if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
+                               else if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
                                        WM_operator_free(op);
-                                       handler->op= NULL;
+                                       handler->op = NULL;
                                }
 
                                /* remove modal handler, operator itself should have been canceled and freed */
-                               if (retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
+                               if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
                                        WM_cursor_ungrab(CTX_wm_window(C));
 
                                        BLI_remlink(handlers, handler);
@@ -1417,20 +1419,20 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
                        printf("wm_handler_operator_call error\n");
        }
        else {
-               wmOperatorType *ot= WM_operatortype_find(event->keymap_idname, 0);
+               wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0);
 
                if (ot)
-                       retval= wm_operator_invoke(C, ot, event, properties, NULL, FALSE);
+                       retval = wm_operator_invoke(C, ot, event, properties, NULL, FALSE);
        }
        /* Finished and pass through flag as handled */
 
        /* Finished and pass through flag as handled */
-       if (retval == (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH))
+       if (retval == (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH))
                return WM_HANDLER_HANDLED;
 
        /* Modal unhandled, break */
-       if (retval == (OPERATOR_PASS_THROUGH|OPERATOR_RUNNING_MODAL))
-               return (WM_HANDLER_BREAK|WM_HANDLER_MODAL);
+       if (retval == (OPERATOR_PASS_THROUGH | OPERATOR_RUNNING_MODAL))
+               return (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
 
        if (retval & OPERATOR_PASS_THROUGH)
                return WM_HANDLER_CONTINUE;
@@ -1441,163 +1443,163 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
 /* fileselect handlers are only in the window queue, so it's save to switch screens or area types */
 static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        SpaceFile *sfile;
-       int action= WM_HANDLER_CONTINUE;
+       int action = WM_HANDLER_CONTINUE;
        
        if (event->type != EVT_FILESELECT)
                return action;
        if (handler->op != (wmOperator *)event->customdata)
                return action;
        
-       switch(event->val) {
+       switch (event->val) {
                case EVT_FILESELECT_OPEN: 
                case EVT_FILESELECT_FULL_OPEN: 
-                       {       
-                               ScrArea *sa;
+               {
+                       ScrArea *sa;
                                
-                               /* sa can be null when window A is active, but mouse is over window B */
-                               /* in this case, open file select in original window A */
-                               if (handler->op_area == NULL) {
-                                       bScreen *screen = CTX_wm_screen(C);
-                                       sa = (ScrArea *)screen->areabase.first;
-                               }
-                               else {
-                                       sa = handler->op_area;
-                               }
+                       /* sa can be null when window A is active, but mouse is over window B */
+                       /* in this case, open file select in original window A */
+                       if (handler->op_area == NULL) {
+                               bScreen *screen = CTX_wm_screen(C);
+                               sa = (ScrArea *)screen->areabase.first;
+                       }
+                       else {
+                               sa = handler->op_area;
+                       }
                                        
-                               if (event->val==EVT_FILESELECT_OPEN) {
-                                       ED_area_newspace(C, sa, SPACE_FILE); /* 'sa' is modified in-place */
-                               }
-                               else {
-                                       sa= ED_screen_full_newspace(C, sa, SPACE_FILE); /* sets context */
-                               }
+                       if (event->val == EVT_FILESELECT_OPEN) {
+                               ED_area_newspace(C, sa, SPACE_FILE);     /* 'sa' is modified in-place */
+                       }
+                       else {
+                               sa = ED_screen_full_newspace(C, sa, SPACE_FILE);    /* sets context */
+                       }
 
-                               /* note, getting the 'sa' back from the context causes a nasty bug where the newly created
-                                * 'sa' != CTX_wm_area(C). removed the line below and set 'sa' in the 'if' above */
-                               /* sa = CTX_wm_area(C); */
+                       /* note, getting the 'sa' back from the context causes a nasty bug where the newly created
+                        * 'sa' != CTX_wm_area(C). removed the line below and set 'sa' in the 'if' above */
+                       /* sa = CTX_wm_area(C); */
 
-                               /* settings for filebrowser, sfile is not operator owner but sends events */
-                               sfile= (SpaceFile*)sa->spacedata.first;
-                               sfile->op= handler->op;
+                       /* settings for filebrowser, sfile is not operator owner but sends events */
+                       sfile = (SpaceFile *)sa->spacedata.first;
+                       sfile->op = handler->op;
 
-                               ED_fileselect_set_params(sfile);
+                       ED_fileselect_set_params(sfile);
                                
-                               action= WM_HANDLER_BREAK;
-                       }
-                       break;
+                       action = WM_HANDLER_BREAK;
+               }
+               break;
                        
                case EVT_FILESELECT_EXEC:
                case EVT_FILESELECT_CANCEL:
                case EVT_FILESELECT_EXTERNAL_CANCEL:
-                       {
-                               /* XXX validate area and region? */
-                               bScreen *screen= CTX_wm_screen(C);
+               {
+                       /* XXX validate area and region? */
+                       bScreen *screen = CTX_wm_screen(C);
 
-                               /* remlink now, for load file case before removing*/
-                               BLI_remlink(handlers, handler);
+                       /* remlink now, for load file case before removing*/
+                       BLI_remlink(handlers, handler);
                                
-                               if (event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) {
-                                       if (screen != handler->filescreen) {
-                                               ED_screen_full_prevspace(C, CTX_wm_area(C));
-                                       }
-                                       else {
-                                               ED_area_prevspace(C, CTX_wm_area(C));
-                                       }
+                       if (event->val != EVT_FILESELECT_EXTERNAL_CANCEL) {
+                               if (screen != handler->filescreen) {
+                                       ED_screen_full_prevspace(C, CTX_wm_area(C));
+                               }
+                               else {
+                                       ED_area_prevspace(C, CTX_wm_area(C));
                                }
+                       }
                                
-                               wm_handler_op_context(C, handler);
+                       wm_handler_op_context(C, handler);
 
-                               /* needed for uiPupMenuReports */
+                       /* needed for uiPupMenuReports */
 
-                               if (event->val==EVT_FILESELECT_EXEC) {
-#if 0                          // use REDALERT now
+                       if (event->val == EVT_FILESELECT_EXEC) {
+#if 0               // use REDALERT now
 
-                                       /* a bit weak, might become arg for WM_event_fileselect? */
-                                       /* XXX also extension code in image-save doesnt work for this yet */
-                                       if (RNA_struct_find_property(handler->op->ptr, "check_existing") && 
-                                                       RNA_boolean_get(handler->op->ptr, "check_existing")) {
-                                               char *path= RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0);
-                                               /* this gives ownership to pupmenu */
-                                               uiPupMenuSaveOver(C, handler->op, (path)? path: "");
-                                               if (path)
-                                                       MEM_freeN(path);
-                                       }
-                                       else
+                               /* a bit weak, might become arg for WM_event_fileselect? */
+                               /* XXX also extension code in image-save doesnt work for this yet */
+                               if (RNA_struct_find_property(handler->op->ptr, "check_existing") &&
+                                   RNA_boolean_get(handler->op->ptr, "check_existing")) {
+                                       char *path = RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0);
+                                       /* this gives ownership to pupmenu */
+                                       uiPupMenuSaveOver(C, handler->op, (path) ? path : "");
+                                       if (path)
+                                               MEM_freeN(path);
+                               }
+                               else
 #endif
-                                       {
-                                               int retval;
+                               {
+                                       int retval;
                                                
-                                               if (handler->op->type->flag & OPTYPE_UNDO)
-                                                       wm->op_undo_depth++;
-
-                                               retval= handler->op->type->exec(C, handler->op);
-
-                                               /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
-                                               if (handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
-                                                       wm->op_undo_depth--;
+                                       if (handler->op->type->flag & OPTYPE_UNDO)
+                                               wm->op_undo_depth++;
                                                
-                                               if (retval & OPERATOR_FINISHED)
-                                                       if (G.f & G_DEBUG)
-                                                               wm_operator_print(C, handler->op);
-                                               
-                                               /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
-                                               if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0)
-                                                       if (handler->op->type->flag & OPTYPE_UNDO)
-                                                               ED_undo_push_op(C, handler->op);
+                                       retval = handler->op->type->exec(C, handler->op);
 
-                                               if (handler->op->reports->list.first) {
+                                       /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
+                                       if (handler->op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
+                                               wm->op_undo_depth--;
 
-                                                       /* FIXME, temp setting window, this is really bad!
-                                                        * only have because lib linking errors need to be seen by users :(
-                                                        * it can be removed without breaking anything but then no linking errors - campbell */
-                                                       wmWindow *win_prev= CTX_wm_window(C);
-                                                       ScrArea *area_prev= CTX_wm_area(C);
-                                                       ARegion *ar_prev= CTX_wm_region(C);
+                                       if (retval & OPERATOR_FINISHED)
+                                               if (G.f & G_DEBUG)
+                                                       wm_operator_print(C, handler->op);
 
-                                                       if (win_prev==NULL)
-                                                               CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
+                                       /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */
+                                       if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0)
+                                               if (handler->op->type->flag & OPTYPE_UNDO)
+                                                       ED_undo_push_op(C, handler->op);
 
-                                                       handler->op->reports->printlevel = RPT_WARNING;
-                                                       uiPupMenuReports(C, handler->op->reports);
+                                       if (handler->op->reports->list.first) {
 
-                                                       /* XXX - copied from 'wm_operator_finished()' */
-                                                       /* add reports to the global list, otherwise they are not seen */
-                                                       BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list);
+                                               /* FIXME, temp setting window, this is really bad!
+                                                * only have because lib linking errors need to be seen by users :(
+                                                * it can be removed without breaking anything but then no linking errors - campbell */
+                                               wmWindow *win_prev = CTX_wm_window(C);
+                                               ScrArea *area_prev = CTX_wm_area(C);
+                                               ARegion *ar_prev = CTX_wm_region(C);
 
-                                                       CTX_wm_window_set(C, win_prev);
-                                                       CTX_wm_area_set(C, area_prev);
-                                                       CTX_wm_region_set(C, ar_prev);
-                                               }
+                                               if (win_prev == NULL)
+                                                       CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
 
-                                               if (retval & OPERATOR_FINISHED) {
-                                                       WM_operator_last_properties_store(handler->op);
-                                               }
+                                               handler->op->reports->printlevel = RPT_WARNING;
+                                               uiPupMenuReports(C, handler->op->reports);
 
-                                               WM_operator_free(handler->op);
-                                       }
-                               }
-                               else {
-                                       if (handler->op->type->cancel) {
-                                               if (handler->op->type->flag & OPTYPE_UNDO)
-                                                       wm->op_undo_depth++;
+                                               /* XXX - copied from 'wm_operator_finished()' */
+                                               /* add reports to the global list, otherwise they are not seen */
+                                               BLI_movelisttolist(&CTX_wm_reports(C)->list, &handler->op->reports->list);
 
-                                               handler->op->type->cancel(C, handler->op);
+                                               CTX_wm_window_set(C, win_prev);
+                                               CTX_wm_area_set(C, area_prev);
+                                               CTX_wm_region_set(C, ar_prev);
+                                       }
 
-                                               if (handler->op->type->flag & OPTYPE_UNDO)
-                                                       wm->op_undo_depth--;
+                                       if (retval & OPERATOR_FINISHED) {
+                                               WM_operator_last_properties_store(handler->op);
                                        }
 
                                        WM_operator_free(handler->op);
                                }
+                       }
+                       else {
+                               if (handler->op->type->cancel) {
+                                       if (handler->op->type->flag & OPTYPE_UNDO)
+                                               wm->op_undo_depth++;
 
-                               CTX_wm_area_set(C, NULL);
+                                       handler->op->type->cancel(C, handler->op);
                                
-                               wm_event_free_handler(handler);
+                                       if (handler->op->type->flag & OPTYPE_UNDO)
+                                               wm->op_undo_depth--;
+                               }
                                
-                               action= WM_HANDLER_BREAK;
+                               WM_operator_free(handler->op);
                        }
-                       break;
+
+                       CTX_wm_area_set(C, NULL);
+
+                       wm_event_free_handler(handler);
+
+                       action = WM_HANDLER_BREAK;
+               }
+               break;
        }
        
        return action;
@@ -1607,12 +1609,12 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
 {
        if (handler->bbwin) {
                if (handler->bblocal) {
-                       rcti rect= *handler->bblocal;
+                       rcti rect = *handler->bblocal;
                        BLI_translate_rcti(&rect, handler->bbwin->xmin, handler->bbwin->ymin);
 
                        if (BLI_in_rcti(&rect, event->x, event->y))
                                return 1;
-                       else if (event->type==MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy))
+                       else if (event->type == MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy))
                                return 1;
                        else
                                return 0;
@@ -1620,7 +1622,7 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
                else {
                        if (BLI_in_rcti(handler->bbwin, event->x, event->y))
                                return 1;
-                       else if (event->type==MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy))
+                       else if (event->type == MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy))
                                return 1;
                        else
                                return 0;
@@ -1631,36 +1633,36 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
 
 static int wm_action_not_handled(int action)
 {
-       return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL);
+       return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL);
 }
 
 static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmEventHandler *handler, *nexthandler;
-       int action= WM_HANDLER_CONTINUE;
+       int action = WM_HANDLER_CONTINUE;
        int always_pass;
 
-       if (handlers==NULL) return action;
+       if (handlers == NULL) return action;
 
        /* modal handlers can get removed in this loop, we keep the loop this way */
-       for (handler= handlers->first; handler; handler= nexthandler) {
+       for (handler = handlers->first; handler; handler = nexthandler) {
                
-               nexthandler= handler->next;
+               nexthandler = handler->next;
                
                /* during this loop, ui handlers for nested menus can tag multiple handlers free */
-               if (handler->flag & WM_HANDLER_DO_FREE);
-                       /* optional boundbox */
+               if (handler->flag & WM_HANDLER_DO_FREE) ;
+               /* optional boundbox */
                else if (handler_boundbox_test(handler, event)) {
                        /* in advance to avoid access to freed event on window close */
-                       always_pass= wm_event_always_pass(event);
+                       always_pass = wm_event_always_pass(event);
                
                        /* modal+blocking handler */
                        if (handler->flag & WM_HANDLER_BLOCKING)
                                action |= WM_HANDLER_BREAK;
 
                        if (handler->keymap) {
-                               wmKeyMap *keymap= WM_keymap_active(wm, handler->keymap);
+                               wmKeyMap *keymap = WM_keymap_active(wm, handler->keymap);
                                wmKeyMapItem *kmi;
                                
                                if (!keymap->poll || keymap->poll(C)) {
@@ -1680,34 +1682,34 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                        else if (handler->ui_handle) {
                                action |= wm_handler_ui_call(C, handler, event, always_pass);
                        }
-                       else if (handler->type==WM_HANDLER_FILESELECT) {
+                       else if (handler->type == WM_HANDLER_FILESELECT) {
                                /* screen context changes here */
                                action |= wm_handler_fileselect_call(C, handlers, handler, event);
                        }
                        else if (handler->dropboxes) {
-                               if (event->type==EVT_DROP) {
-                                       wmDropBox *drop= handler->dropboxes->first;
-                                       for (; drop; drop= drop->next) {
+                               if (event->type == EVT_DROP) {
+                                       wmDropBox *drop = handler->dropboxes->first;
+                                       for (; drop; drop = drop->next) {
                                                /* other drop custom types allowed */
-                                               if (event->custom==EVT_DATA_LISTBASE) {
-                                                       ListBase *lb= (ListBase *)event->customdata;
+                                               if (event->custom == EVT_DATA_LISTBASE) {
+                                                       ListBase *lb = (ListBase *)event->customdata;
                                                        wmDrag *drag;
                                                        
-                                                       for (drag= lb->first; drag; drag= drag->next) {
+                                                       for (drag = lb->first; drag; drag = drag->next) {
                                                                if (drop->poll(C, drag, event)) {
                                                                        
                                                                        drop->copy(drag, drop);
                                                                        
                                                                        /* free the drags before calling operator */
                                                                        BLI_freelistN(event->customdata);
-                                                                       event->customdata= NULL;
-                                                                       event->custom= 0;
+                                                                       event->customdata = NULL;
+                                                                       event->custom = 0;
                                                                        
                                                                        WM_operator_name_call(C, drop->ot->idname, drop->opcontext, drop->ptr);
                                                                        action |= WM_HANDLER_BREAK;
                                                                        
                                                                        /* XXX fileread case */
-                                                                       if (CTX_wm_window(C)==NULL)
+                                                                       if (CTX_wm_window(C) == NULL)
                                                                                return action;
                                                                        
                                                                        /* escape from drag loop, got freed */
@@ -1733,7 +1735,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                
                /* XXX fileread case, if the wm is freed then the handler's
                 * will have been too so the code below need not run. */
-               if (CTX_wm_window(C)==NULL) {
+               if (CTX_wm_window(C) == NULL) {
                        return action;
                }
 
@@ -1762,10 +1764,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                         *   If no double click events are found it will fallback to a single click.
                         *   So a double click event can result in 2 successive single click calls
                         *   if its not handled by the keymap - campbell */
-                       if (    (ABS(event->x - win->eventstate->prevclickx)) <= 2 &&
-                                       (ABS(event->y - win->eventstate->prevclicky)) <= 2 &&
-                                       ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time)
-                       {
+                       if ((ABS(event->x - win->eventstate->prevclickx)) <= 2 &&
+                           (ABS(event->y - win->eventstate->prevclicky)) <= 2 &&
+                           ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time))
+                       {
                                event->val = KM_DBL_CLICK;
                                /* removed this because in cases where we're this is used as a single click
                                 * event, this will give old coords,
@@ -1788,7 +1790,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                }
        }
        
-       if (action == (WM_HANDLER_BREAK|WM_HANDLER_MODAL))
+       if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL))
                wm_cursor_arrow_move(CTX_wm_window(C), event);
 
        return action;
@@ -1800,8 +1802,8 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect)
                return 1;
        if (BLI_in_rcti(rect, event->x, event->y))
                return 1;
-       if (event->type==MOUSEMOVE) {
-               if ( BLI_in_rcti(rect, event->prevx, event->prevy)) {
+       if (event->type == MOUSEMOVE) {
+               if (BLI_in_rcti(rect, event->prevx, event->prevy)) {
                        return 1;
                }
                return 0;
@@ -1811,11 +1813,11 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect)
 
 static ScrArea *area_event_inside(bContext *C, int x, int y)
 {
-       bScreen *screen= CTX_wm_screen(C);
+       bScreen *screen = CTX_wm_screen(C);
        ScrArea *sa;
        
        if (screen)
-               for (sa= screen->areabase.first; sa; sa= sa->next)
+               for (sa = screen->areabase.first; sa; sa = sa->next)
                        if (BLI_in_rcti(&sa->totrct, x, y))
                                return sa;
        return NULL;
@@ -1823,12 +1825,12 @@ static ScrArea *area_event_inside(bContext *C, int x, int y)
 
 static ARegion *region_event_inside(bContext *C, int x, int y)
 {
-       bScreen *screen= CTX_wm_screen(C);
-       ScrArea *area= CTX_wm_area(C);
+       bScreen *screen = CTX_wm_screen(C);
+       ScrArea *area = CTX_wm_area(C);
        ARegion *ar;
        
        if (screen && area)
-               for (ar= area->regionbase.first; ar; ar= ar->next)
+               for (ar = area->regionbase.first; ar; ar = ar->next)
                        if (BLI_in_rcti(&ar->winrct, x, y))
                                return ar;
        return NULL;
@@ -1837,10 +1839,10 @@ static ARegion *region_event_inside(bContext *C, int x, int y)
 static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar)
 {
        if (ar) {
-               for (; pc; pc= pc->next) {
+               for (; pc; pc = pc->next) {
                        if (pc->poll == NULL || pc->poll(C)) {
-                               wmWindow *win= CTX_wm_window(C);
-                               win->screen->do_draw_paintcursor= 1;
+                               wmWindow *win = CTX_wm_window(C);
+                               win->screen->do_draw_paintcursor = 1;
                                wm_tag_redraw_overlay(win, ar);
                        }
                }
@@ -1851,17 +1853,17 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar)
 /* context was set on active area and region */
 static void wm_paintcursor_test(bContext *C, wmEvent *event)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        
        if (wm->paintcursors.first) {
-               ARegion *ar= CTX_wm_region(C);
+               ARegion *ar = CTX_wm_region(C);
                
                if (ar)
                        wm_paintcursor_tag(C, wm->paintcursors.first, ar);
                
                /* if previous position was not in current region, we have to set a temp new context */
-               if (ar==NULL || !BLI_in_rcti(&ar->winrct, event->prevx, event->prevy)) {
-                       ScrArea *sa= CTX_wm_area(C);
+               if (ar == NULL || !BLI_in_rcti(&ar->winrct, event->prevx, event->prevy)) {
+                       ScrArea *sa = CTX_wm_area(C);
                        
                        CTX_wm_area_set(C, area_event_inside(C, event->prevx, event->prevy));
                        CTX_wm_region_set(C, region_event_inside(C, event->prevx, event->prevy));
@@ -1876,16 +1878,16 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event)
 
 static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *event)
 {
-       if (wm->drags.first==NULL) return;
+       if (wm->drags.first == NULL) return;
        
-       if (event->type==MOUSEMOVE)
-               win->screen->do_draw_drag= 1;
-       else if (event->type==ESCKEY) {
+       if (event->type == MOUSEMOVE)
+               win->screen->do_draw_drag = 1;
+       else if (event->type == ESCKEY) {
                BLI_freelistN(&wm->drags);
-               win->screen->do_draw_drag= 1;
+               win->screen->do_draw_drag = 1;
        }
-       else if (event->type==LEFTMOUSE && event->val==KM_RELEASE) {
-               event->type= EVT_DROP;
+       else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
+               event->type = EVT_DROP;
                
                /* create customdata, first free existing */
                if (event->customdata) {
@@ -1893,12 +1895,12 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
                                MEM_freeN(event->customdata);
                }
                
-               event->custom= EVT_DATA_LISTBASE;
-               event->customdata= &wm->drags;
-               event->customdatafree= 1;
+               event->custom = EVT_DATA_LISTBASE;
+               event->customdata = &wm->drags;
+               event->customdatafree = 1;
                
                /* clear drop icon */
-               win->screen->do_draw_drag= 1;
+               win->screen->do_draw_drag = 1;
                
                /* restore cursor (disabled, see wm_dragdrop.c) */
                // WM_cursor_restore(win);
@@ -1907,7 +1909,7 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
        /* overlap fails otherwise */
        if (win->screen->do_draw_drag)
                if (win->drawmethod == USER_DRAW_OVERLAP)
-                       win->screen->do_draw= 1;
+                       win->screen->do_draw = 1;
        
 }
 
@@ -1915,19 +1917,19 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
 /* goes over entire hierarchy:  events -> window -> screen -> area -> region */
 void wm_event_do_handlers(bContext *C)
 {
-       wmWindowManager *wm= CTX_wm_manager(C);
+       wmWindowManager *wm = CTX_wm_manager(C);
        wmWindow *win;
 
        /* update key configuration before handling events */
        WM_keyconfig_update(wm);
 
-       for (win= wm->windows.first; win; win= win->next) {
+       for (win = wm->windows.first; win; win = win->next) {
                wmEvent *event;
                
-               if ( win->screen==NULL )
+               if (win->screen == NULL)
                        wm_event_free_all(win);
                else {
-                       Scenescene = win->screen->scene;
+                       Scene *scene = win->screen->scene;
                        
                        if (scene) {
                                int playing = sound_scene_playing(win->screen->scene);
@@ -1945,7 +1947,7 @@ void wm_event_do_handlers(bContext *C)
                                                float time = sound_sync_scene(scene);
                                                if (finite(time)) {
                                                        int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f;
-                                                       if (ncfra != scene->r.cfra)     {
+                                                       if (ncfra != scene->r.cfra) {
                                                                scene->r.cfra = ncfra;
                                                                ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
                                                                WM_event_add_notifier(C, NC_WINDOW, NULL);
@@ -1960,7 +1962,7 @@ void wm_event_do_handlers(bContext *C)
                        }
                }
                
-               while ( (event= win->queue.first) ) {
+               while ( (event = win->queue.first) ) {
                        int action = WM_HANDLER_CONTINUE;
 
                        if ((G.f & G_DEBUG) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE))
@@ -1983,7 +1985,7 @@ void wm_event_do_handlers(bContext *C)
                        action |= wm_handlers_do(C, event, &win->modalhandlers);
                        
                        /* fileread case */
-                       if (CTX_wm_window(C)==NULL)
+                       if (CTX_wm_window(C) == NULL)
                                return;
                        
                        /* check dragging, creates new event or frees, adds draw tag */
@@ -1995,25 +1997,25 @@ void wm_event_do_handlers(bContext *C)
                        if ((action & WM_HANDLER_BREAK) == 0) {
                                ScrArea *sa;
                                ARegion *ar;
-                               int doit= 0;
+                               int doit = 0;
        
                                /* Note: setting subwin active should be done here, after modal handlers have been done */
-                               if (event->type==MOUSEMOVE) {
+                               if (event->type == MOUSEMOVE) {
                                        /* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */
                                        ED_screen_set_subwinactive(C, event);   
                                        /* for regions having custom cursors */
                                        wm_paintcursor_test(C, event);
                                }
-                               else if (event->type==NDOF_MOTION) {
+                               else if (event->type == NDOF_MOTION) {
                                        win->addmousemove = TRUE;
                                }
 
-                               for (sa= win->screen->areabase.first; sa; sa= sa->next) {
+                               for (sa = win->screen->areabase.first; sa; sa = sa->next) {
                                        if (wm_event_inside_i(event, &sa->totrct)) {
                                                CTX_wm_area_set(C, sa);
 
                                                if ((action & WM_HANDLER_BREAK) == 0) {
-                                                       for (ar=sa->regionbase.first; ar; ar= ar->next) {
+                                                       for (ar = sa->regionbase.first; ar; ar = ar->next) {
                                                                if (wm_event_inside_i(event, &ar->winrct)) {
                                                                        CTX_wm_region_set(C, ar);
                                                                        
@@ -2029,7 +2031,7 @@ void wm_event_do_handlers(bContext *C)
                                                                        action |= wm_handlers_do(C, event, &ar->handlers);
 
                                                                        /* fileread case (python), [#29489] */
-                                                                       if (CTX_wm_window(C)==NULL)
+                                                                       if (CTX_wm_window(C) == NULL)
                                                                                return;
 
                                                                        doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y));
@@ -2062,15 +2064,15 @@ void wm_event_do_handlers(bContext *C)
                                        action |= wm_handlers_do(C, event, &win->handlers);
 
                                        /* fileread case */
-                                       if (CTX_wm_window(C)==NULL)
+                                       if (CTX_wm_window(C) == NULL)
                                                return;
                                }
 
                                /* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad? 
                                 * doing it on ghost queue gives errors when mousemoves go over area borders */
                                if (doit && win->screen && win->screen->subwinactive != win->screen->mainwin) {
-                                       win->eventstate->prevx= event->x;
-                                       win->eventstate->prevy= event->y;
+                                       win->eventstate->prevx = event->x;
+                                       win->eventstate->prevy = event->y;
                                        //printf("win->eventstate->prev = %d %d\n", event->x, event->y);
                                }
                                else {
@@ -2120,13 +2122,13 @@ void wm_event_do_handlers(bContext *C)
                
                /* only add mousemove when queue was read entirely */
                if (win->addmousemove && win->eventstate) {
-                       wmEvent tevent= *(win->eventstate);
+                       wmEvent tevent = *(win->eventstate);
                        //printf("adding MOUSEMOVE %d %d\n", tevent.x, tevent.y);
-                       tevent.type= MOUSEMOVE;
-                       tevent.prevx= tevent.x;
-                       tevent.prevy= tevent.y;
+                       tevent.type = MOUSEMOVE;
+                       tevent.prevx = tevent.x;
+                       tevent.prevy = tevent.y;
                        wm_event_add(win, &tevent);
-                       win->addmousemove= 0;
+                       win->addmousemove = 0;
                }
                
                CTX_wm_window_set(C, NULL);
@@ -2143,12 +2145,12 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval)
        /* add to all windows! */
        wmWindow *win;
        
-       for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
-               wmEvent event= *win->eventstate;
+       for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) {
+               wmEvent event = *win->eventstate;
                
-               event.type= EVT_FILESELECT;
-               event.val= eventval;
-               event.customdata= ophandle;             // only as void pointer type check
+               event.type = EVT_FILESELECT;
+               event.val = eventval;
+               event.customdata = ophandle;     // only as void pointer type check
 
                wm_event_add(win, &event);
        }
@@ -2165,12 +2167,12 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval)
 void WM_event_add_fileselect(bContext *C, wmOperator *op)
 {
        wmEventHandler *handler, *handlernext;
-       wmWindow *win= CTX_wm_window(C);
-       int full= 1;    // XXX preset?
+       wmWindow *win = CTX_wm_window(C);
+       int full = 1;    // XXX preset?
 
        /* only allow 1 file selector open per window */
-       for (handler= win->modalhandlers.first; handler; handler=handlernext) {
-               handlernext= handler->next;
+       for (handler = win->modalhandlers.first; handler; handler = handlernext) {
+               handlernext = handler->next;
                
                if (handler->type == WM_HANDLER_FILESELECT) {
                        if (handler->op)
@@ -2182,11 +2184,11 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
        
        handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler");
        
-       handler->type= WM_HANDLER_FILESELECT;
-       handler->op= op;
-       handler->op_area= CTX_wm_area(C);
-       handler->op_region= CTX_wm_region(C);
-       handler->filescreen= CTX_wm_screen(C);
+       handler->type = WM_HANDLER_FILESELECT;
+       handler->op = op;
+       handler->op_area = CTX_wm_area(C);
+       handler->op_region = CTX_wm_region(C);
+       handler->filescreen = CTX_wm_screen(C);
        
        BLI_addhead(&win->modalhandlers, handler);
        
@@ -2196,34 +2198,34 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
                op->type->check(C, op); /* ignore return value */
        }
 
-       WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN);
+       WM_event_fileselect_event(C, op, full ? EVT_FILESELECT_FULL_OPEN : EVT_FILESELECT_OPEN);
 }
 
 #if 0
 /* lets not expose struct outside wm? */
 static void WM_event_set_handler_flag(wmEventHandler *handler, int flag)
 {
-       handler->flag= flag;
+       handler->flag = flag;
 }
 #endif
 
 wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
 {
-       wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event modal handler");
-       wmWindow *win= CTX_wm_window(C);
+       wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event modal handler");
+       wmWindow *win = CTX_wm_window(C);
        
        /* operator was part of macro */
        if (op->opm) {
                /* give the mother macro to the handler */
-               handler->op= op->opm;
+               handler->op = op->opm;
                /* mother macro opm becomes the macro element */
-               handler->op->opm= op;
+               handler->op->opm = op;
        }
        else
-               handler->op= op;
+               handler->op = op;
        
-       handler->op_area= CTX_wm_area(C);               /* means frozen screen context for modal handlers! */
-       handler->op_region= CTX_wm_region(C);
+       handler->op_area = CTX_wm_area(C);       /* means frozen screen context for modal handlers! */
+       handler->op_region = CTX_wm_region(C);
        
        BLI_addhead(&win->modalhandlers, handler);
 
@@ -2240,13 +2242,13 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap
        }
 
        /* only allow same keymap once */
-       for (handler= handlers->first; handler; handler= handler->next)
-               if (handler->keymap==keymap)
+       for (handler = handlers->first; handler; handler = handler->next)
+               if (handler->keymap == keymap)
                        return handler;
        
-       handler= MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
+       handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
        BLI_addtail(handlers, handler);
-       handler->keymap= keymap;
+       handler->keymap = keymap;
 
        return handler;
 }
@@ -2258,20 +2260,20 @@ wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, wmKeyMa
        
        WM_event_remove_keymap_handler(handlers, keymap);
        
-       handler= MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
+       handler = MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
        BLI_addhead(handlers, handler);
-       handler->keymap= keymap;
+       handler->keymap = keymap;
        
        return handler;
 }
 
 wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, wmKeyMap *keymap, rcti *bblocal, rcti *bbwin)
 {
-       wmEventHandler *handler= WM_event_add_keymap_handler(handlers, keymap);
+       wmEventHandler *handler = WM_event_add_keymap_handler(handlers, keymap);
        
        if (handler) {
-               handler->bblocal= bblocal;
-               handler->bbwin= bbwin;
+               handler->bblocal = bblocal;
+               handler->bbwin = bbwin;
        }
        return handler;
 }
@@ -2280,8 +2282,8 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
 {
        wmEventHandler *handler;
        
-       for (handler= handlers->first; handler; handler= handler->next) {
-               if (handler->keymap==keymap) {
+       for (handler = handlers->first; handler; handler = handler->next) {
+               if (handler->keymap == keymap) {
                        BLI_remlink(handlers, handler);
                        wm_event_free_handler(handler);
                        break;
@@ -2292,13 +2294,13 @@ void WM_event_remove_keymap_handler(ListBase *handlers, wmKeyMap *keymap)
 wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers,
                                         wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata)
 {
-       wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event ui handler");
-       handler->ui_handle= func;
-       handler->ui_remove= remove;
-       handler->ui_userdata= userdata;
-       handler->ui_area= (C)? CTX_wm_area(C): NULL;
-       handler->ui_region= (C)? CTX_wm_region(C): NULL;
-       handler->ui_menu= (C)? CTX_wm_menu(C): NULL;
+       wmEventHandler *handler = MEM_callocN(sizeof(wmEventHandler), "event ui handler");
+       handler->ui_handle = func;
+       handler->ui_remove = remove;
+       handler->ui_userdata = userdata;
+       handler->ui_area = (C) ? CTX_wm_area(C) : NULL;
+       handler->ui_region = (C) ? CTX_wm_region(C) : NULL;
+       handler->ui_menu = (C) ? CTX_wm_menu(C) : NULL;
        
        BLI_addhead(handlers, handler);
        
@@ -2311,7 +2313,7 @@ void WM_event_remove_ui_handler(ListBase *handlers,
 {
        wmEventHandler *handler;
        
-       for (handler= handlers->first; handler; handler= handler->next) {
+       for (handler = handlers->first; handler; handler = handler->next) {
                if (handler->ui_handle == func && handler->ui_remove == remove && handler->ui_userdata == userdata) {
                        /* handlers will be freed in wm_handlers_do() */
                        if (postpone) {
@@ -2331,14 +2333,14 @@ wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropb
        wmEventHandler *handler;
 
        /* only allow same dropbox once */
-       for (handler= handlers->first; handler; handler= handler->next)
-               if (handler->dropboxes==dropboxes)
+       for (handler = handlers->first; handler; handler = handler->next)
+               if (handler->dropboxes == dropboxes)
                        return handler;
        
-       handler= MEM_callocN(sizeof(wmEventHandler), "dropbox handler");
+       handler = MEM_callocN(sizeof(wmEventHandler), "dropbox handler");
        
        /* dropbox stored static, no free or copy */
-       handler->dropboxes= dropboxes;
+       handler->dropboxes = dropboxes;
        BLI_addhead(handlers, handler);
        
        return handler;
@@ -2349,7 +2351,7 @@ void WM_event_remove_area_handler(ListBase *handlers, void *area)
 {
        wmEventHandler *handler, *nexthandler;
 
-       for (handler = handlers->first; handler; handler= nexthandler) {
+       for (handler = handlers->first; handler; handler = nexthandler) {
                nexthandler = handler->next;
                if (handler->type != WM_HANDLER_FILESELECT) {
                        if (handler->ui_area == area) {
@@ -2370,9 +2372,9 @@ static void WM_event_remove_handler(ListBase *handlers, wmEventHandler *handler)
 
 void WM_event_add_mousemove(bContext *C)
 {
-       wmWindow *window= CTX_wm_window(C);
+       wmWindow *window = CTX_wm_window(C);
        
-       window->addmousemove= 1;
+       window->addmousemove = 1;
 }
 
 /* for modal callbacks, check configuration for how to interpret exit with tweaks  */
@@ -2415,85 +2417,85 @@ int WM_modal_tweak_exit(wmEvent *evt, int tweak_event)
 
 static int convert_key(GHOST_TKey key) 
 {
-       if (key>=GHOST_kKeyA && key<=GHOST_kKeyZ) {
+       if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) {
                return (AKEY + ((int) key - GHOST_kKeyA));
        }
-       else if (key>=GHOST_kKey0 && key<=GHOST_kKey9) {
+       else if (key >= GHOST_kKey0 && key <= GHOST_kKey9) {
                return (ZEROKEY + ((int) key - GHOST_kKey0));
        }
-       else if (key>=GHOST_kKeyNumpad0 && key<=GHOST_kKeyNumpad9) {
+       else if (key >= GHOST_kKeyNumpad0 && key <= GHOST_kKeyNumpad9) {
                return (PAD0 + ((int) key - GHOST_kKeyNumpad0));
        }
-       else if (key>=GHOST_kKeyF1 && key<=GHOST_kKeyF19) {
+       else if (key >= GHOST_kKeyF1 && key <= GHOST_kKeyF19) {
                return (F1KEY + ((int) key - GHOST_kKeyF1));
        }
        else {
                switch (key) {
-                       case GHOST_kKeyBackSpace:               return BACKSPACEKEY;
-                       case GHOST_kKeyTab:                             return TABKEY;
-                       case GHOST_kKeyLinefeed:                return LINEFEEDKEY;
-                       case GHOST_kKeyClear:                   return 0;
-                       case GHOST_kKeyEnter:                   return RETKEY;
-                               
-                       case GHOST_kKeyEsc:                             return ESCKEY;
-                       case GHOST_kKeySpace:                   return SPACEKEY;
-                       case GHOST_kKeyQuote:                   return QUOTEKEY;
-                       case GHOST_kKeyComma:                   return COMMAKEY;
-                       case GHOST_kKeyMinus:                   return MINUSKEY;
-                       case GHOST_kKeyPeriod:                  return PERIODKEY;
-                       case GHOST_kKeySlash:                   return SLASHKEY;
-                               
-                       case GHOST_kKeySemicolon:               return SEMICOLONKEY;
-                       case GHOST_kKeyEqual:                   return EQUALKEY;
-                               
-                       case GHOST_kKeyLeftBracket:             return LEFTBRACKETKEY;
-                       case GHOST_kKeyRightBracket:    return RIGHTBRACKETKEY;
-                       case GHOST_kKeyBackslash:               return BACKSLASHKEY;
-                       case GHOST_kKeyAccentGrave:             return ACCENTGRAVEKEY;
-                               
-                       case GHOST_kKeyLeftShift:               return LEFTSHIFTKEY;
-                       case GHOST_kKeyRightShift:              return RIGHTSHIFTKEY;
-                       case GHOST_kKeyLeftControl:             return LEFTCTRLKEY;
-                       case GHOST_kKeyRightControl:    return RIGHTCTRLKEY;
-                       case GHOST_kKeyOS:                              return OSKEY;
-                       case GHOST_kKeyLeftAlt:                 return LEFTALTKEY;
-                       case GHOST_kKeyRightAlt:                return RIGHTALTKEY;
-                               
-                       case GHOST_kKeyCapsLock:                return CAPSLOCKKEY;
-                       case GHOST_kKeyNumLock:                 return 0;
-                       case GHOST_kKeyScrollLock:              return 0;
-                               
-                       case GHOST_kKeyLeftArrow:               return LEFTARROWKEY;
-                       case GHOST_kKeyRightArrow:              return RIGHTARROWKEY;
-                       case GHOST_kKeyUpArrow:                 return UPARROWKEY;
-                       case GHOST_kKeyDownArrow:               return DOWNARROWKEY;
-                               
-                       case GHOST_kKeyPrintScreen:             return 0;
-                       case GHOST_kKeyPause:                   return PAUSEKEY;
-                               
-                       case GHOST_kKeyInsert:                  return INSERTKEY;
-                       case GHOST_kKeyDelete:                  return DELKEY;
-                       case GHOST_kKeyHome:                    return HOMEKEY;
-                       case GHOST_kKeyEnd:                             return ENDKEY;
-                       case GHOST_kKeyUpPage:                  return PAGEUPKEY;
-                       case GHOST_kKeyDownPage:                return PAGEDOWNKEY;
-                               
-                       case GHOST_kKeyNumpadPeriod:    return PADPERIOD;
-                       case GHOST_kKeyNumpadEnter:             return PADENTER;
-                       case GHOST_kKeyNumpadPlus:              return PADPLUSKEY;
-                       case GHOST_kKeyNumpadMinus:             return PADMINUS;
-                       case GHOST_kKeyNumpadAsterisk:  return PADASTERKEY;
-                       case GHOST_kKeyNumpadSlash:             return PADSLASHKEY;
-                               
-                       case GHOST_kKeyGrLess:              return GRLESSKEY; 
-                       
-                       case GHOST_kKeyMediaPlay:               return MEDIAPLAY;
-                       case GHOST_kKeyMediaStop:               return MEDIASTOP;
-                       case GHOST_kKeyMediaFirst:              return MEDIAFIRST;
-                       case GHOST_kKeyMediaLast:               return MEDIALAST;
+                       case GHOST_kKeyBackSpace:       return BACKSPACEKEY;
+                       case GHOST_kKeyTab:             return TABKEY;
+                       case GHOST_kKeyLinefeed:        return LINEFEEDKEY;
+                       case GHOST_kKeyClear:           return 0;
+                       case GHOST_kKeyEnter:           return RETKEY;
+
+                       case GHOST_kKeyEsc:             return ESCKEY;
+                       case GHOST_kKeySpace:           return SPACEKEY;
+                       case GHOST_kKeyQuote:           return QUOTEKEY;
+                       case GHOST_kKeyComma:           return COMMAKEY;
+                       case GHOST_kKeyMinus:           return MINUSKEY;
+                       case GHOST_kKeyPeriod:          return PERIODKEY;
+                       case GHOST_kKeySlash:           return SLASHKEY;
+
+                       case GHOST_kKeySemicolon:       return SEMICOLONKEY;
+                       case GHOST_kKeyEqual:           return EQUALKEY;
+
+                       case GHOST_kKeyLeftBracket:     return LEFTBRACKETKEY;
+                       case GHOST_kKeyRightBracket:    return RIGHTBRACKETKEY;
+                       case GHOST_kKeyBackslash:       return BACKSLASHKEY;
+                       case GHOST_kKeyAccentGrave:     return ACCENTGRAVEKEY;
+
+                       case GHOST_kKeyLeftShift:       return LEFTSHIFTKEY;
+                       case GHOST_kKeyRightShift:      return RIGHTSHIFTKEY;
+                       case GHOST_kKeyLeftControl:     return LEFTCTRLKEY;
+                       case GHOST_kKeyRightControl:    return RIGHTCTRLKEY;
+                       case GHOST_kKeyOS:              return OSKEY;
+                       case GHOST_kKeyLeftAlt:         return LEFTALTKEY;
+                       case GHOST_kKeyRightAlt:        return RIGHTALTKEY;
+
+                       case GHOST_kKeyCapsLock:        return CAPSLOCKKEY;
+                       case GHOST_kKeyNumLock:         return 0;
+                       case GHOST_kKeyScrollLock:      return 0;
+
+                       case GHOST_kKeyLeftArrow:       return LEFTARROWKEY;
+                       case GHOST_kKeyRightArrow:      return RIGHTARROWKEY;
+                       case GHOST_kKeyUpArrow:         return UPARROWKEY;
+                       case GHOST_kKeyDownArrow:       return DOWNARROWKEY;
+
+                       case GHOST_kKeyPrintScreen:     return 0;
+                       case GHOST_kKeyPause:           return PAUSEKEY;
+
+                       case GHOST_kKeyInsert:          return INSERTKEY;
+                       case GHOST_kKeyDelete:          return DELKEY;
+                       case GHOST_kKeyHome:            return HOMEKEY;
+                       case GHOST_kKeyEnd:             return ENDKEY;
+                       case GHOST_kKeyUpPage:          return PAGEUPKEY;
+                       case GHOST_kKeyDownPage:        return PAGEDOWNKEY;
+
+                       case GHOST_kKeyNumpadPeriod:    return PADPERIOD;
+                       case GHOST_kKeyNumpadEnter:     return PADENTER;
+                       case GHOST_kKeyNumpadPlus:      return PADPLUSKEY;
+                       case GHOST_kKeyNumpadMinus:     return PADMINUS;
+                       case GHOST_kKeyNumpadAsterisk:  return PADASTERKEY;
+                       case GHOST_kKeyNumpadSlash:     return PADSLASHKEY;
+
+                       case GHOST_kKeyGrLess:          return GRLESSKEY;
+
+                       case GHOST_kKeyMediaPlay:       return MEDIAPLAY;
+                       case GHOST_kKeyMediaStop:       return MEDIASTOP;
+                       case GHOST_kKeyMediaFirst:      return MEDIAFIRST;
+                       case GHOST_kKeyMediaLast:       return MEDIALAST;
                        
                        default:
-                               return UNKNOWNKEY;      /* GHOST_kKeyUnknown */
+                               return UNKNOWNKEY;  /* GHOST_kKeyUnknown */
                }
        }
 }
@@ -2501,27 +2503,27 @@ static int convert_key(GHOST_TKey key)
 /* adds customdata to event */
 static void update_tablet_data(wmWindow *win, wmEvent *event)
 {
-       const GHOST_TabletData *td= GHOST_GetTabletData(win->ghostwin);
+       const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin);
        
        /* if there's tablet data from an active tablet device then add it */
        if ((td != NULL) && td->Active != GHOST_kTabletModeNone) {
-               struct wmTabletData *wmtab= MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
+               struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet");
                
                wmtab->Active = (int)td->Active;
                wmtab->Pressure = td->Pressure;
                wmtab->Xtilt = td->Xtilt;
                wmtab->Ytilt = td->Ytilt;
                
-               event->custom= EVT_DATA_TABLET;
-               event->customdata= wmtab;
-               event->customdatafree= 1;
+               event->custom = EVT_DATA_TABLET;
+               event->customdata = wmtab;
+               event->customdatafree = 1;
        } 
 }
 
 /* adds customdata to event */
-static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* ghost)
+static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost)
 {
-       wmNDOFMotionDatadata = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF");
+       wmNDOFMotionData *data = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF");
 
        const float s = U.ndof_sensitivity;
 
@@ -2545,11 +2547,11 @@ static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* g
                data->ry = s * ghost->rz;
                data->rz = s * ghost->ry;
 #endif
-               }
+       }
        else {
                data->ty = s * ghost->ty;
                data->tz = s * ghost->tz;
-               }
+       }
 
        data->dt = ghost->dt;
 
@@ -2563,19 +2565,19 @@ static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* g
 /* imperfect but probably usable... draw/enable drags to other windows */
 static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *evt)
 {
-       int mx= evt->x, my= evt->y;
+       int mx = evt->x, my = evt->y;
        
-       if (wm->windows.first== wm->windows.last)
+       if (wm->windows.first == wm->windows.last)
                return NULL;
        
        /* top window bar... */
-       if (mx<0 || my<0 || mx>win->sizex || my>win->sizey+30) {        
+       if (mx < 0 || my < 0 || mx > win->sizex || my > win->sizey + 30) {
                wmWindow *owin;
                wmEventHandler *handler;
                
                /* let's skip windows having modal handlers now */
                /* potential XXX ugly... I wouldn't have added a modalhandlers list (introduced in rev 23331, ton) */
-               for (handler= win->modalhandlers.first; handler; handler= handler->next)
+               for (handler = win->modalhandlers.first; handler; handler = handler->next)
                        if (handler->ui_handle || handler->op)
                                return NULL;
                
@@ -2584,13 +2586,13 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
                my += (int)win->posy;
                
                /* check other windows to see if it has mouse inside */
-               for (owin= wm->windows.first; owin; owin= owin->next) {
+               for (owin = wm->windows.first; owin; owin = owin->next) {
                        
-                       if (owin!=win) {
-                               if (mx-owin->posx >= 0 && my-owin->posy >= 0 &&
-                                  mx-owin->posx <= owin->sizex && my-owin->posy <= owin->sizey) {
-                                       evt->x= mx - (int)owin->posx;
-                                       evt->y= my - (int)owin->posy;
+                       if (owin != win) {
+                               if (mx - owin->posx >= 0 && my - owin->posy >= 0 &&
+                                   mx - owin->posx <= owin->sizex && my - owin->posy <= owin->sizey) {
+                                       evt->x = mx - (int)owin->posx;
+                                       evt->y = my - (int)owin->posy;
                                        
                                        return owin;
                                }
@@ -2605,27 +2607,27 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
 void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int UNUSED(time), void *customdata)
 {
        wmWindow *owin;
-       wmEvent event, *evt= win->eventstate;
+       wmEvent event, *evt = win->eventstate;
 
        /* initialize and copy state (only mouse x y and modifiers) */
-       event= *evt;
+       event = *evt;
        
        switch (type) {
                /* mouse move */
                case GHOST_kEventCursorMove: {
                        if (win->active) {
-                               GHOST_TEventCursorData *cd= customdata;
-                               wmEvent *lastevent= win->queue.last;
+                               GHOST_TEventCursorData *cd = customdata;
+                               wmEvent *lastevent = win->queue.last;
                                int cx, cy;
                                
                                GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
-                               evt->x= cx;
-                               evt->y= (win->sizey-1) - cy;
+                               evt->x = cx;
+                               evt->y = (win->sizey - 1) - cy;
                                
-                               event.x= evt->x;
-                               event.y= evt->y;
+                               event.x = evt->x;
+                               event.y = evt->y;
 
-                               event.type= MOUSEMOVE;
+                               event.type = MOUSEMOVE;
 
                                /* some painting operators want accurate mouse events, they can
                                 * handle in between mouse move moves, others can happily ignore
@@ -2640,13 +2642,13 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                                
                                /* also add to other window if event is there, this makes overdraws disappear nicely */
                                /* it remaps mousecoord to other window in event */
-                               owin= wm_event_cursor_other_windows(wm, win, &event);
+                               owin = wm_event_cursor_other_windows(wm, win, &event);
                                if (owin) {
-                                       wmEvent oevent= *(owin->eventstate);
+                                       wmEvent oevent = *(owin->eventstate);
                                        
-                                       oevent.x=owin->eventstate->x= event.x;
-                                       oevent.y=owin->eventstate->y= event.y;
-                                       oevent.type= MOUSEMOVE;
+                                       oevent.x = owin->eventstate->x = event.x;
+                                       oevent.y = owin->eventstate->y = event.y;
+                                       oevent.type = MOUSEMOVE;
                                        
                                        update_tablet_data(owin, &oevent);
                                        wm_event_add(owin, &oevent);
@@ -2656,7 +2658,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                        break;
                }
                case GHOST_kEventTrackpad: {
-                       GHOST_TEventTrackpadData * pd = customdata;
+                       GHOST_TEventTrackpadData *pd = customdata;
                        switch (pd->subtype) {
                                case GHOST_kTrackpadEventMagnify:
                                        event.type = MOUSEZOOM;
@@ -2666,20 +2668,20 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                                        break;
                                case GHOST_kTrackpadEventScroll:
                                default:
-                                       event.type= MOUSEPAN;
+                                       event.type = MOUSEPAN;
                                        break;
                        }
 
                        {
                                int cx, cy;
                                GHOST_ScreenToClient(win->ghostwin, pd->x, pd->y, &cx, &cy);
-                               event.x= evt->x= cx;
-                               event.y= evt->y= (win->sizey-1) - cy;
+                               event.x = evt->x = cx;
+                               event.y = evt->y = (win->sizey - 1) - cy;
                        }
 
                        // Use prevx/prevy so we can calculate the delta later
-                       event.prevx= event.x - pd->deltaX;
-                       event.prevy= event.y - (-pd->deltaY);
+                       event.prevx = event.x - pd->deltaX;
+                       event.prevy = event.y - (-pd->deltaY);
                        
                        update_tablet_data(win, &event);
                        wm_event_add(win, &event);
@@ -2688,41 +2690,41 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                /* mouse button */
                case GHOST_kEventButtonDown:
                case GHOST_kEventButtonUp: {
-                       GHOST_TEventButtonData *bd= customdata;
+                       GHOST_TEventButtonData *bd = customdata;
 
                        /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */
-                       event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE;
+                       event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
                        
                        if (bd->button == GHOST_kButtonMaskLeft)
-                               event.type= LEFTMOUSE;
+                               event.type = LEFTMOUSE;
                        else if (bd->button == GHOST_kButtonMaskRight)
-                               event.type= RIGHTMOUSE;
+                               event.type = RIGHTMOUSE;
                        else if (bd->button == GHOST_kButtonMaskButton4)
-                               event.type= BUTTON4MOUSE;
+                               event.type = BUTTON4MOUSE;
                        else if (bd->button == GHOST_kButtonMaskButton5)
-                               event.type= BUTTON5MOUSE;
+                               event.type = BUTTON5MOUSE;
                        else
-                               event.type= MIDDLEMOUSE;
+                               event.type = MIDDLEMOUSE;
                        
-                       if (win->active==0) {
+                       if (win->active == 0) {
                                int cx, cy;
                                
                                /* entering window, update mouse pos. (ghost sends win-activate *after* the mouseclick in window!) */
                                wm_get_cursor_position(win, &cx, &cy);
 
-                               event.x= evt->x= cx;
-                               event.y= evt->y= cy;
+                               event.x = evt->x = cx;
+                               event.y = evt->y = cy;
                        }
                        
                        /* add to other window if event is there (not to both!) */
-                       owin= wm_event_cursor_other_windows(wm, win, &event);
+                       owin = wm_event_cursor_other_windows(wm, win, &event);
                        if (owin) {
-                               wmEvent oevent= *(owin->eventstate);
+                               wmEvent oevent = *(owin->eventstate);
                                
-                               oevent.x= event.x;
-                               oevent.y= event.y;
-                               oevent.type= event.type;
-                               oevent.val= event.val;
+                               oevent.x = event.x;
+                               oevent.y = event.y;
+                               oevent.type = event.type;
+                               oevent.val = event.val;
                                
                                update_tablet_data(owin, &oevent);
                                wm_event_add(owin, &oevent);
@@ -2737,66 +2739,66 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                /* keyboard */
                case GHOST_kEventKeyDown:
                case GHOST_kEventKeyUp: {
-                       GHOST_TEventKeyData *kd= customdata;
-                       event.type= convert_key(kd->key);
-                       event.ascii= kd->ascii;
-                       memcpy(event.utf8_buf, kd->utf8_buf,sizeof(event.utf8_buf));/* might be not null terminated*/
-                       event.val= (type==GHOST_kEventKeyDown)?KM_PRESS:KM_RELEASE;
+                       GHOST_TEventKeyData *kd = customdata;
+                       event.type = convert_key(kd->key);
+                       event.ascii = kd->ascii;
+                       memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/
+                       event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE;
                        
                        /* exclude arrow keys, esc, etc from text input */
-                       if (type==GHOST_kEventKeyUp) {
-                               event.ascii= '\0';
+                       if (type == GHOST_kEventKeyUp) {
+                               event.ascii = '\0';
 
                                /* ghost should do this already for key up */
                                if (event.utf8_buf[0]) {
                                        printf("%s: ghost on your platform is misbehaving, utf8 events on key up!\n", __func__);
                                }
-                               event.utf8_buf[0]= '\0';
+                               event.utf8_buf[0] = '\0';
                        }
                        else {
-                               if (event.ascii<32 && event.ascii > 0)
-                                       event.ascii= '\0';
-                               if (event.utf8_buf[0]<32 && event.utf8_buf[0] > 0)
-                                       event.utf8_buf[0]= '\0';
+                               if (event.ascii < 32 && event.ascii > 0)
+                                       event.ascii = '\0';
+                               if (event.utf8_buf[0] < 32 && event.utf8_buf[0] > 0)
+                                       event.utf8_buf[0] = '\0';
                        }
 
                        if (event.utf8_buf[0]) {
                                if (BLI_str_utf8_size(event.utf8_buf) == -1) {
                                        printf("%s: ghost detected an invalid unicode character '%d'!\n",
                                               __func__, (int)(unsigned char)event.utf8_buf[0]);
-                                       event.utf8_buf[0]= '\0';
+                                       event.utf8_buf[0] = '\0';
                                }
                        }
 
                        /* modifiers */
                        /* assigning both first and second is strange - campbell */
-                       switch(event.type) {
-                       case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
-                               event.shift = evt->shift = (event.val == KM_PRESS) ?
-                                               ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-                                               FALSE;
-                               break;
-                       case LEFTCTRLKEY: case RIGHTCTRLKEY:
-                               event.ctrl = evt->ctrl = (event.val == KM_PRESS) ?
-                                               ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-                                               FALSE;
-                               break;
-                       case LEFTALTKEY: case RIGHTALTKEY:
-                               event.alt = evt->alt = (event.val == KM_PRESS) ?
-                                               ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-                                               FALSE;
-                               break;
-                       case OSKEY:
-                               event.oskey = evt->oskey = (event.val == KM_PRESS) ?
-                                               ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-                                               FALSE;
-                               break;
-                       default:
-                               if (event.val == KM_PRESS && event.keymodifier==0)
-                                       evt->keymodifier= event.type; /* only set in eventstate, for next event */
-                               else if (event.val==KM_RELEASE && event.keymodifier==event.type)
-                                       event.keymodifier= evt->keymodifier= 0;
-                               break;
+                       switch (event.type) {
+                               case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
+                                       event.shift = evt->shift = (event.val == KM_PRESS) ?
+                                                                  ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+                                                                  FALSE;
+                                       break;
+                               case LEFTCTRLKEY: case RIGHTCTRLKEY:
+                                       event.ctrl = evt->ctrl = (event.val == KM_PRESS) ?
+                                                                ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+                                                                FALSE;
+                                       break;
+                               case LEFTALTKEY: case RIGHTALTKEY:
+                                       event.alt = evt->alt = (event.val == KM_PRESS) ?
+                                                              ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+                                                              FALSE;
+                                       break;
+                               case OSKEY:
+                                       event.oskey = evt->oskey = (event.val == KM_PRESS) ?
+                                                                  ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
+                                                                  FALSE;
+                                       break;
+                               default:
+                                       if (event.val == KM_PRESS && event.keymodifier == 0)
+                                               evt->keymodifier = event.type;  /* only set in eventstate, for next event */
+                                       else if (event.val == KM_RELEASE && event.keymodifier == event.type)
+                                               event.keymodifier = evt->keymodifier = 0;
+                                       break;
                        }
 
                        /* this case happens on some systems that on holding a key pressed,
@@ -2804,39 +2806,39 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                         * modifier in win->eventstate, but for the press event of the same
                         * key we don't want the key modifier */
                        if (event.keymodifier == event.type)
-                               event.keymodifier= 0;
+                               event.keymodifier = 0;
                        /* this case happened with an external numpad, it's not really clear
                         * why, but it's also impossible to map a key modifier to an unknwon
                         * key, so it shouldn't harm */
                        if (event.keymodifier == UNKNOWNKEY)
-                               event.keymodifier= 0;
+                               event.keymodifier = 0;
                        
                        /* if test_break set, it catches this. XXX Keep global for now? */
-                       if (event.type==ESCKEY)
-                               G.afbreek= 1;
+                       if (event.type == ESCKEY)
+                               G.afbreek = 1;
                        
                        wm_event_add(win, &event);
                        
                        break;
                }
                        
-               case GHOST_kEventWheel: {
-                       GHOST_TEventWheelDatawheelData = customdata;
+               case GHOST_kEventWheel: {
+                       GHOST_TEventWheelData *wheelData = customdata;
                        
                        if (wheelData->z > 0)
-                               event.type= WHEELUPMOUSE;
+                               event.type = WHEELUPMOUSE;
                        else
-                               event.type= WHEELDOWNMOUSE;
+                               event.type = WHEELDOWNMOUSE;
                        
-                       event.val= KM_PRESS;
+                       event.val = KM_PRESS;
                        wm_event_add(win, &event);
                        
                        break;
                }
                case GHOST_kEventTimer: {
-                       event.type= TIMER;
-                       event.custom= EVT_DATA_TIMER;
-                       event.customdata= customdata;
+                       event.type = TIMER;
+                       event.custom = EVT_DATA_TIMER;
+                       event.customdata = customdata;
                        wm_event_add(win, &event);
 
                        break;
@@ -2853,7 +2855,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                }
 
                case GHOST_kEventNDOFButton: {
-                       GHOST_TEventNDOFButtonDatae = customdata;
+                       GHOST_TEventNDOFButtonData *e = customdata;
 
                        event.type = NDOF_BUTTON_NONE + e->button;
 
@@ -2864,7 +2866,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                                case GHOST_kRelease:
                                        event.val = KM_RELEASE;
                                        break;
-                               }
+                       }
 
                        event.custom = 0;
                        event.customdata = NULL;
@@ -2879,7 +2881,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                        break;
 
                case GHOST_kEventWindowDeactivate: {
-                       event.type= WINDEACTIVATE;
+                       event.type = WINDEACTIVATE;
                        wm_event_add(win, &event);
 
                        break;
index db75c78..763f1e3 100644 (file)
@@ -28,9 +28,9 @@
  */
 
 
-       /* placed up here because of crappy
       * winsock stuff.
       */
+/* placed up here because of crappy
+ * winsock stuff.
+ */
 #include <stddef.h>
 #include <string.h>
 #include <errno.h>
@@ -131,20 +131,20 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
        wmWindowManager *wm;
        wmWindow *win, *active_win;
        
-       *wmlist= G.main->wm;
-       G.main->wm.first= G.main->wm.last= NULL;
+       *wmlist = G.main->wm;
+       G.main->wm.first = G.main->wm.last = NULL;
        
        active_win = CTX_wm_window(C);
 
        /* first wrap up running stuff */
        /* code copied from wm_init_exit.c */
-       for (wm= wmlist->first; wm; wm= wm->id.next) {
+       for (wm = wmlist->first; wm; wm = wm->id.next) {
                
                WM_jobs_stop_all(wm);
                
-               for (win= wm->windows.first; win; win= win->next) {
+               for (win = wm->windows.first; win; win = win->next) {
                
-                       CTX_wm_window_set(C, win);      /* needed by operator close callbacks */
+                       CTX_wm_window_set(C, win);  /* needed by operator close callbacks */
                        WM_event_remove_handlers(C, &win->handlers);
                        WM_event_remove_handlers(C, &win->modalhandlers);
                        ED_screen_exit(C, win, win->screen);
@@ -158,13 +158,13 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
 
        /* just had return; here from r12991, this code could just get removed?*/
 #if 0
-       if (wm==NULL) return;
+       if (wm == NULL) return;
        if (G.fileflags & G_FILE_NO_UI) return;
        
        /* we take apart the used screens from non-active window */
-       for (win= wm->windows.first; win; win= win->next) {
+       for (win = wm->windows.first; win; win = win->next) {
                BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME);
-               if (win!=wm->winactive) {
+               if (win != wm->winactive) {
                        BLI_remlink(&G.main->screen, win->screen);
                        //BLI_addtail(screenbase, win->screen);
                }
@@ -185,8 +185,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
        wmWindow *oldwin, *win;
        
        /* cases 1 and 2 */
-       if (oldwmlist->first==NULL) {
-               if (G.main->wm.first); /* nothing todo */
+       if (oldwmlist->first == NULL) {
+               if (G.main->wm.first) ;  /* nothing todo */
                else
                        wm_add_default(C);
        }
@@ -194,29 +194,29 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
                /* cases 3 and 4 */
                
                /* we've read file without wm..., keep current one entirely alive */
-               if (G.main->wm.first==NULL) {
-                       bScreen *screen= NULL;
+               if (G.main->wm.first == NULL) {
+                       bScreen *screen = NULL;
 
                        /* when loading without UI, no matching needed */
-                       if (!(G.fileflags & G_FILE_NO_UI) && (screen= CTX_wm_screen(C))) {
+                       if (!(G.fileflags & G_FILE_NO_UI) && (screen = CTX_wm_screen(C))) {
 
                                /* match oldwm to new dbase, only old files */
-                               for (wm= oldwmlist->first; wm; wm= wm->id.next) {
+                               for (wm = oldwmlist->first; wm; wm = wm->id.next) {
                                        
-                                       for (win= wm->windows.first; win; win= win->next) {
+                                       for (win = wm->windows.first; win; win = win->next) {
                                                /* all windows get active screen from file */
-                                               if (screen->winid==0)
-                                                       win->screen= screen;
+                                               if (screen->winid == 0)
+                                                       win->screen = screen;
                                                else 
-                                                       win->screen= ED_screen_duplicate(win, screen);
+                                                       win->screen = ED_screen_duplicate(win, screen);
                                                
-                                               BLI_strncpy(win->screenname, win->screen->id.name+2, sizeof(win->screenname));
-                                               win->screen->winid= win->winid;
+                                               BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname));
+                                               win->screen->winid = win->winid;
                                        }
                                }
                        }
                        
-                       G.main->wm= *oldwmlist;
+                       G.main->wm = *oldwmlist;
                        
                        /* screens were read from file! */
                        ED_screens_initialize(G.main->wm.first);
@@ -224,47 +224,47 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
                else {
                        /* what if old was 3, and loaded 1? */
                        /* this code could move to setup_appdata */
-                       oldwm= oldwmlist->first;
-                       wm= G.main->wm.first;
+                       oldwm = oldwmlist->first;
+                       wm = G.main->wm.first;
 
                        /* preserve key configurations in new wm, to preserve their keymaps */
-                       wm->keyconfigs= oldwm->keyconfigs;
-                       wm->addonconf= oldwm->addonconf;
-                       wm->defaultconf= oldwm->defaultconf;
-                       wm->userconf= oldwm->userconf;
+                       wm->keyconfigs = oldwm->keyconfigs;
+                       wm->addonconf = oldwm->addonconf;
+                       wm->defaultconf = oldwm->defaultconf;
+                       wm->userconf = oldwm->userconf;
 
-                       oldwm->keyconfigs.first= oldwm->keyconfigs.last= NULL;
-                       oldwm->addonconf= NULL;
-                       oldwm->defaultconf= NULL;
-                       oldwm->userconf= NULL;
+                       oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL;
+                       oldwm->addonconf = NULL;
+                       oldwm->defaultconf = NULL;
+                       oldwm->userconf = NULL;
 
                        /* ensure making new keymaps and set space types */
-                       wm->initialized= 0;
-                       wm->winactive= NULL;
+                       wm->initialized = 0;
+                       wm->winactive = NULL;
                        
                        /* only first wm in list has ghostwins */