PDA

View Full Version : Handling mouse events in Qt WebKit



yakin
24th August 2010, 08:41
Hi,
in an application I use QtWebKit to show flash contents. If you press the right mouse button over a Adobe flash movie, the flash settings menu will appear.
Is there a way to catch and drop or delegate this mouse event so that this menu will not be displayed anymore?
Any ideas?
Thanks Yakin

hvitual
24th August 2010, 09:44
You should call Adobe to solve this problem.

yakin
24th August 2010, 10:45
No, that would not lead to a solution at all.:(
Let me reword my question:
Is it possible for any kind of plugin in QtWebkit (Flash, or an SVG Viewer Plugin for ex.) to fetch and drop the right click mouse event? The QWebView should "eat" those events and don't delegate them to the underlying plugin.

hvitual
25th August 2010, 02:21
Netscape plugins operate in two modes:

* Windowed mode - The plugin has a native window handle of it's own. This means that the plugin has complete control over mouse, keyboard, paint events. It can do whatever it wants, whenever it wants.
* Windowless mode - The plugin does not have a native window. Instead it relies on the browser to tell it where to paint and expects the browser to provide it with keyboard/mouse events. See mozilla site for more information.

Flash has a wmode parameter that triggers the above modes. The default is Windowed mode. When wmode is 'transparent' or 'opaque', flash requests windowless mode. Note that the mode used ultimately resides with the plugin (i.e the browser cannot force a mode).

Read more http://trac.webkit.org/wiki/QtWebKitPlugins


If flash plugin is embeded to page in Window Mode, you cann't interact with it.
If in Windowless Mode, flash plugin is similar a element in web page, you can interact with it. But I think you can't do anything if no help from inside flash coding.

yakin
25th August 2010, 14:18
Thanks hvitual. But windowsless mode did not work. The QWebView will not show the plugin in this mode:(

I found another solution to "steal" the mouse events.

First I find the widget which holds the plugin in an QWebView. Then I register a slot to the signal "clientIsEmbedded()" (Because we have to wait for the plugin to embed).


void WebView::page_loaded(bool ok)
{
QList<QX11EmbedContainer*> l
= this->findChildren<QX11EmbedContainer*>();

foreach(QX11EmbedContainer* x11cont, l) {
connect(x11cont, SIGNAL(clientIsEmbedded()), this,
SLOT(client_embedded()));
}
} // WebView::page_loaded(...)


In the slot "client_embedded()" I will use the XLib function "XGrabButton" to steal mouse button 3 (right button). All right click events will now be processed by my qt application. Flash will not show the context menu anymore:)

void WebView::client_embedded()
{
QX11EmbedContainer* x11cont = static_cast<QX11EmbedContainer*>(sender());

XGrabButton(QX11Info::display(), 3, AnyModifier,
x11cont->clientWinId(),
false, ButtonPressMask, GrabModeAsync, GrabModeAsync,
0L, 0L);
}

The next question is: How to do so under Windows? :(

tbscope
25th August 2010, 14:33
The next question is: How to do so under Windows? :(

http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx

mjstrike
21st April 2011, 06:44
Thanks hvitual. But windowsless mode did not work. The QWebView will not show the plugin in this mode:(

I found another solution to "steal" the mouse events.

First I find the widget which holds the plugin in an QWebView. Then I register a slot to the signal "clientIsEmbedded()" (Because we have to wait for the plugin to embed).


void WebView::page_loaded(bool ok)
{
QList<QX11EmbedContainer*> l
= this->findChildren<QX11EmbedContainer*>();

foreach(QX11EmbedContainer* x11cont, l) {
connect(x11cont, SIGNAL(clientIsEmbedded()), this,
SLOT(client_embedded()));
}
} // WebView::page_loaded(...)


In the slot "client_embedded()" I will use the XLib function "XGrabButton" to steal mouse button 3 (right button). All right click events will now be processed by my qt application. Flash will not show the context menu anymore:)

void WebView::client_embedded()
{
QX11EmbedContainer* x11cont = static_cast<QX11EmbedContainer*>(sender());

XGrabButton(QX11Info::display(), 3, AnyModifier,
x11cont->clientWinId(),
false, ButtonPressMask, GrabModeAsync, GrabModeAsync,
0L, 0L);
}

The next question is: How to do so under Windows? :(

Great job man,this work like a charm