Cleanup: move check_drag & check_click out of wmEvent
These variables track the wmWindow.event_queue state, however they were used in a way that wasn't correct. - check_drag & check_click from wmWindow.eventstate were used to track the click/drag status of events handled in wmWindow.event_queue. - Event's in the queue read from wmEvent.check_drag. - Once a drag action was detected, wmWindow.eventstate.check_drag was disabled. Disabling drag in the event state would not change the drag state for values already in the event queue. Simplify logic by moving these values into the window, so there is one place these variables are tracked.
This commit is contained in:
@@ -251,13 +251,14 @@ typedef struct wmWindow {
|
|||||||
|
|
||||||
struct bScreen *screen DNA_DEPRECATED;
|
struct bScreen *screen DNA_DEPRECATED;
|
||||||
|
|
||||||
|
/** Winid also in screens, is for retrieving this window after read. */
|
||||||
|
int winid;
|
||||||
/** Window coords. */
|
/** Window coords. */
|
||||||
short posx, posy, sizex, sizey;
|
short posx, posy, sizex, sizey;
|
||||||
/** Borderless, full. */
|
/** Borderless, full. */
|
||||||
char windowstate;
|
char windowstate;
|
||||||
/** Set to 1 if an active window, for quick rejects. */
|
/** Set to 1 if an active window, for quick rejects. */
|
||||||
char active;
|
char active;
|
||||||
char _pad0[4];
|
|
||||||
/** Current mouse cursor type. */
|
/** Current mouse cursor type. */
|
||||||
short cursor;
|
short cursor;
|
||||||
/** Previous cursor when setting modal one. */
|
/** Previous cursor when setting modal one. */
|
||||||
@@ -271,8 +272,14 @@ typedef struct wmWindow {
|
|||||||
char addmousemove;
|
char addmousemove;
|
||||||
char tag_cursor_refresh;
|
char tag_cursor_refresh;
|
||||||
|
|
||||||
/** Winid also in screens, is for retrieving this window after read. */
|
/* Track the state of the event queue,
|
||||||
int winid;
|
* these store the state that needs to be kept between handling events in the queue. */
|
||||||
|
/** Enable when #KM_PRESS events are not handled (keyboard/mouse-buttons only). */
|
||||||
|
char event_queue_check_click;
|
||||||
|
/** Enable when #KM_PRESS events are not handled (keyboard/mouse-buttons only). */
|
||||||
|
char event_queue_check_drag;
|
||||||
|
|
||||||
|
char _pad0[2];
|
||||||
|
|
||||||
/** Internal, lock pie creation from this event until released. */
|
/** Internal, lock pie creation from this event until released. */
|
||||||
short pie_event_type_lock;
|
short pie_event_type_lock;
|
||||||
|
|||||||
@@ -612,10 +612,6 @@ typedef struct wmEvent {
|
|||||||
/** Raw-key modifier (allow using any key as a modifier). */
|
/** Raw-key modifier (allow using any key as a modifier). */
|
||||||
short keymodifier;
|
short keymodifier;
|
||||||
|
|
||||||
/** Set in case a #KM_PRESS went by unhandled. */
|
|
||||||
char check_click;
|
|
||||||
char check_drag;
|
|
||||||
|
|
||||||
/** Tablet info, available for mouse move and button events. */
|
/** Tablet info, available for mouse move and button events. */
|
||||||
wmTabletData tablet;
|
wmTabletData tablet;
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,8 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
|
|||||||
win->modalcursor = 0;
|
win->modalcursor = 0;
|
||||||
win->grabcursor = 0;
|
win->grabcursor = 0;
|
||||||
win->addmousemove = true;
|
win->addmousemove = true;
|
||||||
|
win->event_queue_check_click = 0;
|
||||||
|
win->event_queue_check_drag = 0;
|
||||||
BLO_read_data_address(reader, &win->stereo3d_format);
|
BLO_read_data_address(reader, &win->stereo3d_format);
|
||||||
|
|
||||||
/* Multi-view always fallback to anaglyph at file opening
|
/* Multi-view always fallback to anaglyph at file opening
|
||||||
|
|||||||
@@ -2960,8 +2960,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||||||
|
|
||||||
/* Test for CLICK_DRAG events. */
|
/* Test for CLICK_DRAG events. */
|
||||||
if (wm_action_not_handled(action)) {
|
if (wm_action_not_handled(action)) {
|
||||||
if (event->check_drag) {
|
wmWindow *win = CTX_wm_window(C);
|
||||||
wmWindow *win = CTX_wm_window(C);
|
if (win->event_queue_check_drag) {
|
||||||
if (WM_event_drag_test(event, &event->prevclickx)) {
|
if (WM_event_drag_test(event, &event->prevclickx)) {
|
||||||
int x = event->x;
|
int x = event->x;
|
||||||
int y = event->y;
|
int y = event->y;
|
||||||
@@ -2982,15 +2982,18 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||||||
event->x = x;
|
event->x = x;
|
||||||
event->y = y;
|
event->y = y;
|
||||||
|
|
||||||
win->eventstate->check_click = false;
|
win->event_queue_check_click = false;
|
||||||
win->eventstate->check_drag = false;
|
if (!wm_action_not_handled(action)) {
|
||||||
|
/* Only disable when handled as other handlers may use this drag event. */
|
||||||
|
win->event_queue_check_drag = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
if (win) {
|
if (win) {
|
||||||
win->eventstate->check_drag = false;
|
win->event_queue_check_drag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3006,11 +3009,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||||||
|
|
||||||
if (win != NULL) {
|
if (win != NULL) {
|
||||||
if (event->val == KM_PRESS) {
|
if (event->val == KM_PRESS) {
|
||||||
win->eventstate->check_click = true;
|
if (event->prevval != KM_PRESS) {
|
||||||
win->eventstate->check_drag = true;
|
win->event_queue_check_click = true;
|
||||||
|
win->event_queue_check_drag = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (event->val == KM_RELEASE) {
|
else if (event->val == KM_RELEASE) {
|
||||||
win->eventstate->check_drag = false;
|
win->event_queue_check_drag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3018,10 +3023,10 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||||||
|
|
||||||
if (event->val == KM_RELEASE) {
|
if (event->val == KM_RELEASE) {
|
||||||
if (event->prevval == KM_PRESS) {
|
if (event->prevval == KM_PRESS) {
|
||||||
if (win->eventstate->check_click == true) {
|
if (win->event_queue_check_click == true) {
|
||||||
if (WM_event_drag_test(event, &event->prevclickx)) {
|
if (WM_event_drag_test(event, &event->prevclickx)) {
|
||||||
win->eventstate->check_click = 0;
|
win->event_queue_check_click = false;
|
||||||
win->eventstate->check_drag = 0;
|
win->event_queue_check_drag = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Position is where the actual click happens, for more
|
/* Position is where the actual click happens, for more
|
||||||
@@ -3059,8 +3064,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||||||
else {
|
else {
|
||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
if (win) {
|
if (win) {
|
||||||
win->eventstate->check_click = 0;
|
win->event_queue_check_click = false;
|
||||||
win->eventstate->check_drag = 0;
|
win->event_queue_check_drag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3074,7 +3079,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
if (win) {
|
if (win) {
|
||||||
if (ISKEYMODIFIER(event->prevtype)) {
|
if (ISKEYMODIFIER(event->prevtype)) {
|
||||||
win->eventstate->check_click = 0;
|
win->event_queue_check_click = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3497,7 +3502,7 @@ void wm_event_do_handlers(bContext *C)
|
|||||||
* press in tool keymap can override click in editor keymap.*/
|
* press in tool keymap can override click in editor keymap.*/
|
||||||
if (ISMOUSE_BUTTON(event->type) && event->val == KM_PRESS &&
|
if (ISMOUSE_BUTTON(event->type) && event->val == KM_PRESS &&
|
||||||
!wm_action_not_handled(action)) {
|
!wm_action_not_handled(action)) {
|
||||||
win->eventstate->check_click = false;
|
win->event_queue_check_click = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update previous mouse position for following events to use. */
|
/* Update previous mouse position for following events to use. */
|
||||||
|
|||||||
Reference in New Issue
Block a user