Capturing mouse clicks

This forum is about all development around libVLC.
heng
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2010 08:09

Capturing mouse clicks

Postby heng » 16 Nov 2010 17:33

Hi,

I'm trying to capture a mouse click/dblclick while playing a video file. My goal is, for example, to maximize the display window when the user double click on the video screen (btw "libvlc_toggle_fullscreen" no longer work with libvlc v1.1.x).

How can I do that? I thought about using the "libvlc_event_attach" function but I don't see any mouse event types in "libvlc_event_e".

Please advise.

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: Capturing mouse clicks

Postby mangokm40 » 17 Nov 2010 19:49

Give details about your development environment. Also, use the search function. You are not the first to ask this question.

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: Capturing mouse clicks

Postby XilasZ » 17 Nov 2010 20:38

There is libvlc_video_set_mouse_input (new in v1.1), to enable/disable mouse handling by vlc.

But i think the best way to handle mouse/key input is to handle them yourself in your app. Embed the video frame in your GUI and handle mouse events from the GUI, not vlc.

rogerdpack
Big Cone-huna
Big Cone-huna
Posts: 574
Joined: 19 Jul 2008 23:48
Operating System: windows

Re: Capturing mouse clicks

Postby rogerdpack » 17 Nov 2010 23:18

viewtopic.php?f=32&t=73100 might help (but I think XilasZ is right there...)

heng
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2010 08:09

Re: Capturing mouse clicks

Postby heng » 18 Nov 2010 08:08

I AM using the "libvlc_video_set_mouse_input" but I don't recieve any doubleclick events in the containing parent window (I tried both enable/disable mouse input). If I replace the VLC control with an image control (ATL CImage) I get those events easily. Any idea why is that?

I am using libvlc 1.1.5 in VS2010 with MFC under Windows 7.

Is there a way to make libvlc invoke my callback when mouse click happen, like I am currently doing with the "libvlc_event_attach" function for capturing "libvlc_MediaPlayerTimeChanged" events?

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: Capturing mouse clicks

Postby XilasZ » 18 Nov 2010 09:10

it's normal, libvlc_video_set_mouse_input(true) will tell libvlc that it can capture mouse and react to it, but it won't interact with your program.
The issue is that libvlc capture the mouse and keep it for itself, so your app won't see any mouse activity.
try to use libvlc_video_set_mouse_input(false), see if it allows your program to capture the mouse.

A little tips that i used to do that in wpf 3.5 (before libvlc_video_set_mouse_input was added) : i disabled the host control which contains the vlc frame, so mouse event will never reach vlc, allowing me to handle the mouse my way. But it might be related to the necessary mix between wpf and winforms (as vlc need a handle to the display surface, which doesn't exist in wpf).

lanamelach
Blank Cone
Blank Cone
Posts: 31
Joined: 18 Nov 2010 13:22

Re: Capturing mouse clicks

Postby lanamelach » 18 Nov 2010 13:35

Have the same question. You said "Embed the video frame in your GUI and handle mouse events from the GUI, not vlc". What does it mean? I am rendering video to Gtk::DrawingArea and it doesn't receive any messages the same as other parent controls of that DrawingArea. Could someone explain how to receive click messages from vlc?
No milk today

rogerdpack
Big Cone-huna
Big Cone-huna
Posts: 574
Joined: 19 Jul 2008 23:48
Operating System: windows

Re: Capturing mouse clicks

Postby rogerdpack » 18 Nov 2010 15:21

the above links and discussion might help...

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Capturing mouse clicks

Postby Rémi Denis-Courmont » 18 Nov 2010 18:11

Have the same question. You said "Embed the video frame in your GUI and handle mouse events from the GUI, not vlc". What does it mean?
It means it's best to disable LibVLC keyboard and mouse events with libvlc_set_key_input(false) and libvlc_set_mouse_input(false). Then the X server will pass the events to the parent widget that VLC is drawing to, which belonds to your application.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

lanamelach
Blank Cone
Blank Cone
Posts: 31
Joined: 18 Nov 2010 13:22

Re: Capturing mouse clicks

Postby lanamelach » 06 Sep 2011 14:49

But if I use libvlc_set_mouse_input(false) I won't be able to click on DVD menu. I think there must be some way to receive mouse events before VLC eats them. Why not to provide a function that allows to install a user callback to filter/preprocess events?
No milk today

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Capturing mouse clicks

Postby Rémi Denis-Courmont » 06 Sep 2011 15:35

This is not easy to implement. Besides, I believe there is no way to determine whether an area of the video is "active" in some way, or not.

So if you want to catch mouse clicks, for instance to pause the video à la Adobe Flash, then forget DVD menus... The two are more or less mutually incompatible. That is why VLC media player does not use the mouse like Adobe Flash in the first place.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

lanamelach
Blank Cone
Blank Cone
Posts: 31
Joined: 18 Nov 2010 13:22

Re: Capturing mouse clicks

Postby lanamelach » 06 Sep 2011 16:00

This is not easy to implement.
Really? I don't know how it is implemented, but if you know that a user clicked on the window why not to call a filter function before doing what it now does? e.g.:

Code: Select all

void vlc_mouse_receiving_function(MouseEventInfo *info) { if (userCallback(info)) eatMouse(); // use mouse event here else ; // do Nothing }
Besides, I believe there is no way to determine whether an area of the video is "active" in some way, or not.
It is up to a user to determine what is active or not. I want to show popup menu for video area for right click and toggle full screen on left button double click. By the way, VLC player itself does it and DVD menu works there.
No milk today

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Capturing mouse clicks

Postby Rémi Denis-Courmont » 06 Sep 2011 16:11

This is not easy to implement.
Really? I don't know how it is implemented,
First it depends on the platform. And then it is typically from the video rendering thread.

But if you think it's easy, you're welcome to propose a patch.
Besides, I believe there is no way to determine whether an area of the video is "active" in some way, or not.
It is up to a user to determine what is active or not. I want to show popup menu for video area for right click and toggle full screen on left button double click. By the way, VLC player itself does it and DVD menu works there.
VLC does not filter events. It just dispatches them to both the DVD menu VM and the UI. It so happens that the UI handling was designed to not conflict with DVD menus: a single left click has no effects in the VLC UI.

If your application reacts on left mouse clicks, then DVD menus will not work anyhow.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests