Fix mouse click event using current mouse co-ords rather than the co-ords at the time of the click
This commit is contained in:
parent
92f428b6d1
commit
f61b8608de
@ -424,6 +424,7 @@ typedef struct PendingClick {
|
||||
int button, count, modifiers;
|
||||
bool grabbed;
|
||||
monotonic_t at;
|
||||
MousePosition mouse_pos;
|
||||
} PendingClick;
|
||||
|
||||
static void
|
||||
@ -435,7 +436,10 @@ send_pending_click_to_window(Window *w, void *data) {
|
||||
ClickQueue *q = &w->click_queues[pc->button];
|
||||
// only send click if no presses have happened since the release that triggered the click
|
||||
if (q->length && q->clicks[q->length - 1].at <= pc->at) {
|
||||
MousePosition current_pos = w->mouse_pos;
|
||||
w->mouse_pos = pc->mouse_pos;
|
||||
dispatch_mouse_event(w, pc->button, pc->count, pc->modifiers, pc->grabbed);
|
||||
w->mouse_pos = current_pos;
|
||||
}
|
||||
}
|
||||
|
||||
@ -447,6 +451,7 @@ dispatch_possible_click(Window *w, int button, int modifiers) {
|
||||
PendingClick *pc = calloc(sizeof(PendingClick), 1);
|
||||
if (pc) {
|
||||
pc->window_id = w->id;
|
||||
pc->mouse_pos = w->mouse_pos;
|
||||
pc->at = monotonic();
|
||||
pc->button = button;
|
||||
pc->count = count == 2 ? -3 : -2;
|
||||
|
||||
@ -101,6 +101,12 @@ typedef struct {
|
||||
unsigned int length;
|
||||
} ClickQueue;
|
||||
|
||||
typedef struct MousePosition {
|
||||
unsigned int cell_x, cell_y;
|
||||
double x, y;
|
||||
bool in_left_half_of_cell;
|
||||
} MousePosition;
|
||||
|
||||
typedef struct {
|
||||
id_type id;
|
||||
bool visible, cursor_visible_at_last_render;
|
||||
@ -108,11 +114,7 @@ typedef struct {
|
||||
CursorShape last_cursor_shape;
|
||||
PyObject *title;
|
||||
ScreenRenderData render_data;
|
||||
struct {
|
||||
unsigned int cell_x, cell_y;
|
||||
double x, y;
|
||||
bool in_left_half_of_cell;
|
||||
} mouse_pos;
|
||||
MousePosition mouse_pos;
|
||||
struct {
|
||||
unsigned int left, top, right, bottom;
|
||||
} padding;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user