Closed Bug 384975 Opened 17 years ago Closed 17 years ago

input event dispatching for X11 windowless plugins

Categories

(Core Graveyard :: Plug-ins, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: karlt, Assigned: karlt)

References

Details

Attachments

(1 file, 2 obsolete files)

Attached patch input event dispatching (obsolete) — Splinter Review
Mouse, key, focus, and enter/leave events are provided in XEvents
through NPP_HandleEvent.  The mouse events have x and y relative
to the plugin rectangle origin.  This seemed the most useful
information to me, but is not the same as what is provided on
Windows.

(On Windows the mouse events are relative to the containing window.  This requires working with one offset for drawing and a different offset for mouse events.  See bug 135737.  I'd rather avoid this.)

As the XEvents sent to the plugin are synthesized and there is not
a native window corresponding to the plugin rectangle, some of the
members of the XEvent structures are not set to their normal
Xserver values.  e.g. Key events don't have a position.  However
the information should be complete enough.

This patch requires the patch in 384965 and (at least) some of the patch in 384845.
Attached patch input event dispatching 2 (obsolete) — Splinter Review
Added #ifdef MOZ_WIDGET_GTK2 where appropriate.
Using NS_STATIC_CAST.

roc can you review the code, please?
jst can you confirm that you are happy with the plugin API, please?
Attachment #268891 - Attachment is obsolete: true
Attachment #269364 - Flags: superreview?(roc)
Attachment #269364 - Flags: review?(roc)
Attachment #269364 - Flags: review?(jst)
+  if(anEvent.isAlt) state |= Mod1Mask;
+  if(anEvent.isMeta) state |= Mod4Mask;

Are these always the right masks? Check out the modifier-related code in the patch in bug 377478.

+#ifdef MOZ_X11
+  // this code supports windowless plugins

Could we break this out into a helper function?

+        // XXX Non-translation transformations will be interesting.

Take this out ... nsLayoutUtils::GetEventCoordinatesRelativeTo should be fine with this.

+          } break;

Put this on its own line.
(In reply to comment #2)
> +  if(anEvent.isAlt) state |= Mod1Mask;
> +  if(anEvent.isMeta) state |= Mod4Mask;
> 
> Are these always the right masks? Check out the modifier-related code in the
> patch in bug 377478.

These invert processing in nsWindow::OnMotionNotifyEvent, nsCommonWidget::InitButtonEvent, and nsCommonWidget::InitKeyEvent, and so they are correct in that they recover the information stored in the nsInputEvent.

As to the question of whether nsCommonWidget and nsWindow have it right:

Gtk always treats alt as Mod1 in gtk_accelerator_parse

          else if (len >= 5 && is_alt (accelerator))
            {
              accelerator += 5;
              len -= 5;
              mods |= GDK_MOD1_MASK;
            }

and in gtk_accelerator_name

  static const gchar text_mod1[] = "<Alt>";

  ...

  if (accelerator_mods & GDK_MOD1_MASK)
    {
      strcpy (accelerator + l, text_mod1);
      l += sizeof (text_mod1) - 1;
    }

so I guess the isAlt Mod1 association is safe.

As for isMeta, Meta and Alt are usually bound to the same modifier so I guess isMeta really means something like isSuperOrHyper, in which case modifier key detection like that in bug 377478 would be best.  However, I think this modifier is often associated with the window manager so it probably should not be interpreted by us anyway.  (nsWindow::OnMotionNotifyEvent doesn't set isMeta at all, but nsCommonWidget does.)

> 
> +#ifdef MOZ_X11
> +  // this code supports windowless plugins
> 
> Could we break this out into a helper function?

I'll leave this as it stands as there wouldn't be must left of ProcessEvent if we broke this out.

> 
> +        // XXX Non-translation transformations will be interesting.
> 
> Take this out ... nsLayoutUtils::GetEventCoordinatesRelativeTo should be fine
> with this.

Yep.

> 
> +          } break;
> 
> Put this on its own line.

I'm happy to do that as it makes sense to me to.  The style above was based on 
http://www.mozilla.org/hacking/mozilla-style-guide.html.
Removed non-translation comment as requested.
s/} break/}\n break/
Attachment #269364 - Attachment is obsolete: true
Attachment #269776 - Flags: superreview?(roc)
Attachment #269776 - Flags: review?(roc)
Attachment #269776 - Flags: review?(jst)
Attachment #269364 - Flags: superreview?(roc)
Attachment #269364 - Flags: review?(roc)
Attachment #269364 - Flags: review?(jst)
Attachment #269776 - Flags: superreview?(roc)
Attachment #269776 - Flags: superreview+
Attachment #269776 - Flags: review?(roc)
Attachment #269776 - Flags: review+
Attachment #269776 - Flags: review?(jst) → review+
Blocks: 386537
Checked those in.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
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: