Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x11_common: handle window dragging in ButtonPress event #13457

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions video/out/x11_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,6 @@ static void release_all_keys(struct vo *vo)

if (x11->no_autorepeat)
mp_input_put_key(x11->input_ctx, MP_INPUT_RELEASE_ALL);
x11->win_drag_button1_down = false;
}

void vo_x11_check_events(struct vo *vo)
Expand Down Expand Up @@ -1288,30 +1287,12 @@ void vo_x11_check_events(struct vo *vo)
release_all_keys(vo);
break;
case MotionNotify:
if (x11->win_drag_button1_down && !x11->fs &&
!mp_input_test_dragging(x11->input_ctx, Event.xmotion.x,
Event.xmotion.y))
{
mp_input_put_key(x11->input_ctx, MP_INPUT_RELEASE_ALL);
XUngrabPointer(x11->display, CurrentTime);

long params[5] = {
Event.xmotion.x_root, Event.xmotion.y_root,
8, // _NET_WM_MOVERESIZE_MOVE
1, // button 1
1, // source indication: normal
};
x11_send_ewmh_msg(x11, "_NET_WM_MOVERESIZE", params);
} else {
mp_input_set_mouse_pos(x11->input_ctx, Event.xmotion.x,
Event.xmotion.y);
}
x11->win_drag_button1_down = false;
mp_input_set_mouse_pos(x11->input_ctx, Event.xmotion.x,
Event.xmotion.y);
break;
case LeaveNotify:
if (Event.xcrossing.mode != NotifyNormal)
break;
x11->win_drag_button1_down = false;
mp_input_put_key(x11->input_ctx, MP_KEY_MOUSE_LEAVE);
break;
case EnterNotify:
Expand All @@ -1322,19 +1303,30 @@ void vo_x11_check_events(struct vo *vo)
case ButtonPress:
if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT)
break;
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = true;
mp_input_put_key(x11->input_ctx,
(MP_MBTN_BASE + Event.xbutton.button - 1) |
get_mods(Event.xbutton.state) | MP_KEY_STATE_DOWN);
long msg[4] = {XEMBED_REQUEST_FOCUS};
vo_x11_xembed_send_message(x11, msg);
if (Event.xbutton.button == 1 && !x11->fs &&
!mp_input_test_dragging(x11->input_ctx, Event.xmotion.x,
Event.xmotion.y))
{
mp_input_put_key(x11->input_ctx, MP_INPUT_RELEASE_ALL);
XUngrabPointer(x11->display, CurrentTime);

long params[5] = {
Event.xmotion.x_root, Event.xmotion.y_root,
8, // _NET_WM_MOVERESIZE_MOVE
1, // button 1
1, // source indication: normal
};
x11_send_ewmh_msg(x11, "_NET_WM_MOVERESIZE", params);
}
break;
case ButtonRelease:
if (Event.xbutton.button - 1 >= MP_KEY_MOUSE_BTN_COUNT)
break;
if (Event.xbutton.button == 1)
x11->win_drag_button1_down = false;
mp_input_put_key(x11->input_ctx,
(MP_MBTN_BASE + Event.xbutton.button - 1) |
get_mods(Event.xbutton.state) | MP_KEY_STATE_UP);
Expand Down
3 changes: 0 additions & 3 deletions video/out/x11_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ struct vo_x11_state {
Atom dnd_requested_action;
Window dnd_src_window;

/* dragging the window */
bool win_drag_button1_down;

Atom icc_profile_property;
};

Expand Down
Loading