diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_system.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d90eab6f94f..7d92dbc4cf2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -127,12 +127,6 @@ wmEvent *wm_event_add_ex(wmWindow *win, update_tablet_data(win, event); - if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - /* We could have a preference to support relative tablet motion (we can't detect that). */ - event->is_motion_absolute = ((event->tablet_data != NULL) && - (event->tablet_data->Active != GHOST_kTabletModeNone)); - } - if (event_to_add_after == NULL) { BLI_addtail(&win->queue, event); } @@ -176,10 +170,6 @@ void wm_event_free(wmEvent *event) } } - if (event->tablet_data) { - MEM_freeN((void *)event->tablet_data); - } - MEM_freeN(event); } @@ -194,9 +184,6 @@ void wm_event_free_all(wmWindow *win) void wm_event_init_from_window(wmWindow *win, wmEvent *event) { - /* make sure we don't copy any owned pointers */ - BLI_assert(win->eventstate->tablet_data == NULL); - *event = *(win->eventstate); } @@ -1793,19 +1780,16 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi) if (kmitype != KM_ANY) { if (ELEM(kmitype, TABLET_STYLUS, TABLET_ERASER)) { - const wmTabletData *wmtab = winevent->tablet_data; + const wmTabletData *wmtab = &winevent->tablet; - if (wmtab == NULL) { - return false; - } - else if (winevent->type != LEFTMOUSE) { + if (winevent->type != LEFTMOUSE) { /* tablet events can occur on hover + keypress */ return false; } - else if ((kmitype == TABLET_STYLUS) && (wmtab->Active != EVT_TABLET_STYLUS)) { + else if ((kmitype == TABLET_STYLUS) && (wmtab->active != EVT_TABLET_STYLUS)) { return false; } - else if ((kmitype == TABLET_ERASER) && (wmtab->Active != EVT_TABLET_ERASER)) { + else if ((kmitype == TABLET_ERASER) && (wmtab->active != EVT_TABLET_ERASER)) { return false; } } @@ -4107,21 +4091,24 @@ static void wm_eventemulation(wmEvent *event, bool test_only) static void update_tablet_data(wmWindow *win, wmEvent *event) { const GHOST_TabletData *td = GHOST_GetTabletData(win->ghostwin); + wmTabletData *wmtab = &event->tablet; /* if there's tablet data from an active tablet device then add it */ if ((td != NULL) && td->Active != GHOST_kTabletModeNone) { - struct wmTabletData *wmtab = MEM_mallocN(sizeof(wmTabletData), "customdata tablet"); - - wmtab->Active = (int)td->Active; - wmtab->Pressure = wm_pressure_curve(td->Pressure); - wmtab->Xtilt = td->Xtilt; - wmtab->Ytilt = td->Ytilt; - - event->tablet_data = wmtab; - // printf("%s: using tablet %.5f\n", __func__, wmtab->Pressure); + wmtab->active = (int)td->Active; + wmtab->pressure = wm_pressure_curve(td->Pressure); + wmtab->x_tilt = td->Xtilt; + wmtab->y_tilt = td->Ytilt; + /* We could have a preference to support relative tablet motion (we can't detect that). */ + wmtab->is_motion_absolute = ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE); + // printf("%s: using tablet %.5f\n", __func__, wmtab->pressure); } else { - event->tablet_data = NULL; + wmtab->active = EVT_TABLET_NONE; + wmtab->pressure = 1.0f; + wmtab->x_tilt = 0.0f; + wmtab->y_tilt = 0.0f; + wmtab->is_motion_absolute = false; // printf("%s: not using tablet\n", __func__); } } @@ -4280,7 +4267,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void { wmEvent *event_new = wm_event_add_mousemove(win, &event); copy_v2_v2_int(&evt->x, &event_new->x); - evt->is_motion_absolute = event_new->is_motion_absolute; + evt->tablet.is_motion_absolute = event_new->tablet.is_motion_absolute; } /* also add to other window if event is there, this makes overdraws disappear nicely */ @@ -4298,7 +4285,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void { wmEvent *event_new = wm_event_add_mousemove(owin, &oevent); copy_v2_v2_int(&oevt->x, &event_new->x); - oevt->is_motion_absolute = event_new->is_motion_absolute; + oevt->tablet.is_motion_absolute = event_new->tablet.is_motion_absolute; } } |