diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-18 23:40:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-18 23:40:26 +0400 |
commit | 9b75187c55831030d9ba73ac9f2bd17b406be28d (patch) | |
tree | 4433fa097dd41196eaa69f2b9a7317f33d18d3ae /source/blender | |
parent | 119844eb23718870df614a68a035573e9c5e4e11 (diff) |
initialize keymaps after python so python keymaps, solves the problem of keymaps complaining about python operators not existing, but at the expense of some annoying init flags/functions. :/
Brecht/Ton you may want to check that C->data.py_init is a good place to store this.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_context.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 11 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_windowmanager_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 19 |
5 files changed, 34 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 5baf5af81d1..8078f57b98e 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -101,6 +101,10 @@ bContextStore *CTX_store_copy(bContextStore *store); void CTX_store_free(bContextStore *store); void CTX_store_free_list(ListBase *contexts); +/* need to store if python is initialized or not */ +int CTX_py_init_get(bContext *C); +int CTX_py_init_set(bContext *C, int value); + /* Window Manager Context */ struct wmWindowManager *CTX_wm_manager(const bContext *C); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 4bfc1484e56..17349ecc919 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -68,6 +68,7 @@ struct bContext { struct Scene *scene; int recursion; + int py_init; /* true if python is initialized */ } data; /* data evaluation */ @@ -162,6 +163,16 @@ void CTX_store_free_list(ListBase *contexts) } } +/* is python initialied? */ +int CTX_py_init_get(bContext *C) +{ + return C->data.py_init; +} +int CTX_py_init_set(bContext *C, int value) +{ + C->data.py_init= value; +} + /* window manager context */ wmWindowManager *CTX_wm_manager(const bContext *C) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 69ab45d3389..126b6c47b63 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -117,6 +117,9 @@ typedef struct wmWindowManager { } wmWindowManager; +/* wmWindowManager.initialized */ +#define WM_INIT_WINDOW 1<<0 +#define WM_INIT_KEYMAP 1<<1 /* the savable part, rest of data is local in ghostwinlay */ typedef struct wmWindow { diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a5e1df1669a..3615df8bd3b 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -72,6 +72,7 @@ void *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct b void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle); /* keymap */ +void WM_keymap_init (struct bContext *C); wmKeymapItem *WM_keymap_verify_item(ListBase *lb, char *idname, short type, short val, int modifier, short keymodifier); wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 94200925a02..863fb3ab4bd 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -120,6 +120,18 @@ void WM_operator_stack_clear(bContext *C) /* ****************************************** */ +void WM_keymap_init(bContext *C) +{ + wmWindowManager *wm= CTX_wm_manager(C); + + if(CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) { + wm_window_keymap(wm); + ED_spacetypes_keymap(wm); + + wm->initialized |= WM_INIT_KEYMAP; + } +} + void wm_check(bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); @@ -136,13 +148,12 @@ void wm_check(bContext *C) wm_window_add_ghostwindows(wm); /* case: fileread */ - if(wm->initialized==0) { + if((wm->initialized & WM_INIT_WINDOW) == 0) { - wm_window_keymap(wm); - ED_spacetypes_keymap(wm); + WM_keymap_init(C); ED_screens_initialize(wm); - wm->initialized= 1; + wm->initialized |= WM_INIT_WINDOW; } } |