diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-24 11:56:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-24 11:56:42 +0400 |
commit | ad1d3dd30fa5f4c33279679e3824899fd18801b8 (patch) | |
tree | cef4de1e42c5a8a2a1f68719452891c19a065ab7 /source/blender/windowmanager | |
parent | 77a7ec7c61965efa9e2e82894c821fe5c937b989 (diff) | |
parent | 1bdf652b89871614c38bf2146cf94522c3347e06 (diff) |
svn merge ^/trunk/blender -r41175:41200 --- will need to apply fix after
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 58 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 26 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 2 |
6 files changed, 52 insertions, 53 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index f28fb08ac6e..5048166c8b7 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -98,6 +98,11 @@ enum { #define KM_ALT2 64 #define KM_OSKEY2 128 +/* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl */ +/* note that KM_ANY and FALSE are used with these defines too */ +#define KM_MOD_FIRST 1 +#define KM_MOD_SECOND 2 + /* type: defined in wm_event_types.c */ #define KM_TEXTINPUT -2 diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e73440e5eb0..c798b284c7b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2611,39 +2611,43 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U GHOST_TEventKeyData *kd= customdata; event.type= convert_key(kd->key); event.ascii= kd->ascii; - strcpy(event.utf8_buf, kd->utf8_buf); + 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<32 && event.ascii>0)) - event.ascii= '\0'; - - /* modifiers */ - if (event.type==LEFTSHIFTKEY || event.type==RIGHTSHIFTKEY) { - event.shift= evt->shift= (event.val==KM_PRESS); - if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->oskey)) - event.shift= evt->shift = 3; // define? - } - else if (event.type==LEFTCTRLKEY || event.type==RIGHTCTRLKEY) { - event.ctrl= evt->ctrl= (event.val==KM_PRESS); - if(event.val==KM_PRESS && (evt->shift || evt->alt || evt->oskey)) - event.ctrl= evt->ctrl = 3; // define? - } - else if (event.type==LEFTALTKEY || event.type==RIGHTALTKEY) { - event.alt= evt->alt= (event.val==KM_PRESS); - if(event.val==KM_PRESS && (evt->ctrl || evt->shift || evt->oskey)) - event.alt= evt->alt = 3; // define? - } - else if (event.type==OSKEY) { - event.oskey= evt->oskey= (event.val==KM_PRESS); - if(event.val==KM_PRESS && (evt->ctrl || evt->alt || evt->shift)) - event.oskey= evt->oskey = 3; // define? + if(type==GHOST_kEventKeyUp) { + if (event.ascii<32 && event.ascii > 0) { + event.ascii= '\0'; + } + + /* ghost should do this already for key up */ + if (event.utf8_buf[0]) { + printf("%s: ghost on you're platform is misbehaving, utf8 events on key up!\n", __func__); + } + event.utf8_buf[0]= '\0'; } - else { + + /* 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; } /* this case happens on some systems that on holding a key pressed, @@ -2729,4 +2733,8 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U } } + + /* Handy when debugging checking events */ + /* WM_event_print(&event); */ + } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 9b2d7026a46..823df35fc6e 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -289,8 +289,9 @@ static void wm_init_userdef(bContext *C) if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC; else G.f &= ~G_SCRIPT_AUTOEXEC; } + /* update tempdir from user preferences */ - BLI_where_is_temp(btempdir, FILE_MAX, 1); + BLI_init_temporary_dir(U.tempdir); } @@ -573,7 +574,7 @@ void WM_read_history(void) BLI_make_file_string("/", name, cfgdir, BLENDER_HISTORY_FILE); - lines= BLI_read_file_as_lines(name); + lines= BLI_file_read_as_lines(name); G.recent_files.first = G.recent_files.last = NULL; @@ -588,7 +589,7 @@ void WM_read_history(void) } } - BLI_free_file_lines(lines); + BLI_file_free_lines(lines); } @@ -856,14 +857,14 @@ void wm_autosave_location(char *filepath) * BLI_make_file_string will create string that has it most likely on C:\ * through get_default_root(). * If there is no C:\tmp autosave fails. */ - if (!BLI_exists(btempdir)) { + if (!BLI_exists(BLI_temporary_dir())) { savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL); BLI_make_file_string("/", filepath, savedir, pidstr); return; } #endif - BLI_make_file_string("/", filepath, btempdir, pidstr); + BLI_make_file_string("/", filepath, BLI_temporary_dir(), pidstr); } void WM_autosave_init(wmWindowManager *wm) @@ -921,7 +922,7 @@ void wm_autosave_delete(void) if(BLI_exists(filename)) { char str[FILE_MAXDIR+FILE_MAXFILE]; - BLI_make_file_string("/", str, btempdir, "quit.blend"); + BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); /* if global undo; remove tempsave, otherwise rename */ if(U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 4639e2a0514..6f50ef2631e 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -67,6 +67,7 @@ #include "BLI_cellalloc.h" #include "BLI_winstuff.h" +#include "RE_engine.h" #include "RE_pipeline.h" /* RE_ free stuff */ #ifdef WITH_PYTHON diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 854fa688ea4..99bd83ef8c1 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -310,31 +310,15 @@ static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modif kmi->type= type; kmi->val= val; kmi->keymodifier= keymodifier; - + if(modifier == KM_ANY) { kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY; } else { - - kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= 0; - - /* defines? */ - if(modifier & KM_SHIFT) - kmi->shift= 1; - else if(modifier & KM_SHIFT2) - kmi->shift= 2; - if(modifier & KM_CTRL) - kmi->ctrl= 1; - else if(modifier & KM_CTRL2) - kmi->ctrl= 2; - if(modifier & KM_ALT) - kmi->alt= 1; - else if(modifier & KM_ALT2) - kmi->alt= 2; - if(modifier & KM_OSKEY) - kmi->oskey= 1; - else if(modifier & KM_OSKEY2) - kmi->oskey= 2; + kmi->shift= (modifier & KM_SHIFT) ? KM_MOD_FIRST : ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : FALSE); + kmi->ctrl= (modifier & KM_CTRL) ? KM_MOD_FIRST : ((modifier & KM_CTRL2) ? KM_MOD_SECOND : FALSE); + kmi->alt= (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : FALSE); + kmi->oskey= (modifier & KM_OSKEY) ? KM_MOD_FIRST : ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : FALSE); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a06da3941af..5fee5fb2a57 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1807,7 +1807,7 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_WINDOW, NULL); /* load file */ - BLI_make_file_string("/", filename, btempdir, "quit.blend"); + BLI_make_file_string("/", filename, BLI_temporary_dir(), "quit.blend"); WM_read_file(C, filename, op->reports); G.fileflags &= ~G_FILE_RECOVER; |