From bac1279b031f9b3996c4691e948d941e4dcfaea1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Aug 2016 01:19:22 +0200 Subject: Fix T49045: splash not working correctly on OS X, after recent bugfix. --- source/blender/windowmanager/intern/wm_window.c | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 425287993d9..2d43c47679d 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1197,23 +1197,26 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr } case GHOST_kEventNativeResolutionChange: { - // printf("change, pixel size %f\n", GHOST_GetNativePixelSize(win->ghostwin)); - + // only update if the actual pixel size changes + float prev_pixelsize = U.pixelsize; U.pixelsize = wm_window_pixelsize(win); - BKE_blender_userdef_refresh(); - // close all popups since they are positioned with the pixel - // size baked in and it's difficult to correct them - wmWindow *oldWindow = CTX_wm_window(C); - CTX_wm_window_set(C, win); - UI_popup_handlers_remove_all(C, &win->modalhandlers); - CTX_wm_window_set(C, oldWindow); + if (U.pixelsize != prev_pixelsize) { + BKE_blender_userdef_refresh(); - wm_window_make_drawable(wm, win); - wm_draw_window_clear(win); + // close all popups since they are positioned with the pixel + // size baked in and it's difficult to correct them + wmWindow *oldWindow = CTX_wm_window(C); + CTX_wm_window_set(C, win); + UI_popup_handlers_remove_all(C, &win->modalhandlers); + CTX_wm_window_set(C, oldWindow); + + wm_window_make_drawable(wm, win); + wm_draw_window_clear(win); - WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); + } break; } -- cgit v1.2.3 From b10d0058d72da3051895481ae5830a7b668b7d80 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Thu, 18 Aug 2016 00:21:55 -0400 Subject: NDOF: compile 3D mouse code only if WITH_INPUT_NDOF When WITH_INPUT_NDOF is disabled, 3D mouse handling code is removed from: - GHOST (was mostly done, finished the job) - window manager - various editors - RNA - keymaps The input tab of user prefs does not show 3D mouse settings. Key map editor does not show NDOF mappings. DNA does not change. On my Mac the compiled binary is 42KB smaller after this change. It runs fine WITH_INPUT_NDOF on or off. --- source/blender/windowmanager/CMakeLists.txt | 4 ++++ source/blender/windowmanager/WM_api.h | 8 +++++++- source/blender/windowmanager/WM_types.h | 2 ++ source/blender/windowmanager/intern/wm_event_system.c | 12 ++++++++++++ source/blender/windowmanager/intern/wm_init_exit.c | 3 +++ source/blender/windowmanager/intern/wm_operators.c | 10 +++++----- source/blender/windowmanager/wm_event_types.h | 10 +++++++++- 7 files changed, 42 insertions(+), 7 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 01188cb7f65..b6245a8c0d1 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -146,6 +146,10 @@ if(WITH_OPENSUBDIV) add_definitions(-DWITH_OPENSUBDIV) endif() +if(WITH_INPUT_NDOF) + add_definitions(-DWITH_INPUT_NDOF) +endif() + if(WIN32) if(WITH_INPUT_IME) add_definitions(-DWITH_INPUT_IME) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 69905fc296b..2b82f1becb3 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -64,7 +64,10 @@ struct wmDrag; struct ImBuf; struct ImageFormatData; struct ARegion; + +#ifdef WITH_INPUT_NDOF struct wmNDOFMotionData; +#endif typedef struct wmJob wmJob; @@ -186,9 +189,10 @@ void WM_event_add_mousemove(struct bContext *C); bool WM_modal_tweak_exit(const struct wmEvent *event, int tweak_event); bool WM_event_is_absolute(const struct wmEvent *event); +#ifdef WITH_INPUT_NDOF /* 3D mouse */ void WM_ndof_deadzone_set(float deadzone); - +#endif /* notifiers */ void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference); void WM_main_add_notifier(unsigned int type, void *reference); @@ -498,11 +502,13 @@ bool write_crash_blend(void); /* Lock the interface for any communication */ void WM_set_locked_interface(struct wmWindowManager *wm, bool lock); +#ifdef WITH_INPUT_NDOF void WM_event_ndof_pan_get(const struct wmNDOFMotionData *ndof, float r_pan[3], const bool use_zoom); void WM_event_ndof_rotate_get(const struct wmNDOFMotionData *ndof, float r_rot[3]); float WM_event_ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3]); void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]); +#endif /* WITH_INPUT_NDOF */ float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]); bool WM_event_is_tablet(const struct wmEvent *event); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 3c0e99bddd0..0fe3e8a0fcf 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -485,6 +485,7 @@ typedef enum { /* motion progress, for modal handlers */ P_FINISHED } wmProgress; +#ifdef WITH_INPUT_NDOF typedef struct wmNDOFMotionData { /* awfully similar to GHOST_TEventNDOFMotionData... */ /* Each component normally ranges from -1 to +1, but can exceed that. @@ -496,6 +497,7 @@ typedef struct wmNDOFMotionData { float dt; /* time since previous NDOF Motion event */ wmProgress progress; /* is this the first event, the last, or one of many in between? */ } wmNDOFMotionData; +#endif /* WITH_INPUT_NDOF */ typedef struct wmTimer { struct wmTimer *next, *prev; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 01dc77127d2..77d74399769 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -567,6 +567,7 @@ void WM_event_print(const wmEvent *event) BLI_str_utf8_size(event->utf8_buf), event->utf8_buf, event->keymap_idname, (const void *)event); +#ifdef WITH_INPUT_NDOF if (ISNDOF(event->type)) { const wmNDOFMotionData *ndof = event->customdata; if (event->type == NDOF_MOTION) { @@ -577,6 +578,7 @@ void WM_event_print(const wmEvent *event) /* ndof buttons printed already */ } } +#endif /* WITH_INPUT_NDOF */ if (event->tablet_data) { const wmTabletData *wmtab = event->tablet_data; @@ -613,10 +615,12 @@ bool WM_event_is_absolute(const wmEvent *event) return (event->tablet_data != NULL); } +#ifdef WITH_INPUT_NDOF void WM_ndof_deadzone_set(float deadzone) { GHOST_setNDOFDeadZone(deadzone); } +#endif static void wm_add_reports(ReportList *reports) { @@ -2423,9 +2427,11 @@ void wm_event_do_handlers(bContext *C) /* for regions having custom cursors */ wm_paintcursor_test(C, event); } +#ifdef WITH_INPUT_NDOF else if (event->type == NDOF_MOTION) { win->addmousemove = true; } +#endif for (sa = win->screen->areabase.first; sa; sa = sa->next) { /* after restoring a screen from SCREENMAXIMIZED we have to wait @@ -3026,6 +3032,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event) } } +#ifdef WITH_INPUT_NDOF /* adds customdata to event */ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *ghost) { @@ -3052,6 +3059,7 @@ static void attach_ndof_data(wmEvent *event, const GHOST_TEventNDOFMotionData *g event->customdata = data; event->customdatafree = 1; } +#endif /* WITH_INPUT_NDOF */ /* imperfect but probably usable... draw/enable drags to other windows */ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *event) @@ -3439,6 +3447,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } +#ifdef WITH_INPUT_NDOF case GHOST_kEventNDOFMotion: { event.type = NDOF_MOTION; @@ -3474,6 +3483,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } +#endif /* WITH_INPUT_NDOF */ case GHOST_kEventUnknown: case GHOST_kNumEventTypes: @@ -3545,6 +3555,7 @@ void WM_set_locked_interface(wmWindowManager *wm, bool lock) } +#ifdef WITH_INPUT_NDOF /* -------------------------------------------------------------------- */ /* NDOF */ @@ -3587,6 +3598,7 @@ void WM_event_ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]) angle = WM_event_ndof_to_axis_angle(ndof, axis); axis_angle_to_quat(q, axis, angle); } +#endif /* WITH_INPUT_NDOF */ /* if this is a tablet event, return tablet pressure and set *pen_flip * to 1 if the eraser tool is being used, 0 otherwise */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 3022d865460..73622cda483 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -198,8 +198,11 @@ void WM_init(bContext *C, int argc, const char **argv) BLT_lang_set(NULL); if (!G.background) { + +#ifdef WITH_INPUT_NDOF /* sets 3D mouse deadzone */ WM_ndof_deadzone_set(U.ndof_deadzone); +#endif GPU_init(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 78273615602..fcdab746d57 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -4348,7 +4348,6 @@ void wm_window_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0); wmKeyMapItem *kmi; - const char *data_path; /* note, this doesn't replace existing keymap items */ WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); @@ -4386,7 +4385,9 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* menus that can be accessed anywhere in blender */ WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0); +#ifdef WITH_INPUT_NDOF WM_keymap_add_menu(keymap, "USERPREF_MT_ndof_settings", NDOF_BUTTON_MENU, KM_PRESS, 0, 0); +#endif /* Space switching */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", F2KEY, KM_PRESS, KM_SHIFT, 0); /* new in 2.5x, was DXF export */ @@ -4433,8 +4434,9 @@ void wm_window_keymap(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "area.type"); RNA_string_set(kmi->ptr, "value", "DOPESHEET_EDITOR"); +#ifdef WITH_INPUT_NDOF /* ndof speed */ - data_path = "user_preferences.inputs.ndof_sensitivity"; + const char *data_path = "user_preferences.inputs.ndof_sensitivity"; kmi = WM_keymap_add_item(keymap, "WM_OT_context_scale_float", NDOF_BUTTON_PLUS, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", data_path); RNA_float_set(kmi->ptr, "value", 1.1f); @@ -4450,9 +4452,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_scale_float", NDOF_BUTTON_MINUS, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", data_path); RNA_float_set(kmi->ptr, "value", 1.0f / 1.5f); - data_path = NULL; - (void)data_path; - +#endif /* WITH_INPUT_NDOF */ gesture_circle_modal_keymap(keyconf); gesture_border_modal_keymap(keyconf); diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 3085f138846..0936b294d1b 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -40,7 +40,9 @@ enum { EVT_DATA_GESTURE = 1, EVT_DATA_TIMER = 2, EVT_DATA_DRAGDROP = 3, +#ifdef WITH_INPUT_NDOF EVT_DATA_NDOF_MOTION = 4, +#endif }; /* tablet active, matches GHOST_TTabletMode */ @@ -236,6 +238,7 @@ enum { /* *** End of keyboard codes. *** */ +#ifdef WITH_INPUT_NDOF /* NDOF (from SpaceNavigator & friends) * These should be kept in sync with GHOST_NDOFManager.h * Ordering matters, exact values do not. */ @@ -290,6 +293,7 @@ enum { NDOF_BUTTON_C, /* the end */ NDOF_LAST, +#endif /* WITH_INPUT_NDOF */ /* ********** End of Input devices. ********** */ @@ -369,8 +373,12 @@ enum { /* test whether the event is tweak event */ #define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_GESTURE) +#ifdef WITH_INPUT_NDOF /* test whether the event is a NDOF event */ -#define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) +# define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) +#else +# define ISNDOF(event_type) false +#endif /* test whether event type is acceptable as hotkey, excluding modifiers */ #define ISHOTKEY(event_type) \ -- cgit v1.2.3 From 33fbf9b7e0a3f7e1e78cd94c5dcaff1e0c562e6a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 19 Aug 2016 15:51:44 +0200 Subject: Fix broken keymap loading with disabled ndof - revert part of recent rBb10d0058d72da30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ifdef’ing out defines in DNA/RNA is not a good idea, was breaking alternative keymaps loading from splash screen e.g. (reported by Sergey over IRC, thanks). --- source/blender/windowmanager/wm_event_types.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 0936b294d1b..3085f138846 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -40,9 +40,7 @@ enum { EVT_DATA_GESTURE = 1, EVT_DATA_TIMER = 2, EVT_DATA_DRAGDROP = 3, -#ifdef WITH_INPUT_NDOF EVT_DATA_NDOF_MOTION = 4, -#endif }; /* tablet active, matches GHOST_TTabletMode */ @@ -238,7 +236,6 @@ enum { /* *** End of keyboard codes. *** */ -#ifdef WITH_INPUT_NDOF /* NDOF (from SpaceNavigator & friends) * These should be kept in sync with GHOST_NDOFManager.h * Ordering matters, exact values do not. */ @@ -293,7 +290,6 @@ enum { NDOF_BUTTON_C, /* the end */ NDOF_LAST, -#endif /* WITH_INPUT_NDOF */ /* ********** End of Input devices. ********** */ @@ -373,12 +369,8 @@ enum { /* test whether the event is tweak event */ #define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_GESTURE) -#ifdef WITH_INPUT_NDOF /* test whether the event is a NDOF event */ -# define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) -#else -# define ISNDOF(event_type) false -#endif +#define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST) /* test whether event type is acceptable as hotkey, excluding modifiers */ #define ISHOTKEY(event_type) \ -- cgit v1.2.3