diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_window.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 583a11f1244..4f70eeefb76 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -548,6 +548,12 @@ void WM_window_set_dpi(const wmWindow *win) BLF_default_dpi(U.pixelsize * U.dpi); } +static void wm_window_update_eventstate(wmWindow *win) +{ + /* Update mouse position when a window is activated. */ + wm_get_cursor_position(win, &win->eventstate->x, &win->eventstate->y); +} + static void wm_window_ensure_eventstate(wmWindow *win) { if (win->eventstate) { @@ -555,7 +561,7 @@ static void wm_window_ensure_eventstate(wmWindow *win) } win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); - wm_get_cursor_position(win, &win->eventstate->x, &win->eventstate->y); + wm_window_update_eventstate(win); } /* belongs to below */ @@ -703,6 +709,8 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, boo /* happens after fileread */ wm_window_ensure_eventstate(win); + + WM_window_set_dpi(win); } /* add keymap handlers (1 handler for all keys in map!) */ @@ -1207,7 +1215,6 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr case GHOST_kEventWindowActivate: { GHOST_TEventKeyData kdata; wmEvent event; - int wx, wy; const int keymodifier = ((query_qual(SHIFT) ? KM_SHIFT : 0) | (query_qual(CONTROL) ? KM_CTRL : 0) | (query_qual(ALT) ? KM_ALT : 0) | (query_qual(OS) ? KM_OSKEY : 0)); @@ -1292,10 +1299,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr win->eventstate->keymodifier = 0; /* entering window, update mouse pos. but no event */ - wm_get_cursor_position(win, &wx, &wy); - - win->eventstate->x = wx; - win->eventstate->y = wy; + wm_window_update_eventstate(win); win->addmousemove = 1; /* enables highlighted buttons */ @@ -1456,12 +1460,9 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr case GHOST_kEventDraggingDropDone: { wmEvent event; GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt); - int wx, wy; /* entering window, update mouse pos */ - wm_get_cursor_position(win, &wx, &wy); - win->eventstate->x = wx; - win->eventstate->y = wy; + wm_window_update_eventstate(win); wm_event_init_from_window(win, &event); /* copy last state, like mouse coords */ @@ -1543,9 +1544,21 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr wm_event_add_ghostevent(wm, win, type, data); break; } - default: + case GHOST_kEventButtonDown: + case GHOST_kEventButtonUp: { + if (win->active == 0) { + /* Entering window, update cursor and tablet state. + * (ghost sends win-activate *after* the mouse-click in window!) */ + wm_window_update_eventstate(win); + } + + wm_event_add_ghostevent(wm, win, type, data); + break; + } + default: { wm_event_add_ghostevent(wm, win, type, data); break; + } } } return 1; @@ -2099,21 +2112,6 @@ void WM_cursor_compatible_xy(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 wm_pressure_curve(td->Pressure); - } - else { - return -1.0f; - } -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -2190,8 +2188,8 @@ void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect) } } - BLI_assert(screen_rect.xmin < screen_rect.xmax); - BLI_assert(screen_rect.ymin < screen_rect.ymax); + BLI_assert(BLI_rcti_is_valid(&screen_rect)); + *r_rect = screen_rect; } |