Closed Bug 68756 Opened 24 years ago Closed 24 years ago

ObjectFrame needs nsIDOMFocusListener for Mac keyboard events in Shockwave

Categories

(Core Graveyard :: Plug-ins, defect, P1)

PowerPC
All
defect

Tracking

(Not tracked)

VERIFIED FIXED
mozilla0.9

People

(Reporter: grandma, Assigned: peterlubczynski-bugs)

References

()

Details

(Keywords: shockwave, Whiteboard: need4embd-0.9 [fix-in-hand])

Attachments

(4 files)

NPP_HandleEvent() is now receiving keyDown event's, but NS 6.01 is not sending getFocusEvent / loseFocusEvent, so Shockwave ignores the keyDown's. You need to invoke NPP_HandleEvent() with (macEvent->what = getFocusEvent) when you are giving the plugin keyboard focus, and (macEvent->what = loseFocusEvent) when you are taking it away. Shockwave polls the keyboard (so twitch games are possible), so it limits keyboard events to when there is focus to prevent someone from writing a Shockwave movie which captures keyboard events while the focus is not on the plugin (a security risk). Most plugins aren't this paranoid, so they will work with NS6.01 (as it is sending keyDown events). This is not the same bug as 58957, although the fix for it is probably a good place to look for where to add the calls.
Peter, is this a problem with just NS 6.01, or also current Mozilla builds. Also, is this a Mac-only problem or a problem on Windows/Linux as well?
Boris, this is a mac only problem (the Platform was set to indicate this, so I did not wish to be redundant by adding it to the comments) ... NPP_HandleEvents () is not used on Windows, and there is no linux player for Shockwave.
-->peterl
Assignee: av → peterlubczynski
Status: UNCONFIRMED → NEW
Ever confirmed: true
Chris, There still seems to be a small focus problem. I set a breakpoint in nsObjectFrame::GUItoMacEvent() where the switch catches the getFocus and lostFocus events, but they are never being called. Does the ObjectFrame need to be a "focus listener" just as you make it a key and mouse listener? Apparently, it is vital for Shockwave to get these focus events on the Mac.
Status: NEW → ASSIGNED
Yeah, make it implement nsIDOMFocusListener too and dispatch those events too.
Due to yeterday's layout carpool, all my trees need updating and I havne't tried this yet. Here's the first try patch at implementing nsIDOMFocusListener. It follows Chris's lead with the KeyListeners.
Target Milestone: --- → mozilla0.9
looks good to me. r=saari
NO!! This patch is NOT good. Something is wrong. Rod or Chris, can you take a quick look to see if I missed something? I pretty much copied the way Mouse and Key Listeners work, but perhaps Focus needs something else extra. I'm getting tons of "Unable to remove event listener for plugin" ASSERTIONS from focus in Destroy() probably because it can't get the focus listener. Am I registering it right? That shouldn't be happening. Now that my builds are done I can look in the debugger. Be sure to increase memory allocated to Mojo before playing Shockwave games on Mac. Rod, in nsGFXTextControlFrame2, it looks like you are keeping the state of focus as a member and setting it upon keystroke as well. Is this something I should do as well? Actually, I just want to pass the event off, but according to Macromedia, focus needs to be sent before keyboard are accepted. Looking further in the debugger, it looks like the AddEventListenerByIID is failing. Anyone know why?
My bad....didn't finish implementing QI. Sorry. Did that, still doesn't work. Will keep looking, but now it's a problem in plugins as we are recieving focus and blur events from the DOM.
Ok, looks like Blur is working but I'm getting an invalid pointer with Focus events. When nsIDOMEvent gets cast to a nsEvent when calling GetInternalNSEvent in the dispatch, I think my nativeMsg (void *) pointer is garbage (pointing at 00000001). This doesn't happen for Blur events. Any ideas? Changing summary from: Keyboard input broken for Shockwave Plugin
Keywords: shockwave
Summary: Keyboard input broken for Shockwave Plugin → ObjectFrame needs nsIDOMFocusListener for Mac keyboard events in Shockwave
Chris, question: (void *) nsGUIEvent.nativeMsg is pointing to 00000001 and my event is not an NS_GOTFOCUS but rather an NS_FOCUSEVENTSTART (if that's a problem???). If I ignore the invalid pointer, and let this through, it seems to work! My question: Do you know why nativeMsg is NOT null and what this value means? What constant defines this because I need to allow this case to go through. Since it's "native" I'm thinking it's a OS constant? Thanks!
This patch works pretty good on the Mac. Shockwave games now work with the keyboard. I will continue to test on Windows and if others can try, that'd be good to catch regressions.
I don't know why you're seeing that garbage pointer for the OS event... but it isn't good. I bet some plugin out there somewhere will wipe out with that. And you shouldn't be seeing NS_FOCUS_EVENT_START, that is just the start offset for some focus events in nsGUIEvent.h, we shouldn't ever be dispatching it!
I tried this out on Windows and I don't see any regressions. With that garbage pointer, Kevin seems to think nativeMsg is a bad handle. I have a similar problem on Windows which is only on debug builds. Perhpas there is an rv that needs checking. Fixing this is high-priority because it blocks keyboard input in Shockwave
Priority: -- → P1
I'm seeking a review for this patch. Comments on how to resolve the notes Chris Saari made are very welcome.
Moving to mozilla0.8.1
Keywords: patch, review
Target Milestone: mozilla0.9 → mozilla0.8.1
The patch looks good, except for the NS_FOCUS_EVENT_START stuff. Don't know why that is... did you get any leads on this yet?
The plugin doesn't have a problem with NS_LOSTFOCUS. In fact, if you change that one, it breaks. But Shockwave seems to like NS_FOCUS_EVENT_START instead?. Is this a bug on our side or does this just what shockwave excepts. I couldn't find anything in the 4.x spec. It works though???? Andrei/Peter any comments?
Peter, this is effectively what the macintosh shockwave plugin does for NPP_HandleEvent(NPP instance, EventRecord *event) { ... switch (event->what) { case getFocusEvent: /* Remember that the browser has given us keyboard focus. */ pPluginMovieInst->bPluginHasKeyboardFocus = kTrue; /* Tell the host browser that we will accept keyboard events. */ return TRUE; case loseFocusEvent: /* Remember that the browser has taken keyboard focus away from us. */ pPluginMovieInst->bPluginHasKeyboardFocus = kFalse; return TRUE; ... } getFocusEvent and loseFocusEvent are defined by OS headers. Shockwave will only handle keyboard events (or poll for key states) if pPluginMovieInst- >bPluginHasKeyboardFocus is true.
To bypass the blocking on Shockwave.com add this to all.js: pref("general.useragent.override","Mozilla/4.75 [en] (Win95; U)"); Patch seems to not cause any regressions on Windows. Faceball plays quite nicely. Andrei and Shrir, can you please try and Andrei can I get an r=? Thanks.
r=av, so far looks good to me. Have you tried this on Windows?
Tested and works on Windows.
Why this? + //case NS_BLUR_CONTENT: otherwise it looks ok. r=sfraser
Target Milestone: mozilla0.8.1 → mozilla0.9
+ //case NS_BLUR_CONTENT: Caused problems and freeze ups. Simon, can I use your r= as an sr=? Andrei, can you give me an a= on this?
a=av
Patch checked in. ===> new revision: 1.204; previous revision: 1.203 Keyboard input should now work with Shockwave on the Mac.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Re-opening as this is still happening. Strange....works in my debug build (I can play Faceball) but not in a optimized nightly. Anyone know why this would be so? Need to build an optimized build in order to debug this and my Mac can never complete an optimized build. New powerful Mac should arrive tomorrow or Monday with more RAM. Leaving Milestone at mozilla 0.9 as this is an important regression to fix. Please change if you feel otherwise. No keyboard events will work with Shockwave therefore one is unable to play the games on Shockwave.com
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Blocks: 35916
Blocks: 75664
Still can't build optimized......but, I think I found the problem. In nsPluginInstanceOwner::ProcessEvent(), looks like the problem is the cast from an nsGUIEvent to an EventRecord. I'll see if I can make a patch, but I still need someone to test it on their optimized build.
Keywords: patch, review
is this mac only? any progress on figuring this out for 0.9? -thanks
Whiteboard: reworking fix...
This is Macintosh only. I'm attaching a patch which should fix this in all builds. Marc or Pinkerton, could you review and try if you have an optimized build? Thanks.
Whiteboard: reworking fix... → [fix-in-hand]
Peter, I don't really get it. It looks like you are just indicating that focus and blur events shoul dget through, is that it? What about that old junk with casting the event to an int and comparing to '5'? What was that for and why can you remove it now? Also, it looks like you have some unnecessary parens in the list of || clauses... I can't do an opt build at the moment, I'm debugging (unless somebody tells me how to have and DEBUG and OPT mac build in the same tree).
Whiteboard: [fix-in-hand] → need4embd-0.9 [fix-in-hand]
r=karnaze, you may want to reverse the == tests so the constant appears on the LHS.
sr=attinasi
a=drivers check it in. thanks
Patch checked in. Marking FIXED. /cvsroot/mozilla/layout/html/base/src/nsObjectFrame.cpp,v <-- nsObjectFrame.cpp new revision: 1.211; previous revision: 1.210
Status: REOPENED → RESOLVED
Closed: 24 years ago24 years ago
Resolution: --- → FIXED
verified on mac trunk 20010425. Kwyboard events work now on shockwave games.
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: