(windowless) plugins want to change cursor




11 years ago
2 years ago


(Reporter: otte, Unassigned)


Firefox Tracking Flags

(Not tracked)



(1 attachment)

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
Ever confirmed: true
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.
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.
one note - I haven't tested that patch extensively, but for the popfly mashup creator at (http://www.popfly.com), 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 :)
Are you sure you don't want the ability for plugins to create custom cursors?
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.
This is something that we would do with in Maemo5 microb-engine. Adding Oleg and Doug as CC per Oleg's request.
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 */
Resolving old bugs which are likely not relevant any more, since NPAPI plugins are deprecated.
Closed: 2 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.