mpv-player / mpv-player/mpv

Allow libmpv frontends for better window-dragging implementation

Open
#12,782 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

meta:feature-request
Dominant language
C
Stars
37k
Forks
3.5k
Avg merge
1d 10h
Merged PRs (30d)
22

Description

For a libmpv frontend to fully support 3rd party OSCs like uosc and support window-dragging, it's necessary to know if the mouse is inside an OSC menu, in this case dragging is undesired.

I couldn't find a way to get this information, so I use a workaround, I simply do no dragging when the mouse is near a window border because OSC menus are usually found near window borders.

If the menu is in the middle, like the context menu of uosc, dragging is still performed. I didn't know uosc is very popular and doesn't fully work in mpv.net until a recent bug report, it works now after delaying the start of the drag operation for a few pixels.

So currently there are two minor defects in my frontend, dragging works only in the middle of the window, not near borders, and if there is a menu in the middle of the window dragging is still performed.

I looked at the mpv code today and what I found is that it appears to hit test here:

static bool test_mouse(struct input_ctx *ictx, int x, int y, int rej_flags)
{
    input_lock(ictx);
    bool res = false;
    for (int i = 0; i < ictx->num_active_sections; i++) {
        struct active_section *as = &ictx->active_sections[i];
        if (as->flags & rej_flags)
            continue;
        struct cmd_bind_section *s = get_bind_section(ictx, bstr0(as->name));
        if (s->mouse_area_set && test_rect(&s->mouse_area, x, y)) {
            res = true;
            break;
        }
    }
    input_unlock(ictx);
    return res;
}

Now if there was a hit test function either in client.h or as input command, it would solve my problem, or maybe there is already something I could use, or something simpler.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the test_mouse function shown in the issue and inspect client.h for an existing frontend-facing hit-test entry point. Determine how an OSC menu's mouse area could be exposed to libmpv frontends, then verify that a frontend can distinguish menu interaction from window dragging, including menus near borders and in the window center.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
api, desktop
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.