Last Comment Bug 430451 - (windowless) plugins want to change cursor
: (windowless) plugins want to change cursor
Status: NEW
Product: Core
Classification: Components
Component: Plug-ins (show other bugs)
: unspecified
: x86 Linux
-- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Benjamin Smedberg [:bsmedberg]
Depends on:
  Show dependency treegraph
Reported: 2008-04-23 05:47 PDT by Benjamin Otte
Modified: 2009-10-22 05:50 PDT (History)
7 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

adds NPPVcursor functionality to npapi (10.47 KB, patch)
2008-10-14 15:05 PDT, Chris Toshok
no flags Details | Diff | Splinter Review

Description User image Benjamin Otte 2008-04-23 05:47:14 PDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9b4) Gecko Epiphany/2.22
Build Identifier: 

Currently there is no way for windowless plugins to change the mouse cursor. This is important for Flash, as there's clickable, text-editable and normal areas inside a Flash file. Plus, there's the way to make the cursor invisible.

On Mac and Windows this is possible, the documentation even contains hints on how to do it. On UNIX this has been done by changing the cursor of the plugin's own window.

However, with windowless mode, the plugin does not get at the X window that is used to render the contents.

Someone suggested using the result from NPN_GetValue with NPNVnetscapeWindow. I tried that, but no cursor change happened.

Reproducible: Always
Comment 1 User image rajesh 2008-04-23 23:08:55 PDT
Comment 2 User image Chris Toshok 2008-07-01 20:00:25 PDT
Just adding some information so possible state isn't lost :)

The problem with the NPNVnetscapeWindow approach is that firefox is calling XDefineCursor on a different window ID.  Presumably it's more of a viewport window (for the tab, maybe?), but it's clearly a descendant of the NPNVnetscapeWindow value, which is why it doesn't work.

karlt and I were on irc today, and he suggested a possible solution, which would add a NPNVcursor variable.  Plugins would set that to (hopefully, in the case of unix/x11) the XCursor, and firefox would in turn set the cursor on the same window the DOM stuff sets it on.
Comment 3 User image Chris Toshok 2008-10-14 15:05:56 PDT
Created attachment 343122 [details] [diff] [review]
adds NPPVcursor functionality to npapi

turns out setting the NPPVcursor variable to a native cursor would be way, way too involved.  So instead I added an enum (NPCursor) which essentially maps to the NS_STYLE_CURSOR_* values (except I took out the _MOZ_ ones..  probably should instead limit NPCursor to the ones defined in css.  right?)

One remaining problem with this patch is that the plugin will likely change the cursor based on a motion event, which happens *after* the nsObjectFrame::GetCursor call is made.  roc suggested moving nsEventManagerState::UpdateCursor from PreHandleEvent to PostHandleEvent in order to fix this, but I haven't tried it yet.
Comment 4 User image Chris Toshok 2008-10-14 15:07:37 PDT
one note - I haven't tested that patch extensively, but for the popfly mashup creator at (, they set the cursor to none and do pointer tracking with an element in the xaml interface.  Before the change, I was seeing both an arrow (the mouse pointer) and their custom cursor.  After the change, just their custom cursor.  So I know NPCursorNone is working, at least :)
Comment 5 User image Robert O'Callahan (:roc) (email my personal email if necessary) 2008-10-14 15:54:58 PDT
Are you sure you don't want the ability for plugins to create custom cursors?
Comment 6 User image Chris Toshok 2008-10-14 17:09:21 PDT
Oh I definitely do - in the original proposal I sent to plugin-futures I mentioned two properties:  NPPVcssCursor and NPPVtoolkitCursor.  It just looked from the code that the toolkitCursor was going to be non-trivial to implement, and NPPVcssCursor (which I called NPPVcursor in the patch) was pretty easy to hook up using the existing code.
Comment 7 User image Jaakko Kiviluoto 2009-10-15 03:57:01 PDT
This is something that we would do with in Maemo5 microb-engine. Adding Oleg and Doug as CC per Oleg's request.
Comment 8 User image timeless 2009-10-22 05:50:32 PDT
Comment on attachment 343122 [details] [diff] [review]
adds NPPVcursor functionality to npapi

>diff -r 3f4d21c3af97 layout/generic/nsObjectFrame.cpp
>+nsObjectFrame::GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor)
>+#if MOZ_X11
>+  if (windowless) {

Gecko style is:
if (!windowless)

(return early) ...

>+    default:
>+      return NS_ERROR_FAILURE;

>+    return NS_OK;
>+  }
>+  else {
>+  }
>+  /* fail on any requests to get a cursor from us because plugins set their own! see bug 118877 */

Note You need to log in before you can comment on or make changes to this bug.