Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-13 21:02:12 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-13 21:29:13 +0300
commitca6dd692b5b0137d236f14ed306196662f0cd869 (patch)
tree579ae2480246e89572365a8ef0662f33a9bb06c2
parentc39d5a6c88dcda9dff9626d7b059a98913da6fd2 (diff)
Keymaps: reload key configuration when changing select mouse.
For configuration scripts that want to change keymaps based on this setting.
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c7
-rw-r--r--source/blender/windowmanager/WM_keymap.h4
-rw-r--r--source/blender/windowmanager/intern/wm.c21
-rw-r--r--source/creator/creator.c2
5 files changed, 26 insertions, 10 deletions
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index abd35a3cc73..e13847f2473 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -168,7 +168,7 @@ typedef struct wmWindowManager {
/* wmWindowManager.initialized */
enum {
WM_WINDOW_IS_INITIALIZED = (1<<0),
- WM_KEYMAP_IS_INITIALIZED = (1<<1),
+ WM_KEYCONFIG_IS_INITIALIZED = (1<<1),
};
/* IME is win32 only! */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 1ea5c164449..84258835b14 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -222,6 +222,11 @@ static void rna_userdef_select_mouse_set(PointerRNA *ptr, int value)
userdef->flag &= ~USER_LMOUSESELECT;
}
+static void rna_userdef_select_mouse_update(bContext *C, Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ WM_keyconfig_reload(C);
+}
+
static int rna_userdef_autokeymode_get(PointerRNA *ptr)
{
UserDef *userdef = (UserDef *)ptr->data;
@@ -4546,6 +4551,8 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_enum_items(prop, select_mouse_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_userdef_select_mouse_set", NULL);
RNA_def_property_ui_text(prop, "Select Mouse", "Mouse button used for selection");
+ RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+ RNA_def_property_update(prop, 0, "rna_userdef_select_mouse_update");
prop = RNA_def_property(srna, "view_zoom_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "viewzoom");
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 71037ab162e..f93ef005b2a 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -42,6 +42,9 @@ struct EnumPropertyItem;
/* Key Configuration */
+void WM_keyconfig_init (struct bContext *C);
+void WM_keyconfig_reload (struct bContext *C);
+
wmKeyConfig *WM_keyconfig_new (struct wmWindowManager *wm, const char *idname, bool user_defined);
wmKeyConfig *WM_keyconfig_new_user(struct wmWindowManager *wm, const char *idname);
bool WM_keyconfig_remove (struct wmWindowManager *wm, struct wmKeyConfig *keyconf);
@@ -56,7 +59,6 @@ void WM_keyconfig_update_operatortype(void);
/* Keymap */
-void WM_keymap_init (struct bContext *C);
void WM_keymap_clear (struct wmKeyMap *keymap);
wmKeyMapItem *WM_keymap_verify_item(
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index bc9c1e263cb..29a1252cf4b 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -225,7 +225,16 @@ void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
/* ****************************************** */
-void WM_keymap_init(bContext *C)
+void WM_keyconfig_reload(bContext *C)
+{
+ if (CTX_py_init_get(C) && !G.background) {
+ BPY_execute_string(
+ C, (const char *[]){"bpy", NULL},
+ "bpy.utils.keyconfig_init()");
+ }
+}
+
+void WM_keyconfig_init(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
@@ -239,16 +248,14 @@ void WM_keymap_init(bContext *C)
/* initialize only after python init is done, for keymaps that
* use python operators */
- if (CTX_py_init_get(C) && (wm->initialized & WM_KEYMAP_IS_INITIALIZED) == 0) {
+ if (CTX_py_init_get(C) && (wm->initialized & WM_KEYCONFIG_IS_INITIALIZED) == 0) {
/* create default key config, only initialize once,
* it's persistent across sessions */
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
wm_window_keymap(wm->defaultconf);
ED_spacetypes_keymap(wm->defaultconf);
- BPY_execute_string(
- C, (const char *[]){"bpy", NULL},
- "bpy.utils.keyconfig_init()");
+ WM_keyconfig_reload(C);
wm->defaultconf->flag |= KEYCONF_INIT_DEFAULT;
}
@@ -256,7 +263,7 @@ void WM_keymap_init(bContext *C)
WM_keyconfig_update_tag(NULL, NULL);
WM_keyconfig_update(wm);
- wm->initialized |= WM_KEYMAP_IS_INITIALIZED;
+ wm->initialized |= WM_KEYCONFIG_IS_INITIALIZED;
}
}
@@ -278,7 +285,7 @@ void WM_check(bContext *C)
if (!G.background) {
/* case: fileread */
if ((wm->initialized & WM_WINDOW_IS_INITIALIZED) == 0) {
- WM_keymap_init(C);
+ WM_keyconfig_init(C);
WM_autosave_init(wm);
}
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 3cd3e2986f9..5bc266427d5 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -465,7 +465,7 @@ int main(
#endif
CTX_py_init_set(C, 1);
- WM_keymap_init(C);
+ WM_keyconfig_init(C);
/* Called on load, however Python is not yet initialized, so call again here. */
if (!G.background) {