summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-02-26 18:49:03 -0500
committersfan5 <sfan5@live.de>2024-03-01 18:25:12 +0100
commit14c5da6f502ff88c8e437858ec2787e218d0587f (patch)
tree1e384ad51e6e51ef55f27bef759a0378ab6ee333
parent6eedf9b1e94ffd6a0377fd4f073fd399a7093efb (diff)
downloadmpv-14c5da6f502ff88c8e437858ec2787e218d0587f.tar.bz2
mpv-14c5da6f502ff88c8e437858ec2787e218d0587f.tar.xz
w32_common: implement VOCTRL_BEGIN_DRAGGING
This allows begin-vo-dragging command to initialize a vo dragging request for win32. Also set dragging to release all keys like for other platforms. The hard-coded left mouse button down trigger is scheduled to be removed in a later commit.
-rw-r--r--video/out/w32_common.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index cf807c0136..49a15b4a78 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -472,29 +472,35 @@ static bool handle_char(struct vo_w32_state *w32, WPARAM wc, bool decode)
return true;
}
+static void begin_dragging(struct vo_w32_state *w32)
+{
+ if (mp_input_test_dragging(w32->input_ctx, w32->mouse_x, w32->mouse_y))
+ return;
+ // Window dragging hack
+ ReleaseCapture();
+ // The dragging model loop is entered at SendMessage() here.
+ // Unfortunately, the w32->current_fs value is stale because the
+ // input is handled in a different thread, and we cannot wait for
+ // an up-to-date value before entering the model loop if dragging
+ // needs to be kept resonsive.
+ // Workaround this by intercepting the loop in the WM_MOVING message,
+ // where the up-to-date value is available.
+ SystemParametersInfoW(SPI_GETWINARRANGING, 0, &w32->win_arranging, 0);
+ w32->dragging = true;
+ SendMessage(w32->window, WM_NCLBUTTONDOWN, HTCAPTION, 0);
+ w32->dragging = false;
+ SystemParametersInfoW(SPI_SETWINARRANGING, w32->win_arranging, 0, 0);
+
+ mp_input_put_key(w32->input_ctx, MP_INPUT_RELEASE_ALL);
+}
+
static bool handle_mouse_down(struct vo_w32_state *w32, int btn, int x, int y)
{
btn |= mod_state(w32);
mp_input_put_key(w32->input_ctx, btn | MP_KEY_STATE_DOWN);
- if (btn == MP_MBTN_LEFT && !mp_input_test_dragging(w32->input_ctx, x, y)) {
- // Window dragging hack
- ReleaseCapture();
- // The dragging model loop is entered at SendMessage() here.
- // Unfortunately, the w32->current_fs value is stale because the
- // input is handled in a different thread, and we cannot wait for
- // an up-to-date value before entering the model loop if dragging
- // needs to be kept resonsive.
- // Workaround this by intercepting the loop in the WM_MOVING message,
- // where the up-to-date value is available.
- SystemParametersInfoW(SPI_GETWINARRANGING, 0, &w32->win_arranging, 0);
- w32->dragging = true;
- SendMessage(w32->window, WM_NCLBUTTONDOWN, HTCAPTION, 0);
- w32->dragging = false;
- SystemParametersInfoW(SPI_SETWINARRANGING, w32->win_arranging, 0, 0);
-
- mp_input_put_key(w32->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP);
-
+ if (btn == MP_MBTN_LEFT) {
+ begin_dragging(w32);
// Indicate the message was handled, so DefWindowProc won't be called
return true;
}
@@ -2164,6 +2170,9 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
case VOCTRL_GET_FOCUSED:
*(bool *)arg = w32->focused;
return VO_TRUE;
+ case VOCTRL_BEGIN_DRAGGING:
+ begin_dragging(w32);
+ return VO_TRUE;
}
return VO_NOTIMPL;
}