diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-15 19:54:47 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-15 19:54:47 +0300 |
commit | a16df53619a2ab3b41c0cbcf6f9e01a9bf370c9c (patch) | |
tree | a96b757fd2a791c242b6ace94b22e465bac9b1d2 /source/blender/windowmanager | |
parent | c13bb258b1149d8bbfb97b896a58cd748e7cd861 (diff) |
2.5
Mouse cursors now work again
- centralized screen-level cursor changes, no more operator
running for it.
- spacetypes have callback to check/set individual cursor
types. Use notifier SCREEN_CHANGED to make sure it works
on mode changes etc.
- new calls WM_cursor_modal() and WM_cursor_restore() to
make temporarily cursor types during modes.
- used above for view2d cursors.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 54 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_cursors.h | 3 |
5 files changed, 45 insertions, 27 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index b278f83706a..b0fdcee2c04 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -55,10 +55,11 @@ void WM_read_autosavefile(struct bContext *C); void WM_write_autosave (struct bContext *C); /* mouse cursors */ -void WM_init_cursor_data (void); -void WM_set_cursor (struct bContext *C, int curs); -void WM_waitcursor (struct bContext *C, int val); -void WM_timecursor (struct bContext *C, int nr); +void WM_cursor_set (struct wmWindow *win, int curs); +void WM_cursor_modal (struct wmWindow *win, int curs); +void WM_cursor_restore (struct wmWindow *win); +void WM_cursor_wait (struct wmWindow *win, int val); +void WM_timecursor (struct wmWindow *win, int nr); /* keymap and handlers */ wmKeymapItem *WM_keymap_set_item (ListBase *lb, char *idname, short type, diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index e4299b8949b..8b4ddd786e0 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -86,15 +86,12 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB /* Cursor Globals */ static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs */ -static short CurrentCursor=-1, LastCursor=-1; -void WM_set_cursor(bContext *C, int curs) +void WM_cursor_set(wmWindow *win, int curs) { - wmWindow *win= C->window; if (win==NULL) return; /* Can't set custom cursor before Window init */ - win->cursor= curs; - + if (curs==CURSOR_NONE) { GHOST_SetCursorVisibility(win->ghostwin, 0); return; @@ -102,18 +99,14 @@ void WM_set_cursor(bContext *C, int curs) GHOST_SetCursorVisibility(win->ghostwin, 1); - LastCursor=CurrentCursor; - CurrentCursor=curs; - - /* previous cursor? */ - if (curs==LASTCURSOR) curs=LastCursor; + win->cursor= curs; /* detect if we use system cursor or Blender cursor */ if(curs>=BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); } else { - if ((curs<LASTCURSOR)||(curs>=BC_NUMCURSORS)) return; + if ((curs<SYSCURSOR) || (curs>=BC_NUMCURSORS)) return; if (curs==SYSCURSOR) { /* System default Cursor */ GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); @@ -127,18 +120,34 @@ void WM_set_cursor(bContext *C, int curs) } } -void WM_waitcursor(bContext *C, int val) +static int LastCursor=-1; /* global, assumed we only have one */ + +void WM_cursor_modal(wmWindow *win, int val) { - if(C->window) { - if(val) { - WM_set_cursor(C, CURSOR_WAIT); - } else { - WM_set_cursor(C, LASTCURSOR); - } + if(LastCursor == -1) + LastCursor = win->cursor; + WM_cursor_set(win, val); +} + +void WM_cursor_restore(wmWindow *win) +{ + if(LastCursor != -1) + WM_cursor_set(win, LastCursor); + LastCursor = -1; +} + + +void WM_cursor_wait(wmWindow *win, int val) +{ + if(val) { + WM_cursor_modal(win, CURSOR_WAIT); + } else { + WM_cursor_restore(win); } } -void WM_timecursor(bContext *C, int nr) +/* afer this you can call restore too */ +void WM_timecursor(wmWindow *win, int nr) { /* 10 8x8 digits */ static char number_bitmaps[10][8]= { @@ -157,6 +166,9 @@ void WM_timecursor(bContext *C, int nr) unsigned char bitmap[16][2]; int i, idx; + if(LastCursor != -1) + LastCursor= win->cursor; + memset(&bitmap, 0x00, sizeof(bitmap)); memset(&mask, 0xFF, sizeof(mask)); @@ -171,7 +183,7 @@ void WM_timecursor(bContext *C, int nr) nr/= 10; } - window_set_custom_cursor(C->window, mask, bitmap, 7, 7); + window_set_custom_cursor(win, mask, bitmap, 7, 7); } @@ -217,7 +229,7 @@ are for */ #define BEGIN_CURSOR_BLOCK { #define END_CURSOR_BLOCK } -void WM_init_cursor_data(void){ +void wm_init_cursor_data(void){ /********************** NW_ARROW Cursor **************************/ BEGIN_CURSOR_BLOCK diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a083edf826a..6aa8c980456 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -648,7 +648,8 @@ void wm_event_do_handlers(bContext *C) int doit= 0; /* XXX to solve, here screen handlers? */ - ED_screen_set_subwinactive(win); /* state variables in screen */ + if(!wm_event_always_pass(event)) + ED_screen_set_subwinactive(win); /* state variables in screen */ for(sa= win->screen->areabase.first; sa; sa= sa->next) { if(wm_event_always_pass(event) || wm_event_prev_inside_i(event, &sa->totrct)) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index db37f0754a0..4d170ceeb46 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -74,6 +74,8 @@ #include "WM_api.h" #include "WM_types.h" + +#include "wm_cursors.h" #include "wm_event_system.h" #include "wm.h" #include "wm_files.h" @@ -110,6 +112,7 @@ void WM_init(bContext *C) { wm_ghost_init(C); /* note: it assigns C to ghost! */ + wm_init_cursor_data(); wm_operatortype_init(); set_free_windowmanager_cb(wm_close_and_free); /* library.c */ diff --git a/source/blender/windowmanager/wm_cursors.h b/source/blender/windowmanager/wm_cursors.h index 73ff6ccc19e..e3f0e846b7a 100644 --- a/source/blender/windowmanager/wm_cursors.h +++ b/source/blender/windowmanager/wm_cursors.h @@ -32,6 +32,8 @@ #ifndef WM_CURSORS_H #define WM_CURSORS_H +void wm_init_cursor_data(void); + #define BC_GHOST_CURSORS 1000 /* old cursors */ @@ -72,7 +74,6 @@ typedef struct BCursor { } BCursor; -#define LASTCURSOR -2 #define SYSCURSOR -1 enum { BC_NW_ARROWCURSOR=0, |