diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-27 03:49:13 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-27 03:49:13 +0400 |
commit | 556912792ad3c37c294256a558c96b39f264e7b5 (patch) | |
tree | 9b6ee8cf1ad92ee89c04f27a89be11599c5b40c0 /source/blender/windowmanager | |
parent | 9251d628db0abe599d927d79170025d8545c8ace (diff) | |
parent | c84383301c5a2582e95259a7e4468a23a3566401 (diff) |
Merged changes in the trunk up to revision 54110.
Conflicts resolved:
source/blender/blenfont/SConscript
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/intern/rna_scene.c
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 25 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 22 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 73 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 94 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 60 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_system.h | 17 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 9 |
12 files changed, 252 insertions, 68 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index eb1aad75a88..bea54154e47 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -131,6 +131,7 @@ void *WM_paint_cursor_activate(struct wmWindowManager *wm, void WM_paint_cursor_end(struct wmWindowManager *wm, void *handle); void WM_cursor_warp (struct wmWindow *win, int x, int y); +float WM_cursor_pressure (const struct wmWindow *win); /* event map */ int WM_userdef_event_map(int kmitype); @@ -201,6 +202,7 @@ int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, con /* operator api */ void WM_operator_free (struct wmOperator *op); void WM_operator_stack_clear(struct wmWindowManager *wm); +void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot); struct wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet); struct GHashIterator *WM_operatortype_iter(void); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 197d585bff4..942cce1b6dd 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -448,7 +448,10 @@ typedef struct wmEvent { /* keymap item, set by handler (weak?) */ const char *keymap_idname; - + + /* tablet info, only use when the tablet is active */ + struct wmTabletData *tablet_data; + /* custom data */ short custom; /* custom data type, stylus, 6dof, see wm_event_types.h */ short customdatafree; diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 53e67e91bd2..a01f7301ec2 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -149,6 +149,31 @@ void WM_operator_stack_clear(wmWindowManager *wm) WM_main_add_notifier(NC_WM | ND_HISTORY, NULL); } +/** + * This function is needed in the case when an addon id disabled + * while a modal operator it defined is running. + */ +void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot) +{ + wmWindow *win; + for (win = wm->windows.first; win; win = win->next) { + ListBase *lb[2] = {&win->handlers, &win->modalhandlers}; + wmEventHandler *handler; + int i; + + for (i = 0; i < 2; i++) { + for (handler = lb[i]->first; handler; handler = handler->next) { + if (handler->op && handler->op->type == ot) { + /* don't run op->cancel because it needs the context, + * assume whoever unregisters the operator will cleanup */ + handler->flag |= WM_HANDLER_DO_FREE; + WM_operator_free(handler->op); + handler->op = NULL; + } + } + } + } +} /* ************ uiListType handling ************** */ diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index ebde6407a48..794bfdde114 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -188,12 +188,26 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int bounds[4]) * It helps not to get a stuck WM when hitting a breakpoint * */ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal; - - if (hide) mode = GHOST_kGrabHide; - else if (wrap) mode = GHOST_kGrabWrap; + float fac = GHOST_GetNativePixelSize(win->ghostwin); + + /* in case pixel coords differ from window/mouse coords */ + if (bounds) { + bounds[0] /= fac; + bounds[1] /= fac; + bounds[2] /= fac; + bounds[3] /= fac; + } + + if (hide) { + mode = GHOST_kGrabHide; + } + else if (wrap) { + mode = GHOST_kGrabWrap; + } if ((G.debug & G_DEBUG) == 0) { - if (win && win->ghostwin) { + if (win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); + /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 48cad9e020b..84fee9ff34c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -84,6 +84,8 @@ # include "RNA_enum_types.h" #endif +static void update_tablet_data(wmWindow *win, wmEvent *event); + static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, short context, short poll_only); @@ -94,6 +96,9 @@ void wm_event_add(wmWindow *win, wmEvent *event_to_add) wmEvent *event = MEM_callocN(sizeof(wmEvent), "wmEvent"); *event = *event_to_add; + + update_tablet_data(win, event); + BLI_addtail(&win->queue, event); } @@ -108,6 +113,11 @@ void wm_event_free(wmEvent *event) MEM_freeN(event->customdata); } } + + if (event->tablet_data) { + MEM_freeN(event->tablet_data); + } + MEM_freeN(event); } @@ -2652,9 +2662,12 @@ static void update_tablet_data(wmWindow *win, wmEvent *event) wmtab->Xtilt = td->Xtilt; wmtab->Ytilt = td->Ytilt; - event->custom = EVT_DATA_TABLET; - event->customdata = wmtab; - event->customdatafree = 1; + event->tablet_data = wmtab; + // printf("%s: using tablet %.5f\n", __func__, wmtab->Pressure); + } + else { + event->tablet_data = NULL; + // printf("%s: not using tablet\n", __func__); } } @@ -2747,6 +2760,24 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi return NULL; } +static bool wm_event_is_double_click(wmEvent *event, wmEvent *event_state) +{ + if ((event->type == event_state->prevtype) && + (event_state->prevval == KM_RELEASE) && + (event->val == KM_PRESS)) + { + if ((ISMOUSE(event->type) == false) || ((ABS(event->x - event_state->prevclickx)) <= 2 && + (ABS(event->y - event_state->prevclicky)) <= 2)) + { + if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) { + return true; + } + } + } + + return false; +} + /* windows store own event queues, no bContext here */ /* time is in 1000s of seconds, from ghost */ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int UNUSED(time), void *customdata) @@ -2756,7 +2787,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* initialize and copy state (only mouse x y and modifiers) */ event = *evt; - + switch (type) { /* mouse move, also to inactive window (X11 does this) */ case GHOST_kEventCursorMove: @@ -2778,7 +2809,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if (lastevent && lastevent->type == MOUSEMOVE) lastevent->type = INBETWEEN_MOUSEMOVE; - update_tablet_data(win, &event); wm_event_add(win, &event); /* also add to other window if event is there, this makes overdraws disappear nicely */ @@ -2791,7 +2821,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U oevent.y = owin->eventstate->y = event.y; oevent.type = MOUSEMOVE; - update_tablet_data(owin, &oevent); wm_event_add(owin, &oevent); } @@ -2823,7 +2852,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.prevx = event.x - pd->deltaX; event.prevy = event.y - (-pd->deltaY); - update_tablet_data(win, &event); wm_event_add(win, &event); break; } @@ -2868,15 +2896,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U } /* double click test */ - if (event.type == evt->prevtype && event.val == KM_PRESS) { - if ((ABS(event.x - evt->prevclickx)) <= 2 && - (ABS(event.y - evt->prevclicky)) <= 2 && - ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time)) - { - if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) ) - printf("%s Send double click\n", __func__); - event.val = KM_DBL_CLICK; - } + if (wm_event_is_double_click(&event, evt)) { + if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) ) + printf("%s Send double click\n", __func__); + event.val = KM_DBL_CLICK; } if (event.val == KM_PRESS) { evt->prevclicktime = PIL_check_seconds_timer(); @@ -2894,11 +2917,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U oevent.type = event.type; oevent.val = event.val; - update_tablet_data(owin, &oevent); wm_event_add(owin, &oevent); } else { - update_tablet_data(win, &event); wm_event_add(win, &event); } @@ -2982,15 +3003,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U /* double click test */ /* if previous event was same type, and previous was release, and now it presses... */ - if (event.type == evt->prevtype && evt->prevval == KM_RELEASE && event.val == KM_PRESS) { - if ((ABS(event.x - evt->prevclickx)) <= 2 && - (ABS(event.y - evt->prevclicky)) <= 2 && - ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time)) - { - if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) ) - printf("%s Send double click\n", __func__); - evt->val = event.val = KM_DBL_CLICK; - } + if (wm_event_is_double_click(&event, evt)) { + if (G.debug & (G_DEBUG_HANDLERS | G_DEBUG_EVENTS) ) + printf("%s Send double click\n", __func__); + evt->val = event.val = KM_DBL_CLICK; } /* this case happens on holding a key pressed, it should not generate @@ -3100,4 +3116,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U } +#if 0 + WM_event_print(&event); +#endif } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 550a9f83cff..2d4e4a5334a 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -306,11 +306,6 @@ static void wm_init_userdef(bContext *C) /* update tempdir from user preferences */ BLI_init_temporary_dir(U.tempdir); - - /* displays with larger native pixels, like Macbook. Used to scale dpi with */ - if (G.background == FALSE) - U.pixelsize = GHOST_GetNativePixelSize(); - if (U.pixelsize == 0) U.pixelsize = 1; BKE_userdef_state(); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b2c3c935553..03a81e944c0 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -69,6 +69,7 @@ #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_material.h" #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" /* BKE_ST_MAXNAME */ @@ -561,6 +562,7 @@ char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, i } /* return NULL if no match is found */ +#if 0 static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index) { @@ -583,7 +585,7 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert for (link = lb.first; link; link = link->next) { const char *identifier = link->data; - PointerRNA ctx_item_ptr = {{0}}; // CTX_data_pointer_get(C, identifier); + PointerRNA ctx_item_ptr = {{0}} // CTX_data_pointer_get(C, identifier); // XXX, this isnt working if (ctx_item_ptr.type == NULL) { continue; @@ -624,6 +626,94 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert return ret; } +#else + +/* use hard coded checks for now */ +static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index) +{ + const char *member_id = NULL; + + char *prop_str = NULL; + char *ret = NULL; + + if (ptr->id.data) { + ID *idptr = ptr->id.data; + +#define CTX_TEST_PTR_ID(C, member, idptr) \ + { \ + const char *ctx_member = member; \ + PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, ctx_member); \ + if (ctx_item_ptr.id.data == idptr) { \ + member_id = ctx_member; \ + break; \ + } \ + } (void)0 + +#define CTX_TEST_PTR_ID_CAST(C, member, member_full, cast, idptr) \ + { \ + const char *ctx_member = member; \ + const char *ctx_member_full = member_full; \ + PointerRNA ctx_item_ptr = CTX_data_pointer_get(C, ctx_member); \ + if (ctx_item_ptr.id.data && cast(ctx_item_ptr.id.data) == idptr) { \ + member_id = ctx_member_full; \ + break; \ + } \ + } (void)0 + + switch (GS(idptr->name)) { + case ID_SCE: + { + CTX_TEST_PTR_ID(C, "scene", ptr->id.data); + break; + } + case ID_OB: + { + CTX_TEST_PTR_ID(C, "object", ptr->id.data); + break; + } + /* from rna_Main_objects_new */ + case OB_DATA_SUPPORT_ID_CASE: + { +#define ID_CAST_OBDATA(id_pt) (((Object *)(id_pt))->data) + CTX_TEST_PTR_ID_CAST(C, "object", "object.data", ID_CAST_OBDATA, ptr->id.data); + break; +#undef ID_CAST_OBDATA + } + case ID_MA: + { +#define ID_CAST_OBMATACT(id_pt) (give_current_material(((Object *)id_pt), ((Object *)id_pt)->actcol)) + CTX_TEST_PTR_ID_CAST(C, "object", "object.active_material", ID_CAST_OBMATACT, ptr->id.data); + break; +#undef ID_CAST_OBMATACT + } + case ID_WO: + { +#define ID_CAST_SCENEWORLD(id_pt) (((Scene *)(id_pt))->world) + CTX_TEST_PTR_ID_CAST(C, "scene", "scene.world", ID_CAST_SCENEWORLD, ptr->id.data); + break; +#undef ID_CAST_SCENEWORLD + } + case ID_SCR: + { + CTX_TEST_PTR_ID(C, "screen", ptr->id.data); + break; + } + } + + if (member_id) { + prop_str = RNA_path_struct_property_py(ptr, prop, index); + if (prop_str) { + ret = BLI_sprintfN("bpy.context.%s.%s", member_id, prop_str); + MEM_freeN(prop_str); + } + } +#undef CTX_TEST_PTR_ID +#undef CTX_TEST_PTR_ID_CAST + } + + return ret; +} +#endif char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index) { @@ -1589,7 +1679,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); - uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-265"); + uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-266"); uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.6/Manual"); uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 8b387196da7..fd44f4a7169 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -689,7 +689,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) break; } case GHOST_kEventWindowActivate: - case GHOST_kEventWindowDeactivate: { + case GHOST_kEventWindowDeactivate: + { g_WS.qual &= ~WS_QUAL_MOUSE; break; } diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 1ed9ffb3b6c..20406ac463d 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -255,7 +255,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) width = BLI_rcti_size_x(&_curswin->winrct) + 1; height = BLI_rcti_size_y(&_curswin->winrct) + 1; glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - + if (srct) { int width = BLI_rcti_size_x(srct) + 1; /* only here */ int height = BLI_rcti_size_y(srct) + 1; @@ -266,11 +266,10 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); glLoadIdentity(); - + glFlush(); } - /* enable the WM versions of opengl calls */ void wmSubWindowSet(wmWindow *win, int swinid) { diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 9e0f8613a1a..44c5693c3e3 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -75,6 +75,11 @@ #include "UI_interface.h" +/* for assert */ +#ifndef NDEBUG +# include "BLI_threads.h" +#endif + /* the global to talk to ghost */ static GHOST_SystemHandle g_system = NULL; @@ -377,7 +382,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) /* displays with larger native pixels, like Macbook. Used to scale dpi with */ /* needed here, because it's used before it reads userdef */ - U.pixelsize = GHOST_GetNativePixelSize(); + U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); BKE_userdef_state(); /* store actual window size in blender window */ @@ -595,12 +600,13 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) static void wm_convert_cursor_position(wmWindow *win, int *x, int *y) { - + float fac = GHOST_GetNativePixelSize(win->ghostwin); + GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y); - *x *= GHOST_GetNativePixelSize(); + *x *= fac; *y = (win->sizey - 1) - *y; - *y *= GHOST_GetNativePixelSize(); + *y *= fac; } @@ -661,6 +667,10 @@ void wm_window_make_drawable(bContext *C, wmWindow *win) printf("%s: set drawable %d\n", __func__, win->winid); } GHOST_ActivateWindowDrawingContext(win->ghostwin); + + /* this can change per window */ + U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); + BKE_userdef_state(); } } @@ -947,6 +957,15 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr break; } + case GHOST_kEventNativeResolutionChange: + // printf("change, pixel size %f\n", GHOST_GetNativePixelSize(win->ghostwin)); + + U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); + BKE_userdef_state(); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); + + break; case GHOST_kEventTrackpad: { GHOST_TEventTrackpadData *pd = data; @@ -1022,8 +1041,12 @@ static int wm_window_timer(const bContext *C) void wm_window_process_events(const bContext *C) { - int hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ - + int hasevent; + + BLI_assert(BLI_thread_is_main()); + + hasevent = GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */ + if (hasevent) GHOST_DispatchEvents(g_system); @@ -1045,7 +1068,9 @@ void wm_window_testbreak(void) { static double ltime = 0; double curtime = PIL_check_seconds_timer(); - + + BLI_assert(BLI_thread_is_main()); + /* only check for breaks every 50 milliseconds * if we get called more often. */ @@ -1289,7 +1314,7 @@ void WM_init_native_pixels(int do_it) void WM_cursor_warp(wmWindow *win, int x, int y) { if (win && win->ghostwin) { - float f = GHOST_GetNativePixelSize(); + float f = GHOST_GetNativePixelSize(win->ghostwin); int oldx = x, oldy = y; x = x / f; @@ -1304,18 +1329,33 @@ void WM_cursor_warp(wmWindow *win, int x, int y) } } +/** + * Get the cursor pressure, in most cases you'll want to use wmTabletData from the event + */ +float WM_cursor_pressure(const struct wmWindow *win) +{ + const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin); + /* if there's tablet data from an active tablet device then add it */ + if ((td != NULL) && td->Active != GHOST_kTabletModeNone) { + return td->Pressure; + } + else { + return -1.0f; + } +} + /* support for native pixel size */ /* mac retina opens window in size X, but it has up to 2 x more pixels */ int WM_window_pixels_x(wmWindow *win) { - float f = GHOST_GetNativePixelSize(); + float f = GHOST_GetNativePixelSize(win->ghostwin); return (int)(f * (float)win->sizex); } int WM_window_pixels_y(wmWindow *win) { - float f = GHOST_GetNativePixelSize(); + float f = GHOST_GetNativePixelSize(win->ghostwin); return (int)(f * (float)win->sizey); diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index 2fbfdc41bce..d12e1d47fa0 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -45,7 +45,8 @@ struct ARegion; typedef struct wmEventHandler { struct wmEventHandler *next, *prev; - int type, flag; /* type default=0, rest is custom */ + int type; /* WM_HANDLER_DEFAULT, ... */ + int flag; /* WM_HANDLER_BLOCKING, ... */ /* keymap handler */ wmKeyMap *keymap; /* pointer to builtin/custom keymaps */ @@ -72,21 +73,17 @@ typedef struct wmEventHandler { } wmEventHandler; - -/* handler flag */ - /* after this handler all others are ignored */ -#define WM_HANDLER_BLOCKING 1 - /* handler tagged to be freed in wm_handlers_do() */ -#define WM_HANDLER_DO_FREE 2 - - - /* custom types for handlers, for signalling, freeing */ enum { WM_HANDLER_DEFAULT, WM_HANDLER_FILESELECT }; +/* handler flag */ +enum { + WM_HANDLER_BLOCKING = 1, /* after this handler all others are ignored */ + WM_HANDLER_DO_FREE = 2 /* handler tagged to be freed in wm_handlers_do() */ +}; /* wm_event_system.c */ void wm_event_free_all (wmWindow *win); diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 78a67a31e0f..bc7e7efdcfd 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -39,11 +39,10 @@ #define __WM_EVENT_TYPES_H__ /* customdata type */ -#define EVT_DATA_TABLET 1 -#define EVT_DATA_GESTURE 2 -#define EVT_DATA_TIMER 3 -#define EVT_DATA_LISTBASE 4 -#define EVT_DATA_NDOF_MOTION 5 +#define EVT_DATA_GESTURE 1 +#define EVT_DATA_TIMER 2 +#define EVT_DATA_LISTBASE 3 +#define EVT_DATA_NDOF_MOTION 4 /* tablet active, matches GHOST_TTabletMode */ #define EVT_TABLET_NONE 0 |