Comment 14 for bug 538838

Revision history for this message
In , Karlt (karlt) wrote :

(From update of attachment 446645)
In principal, this looks sensible to me.

>+ /**
>+ * Begin a window moving drag. We don't need an event.
>+ */
>+ NS_IMETHOD BeginMoveDrag() = 0;

>+ // get the current pointer position and button state
>+ GdkScreen* screen = NULL;
>+ gint screenX, screenY;
>+ GdkModifierType mask;
>+ gdk_display_get_pointer(display, &screen, &screenX, &screenY, &mask);
>+
>+ // we only support moving with button 1
>+ if (!(mask & GDK_BUTTON1_MASK)) {
>+ return NS_ERROR_FAILURE;
>+ }
>+
>+ // tell the window manager to start the move
>+ gdk_window_begin_move_drag(gdk_window, 1, screenX, screenY, GDK_CURRENT_TIME);

This really does need an event for the root window coordinates and timestamp.
If the user is dragging, the coordinates at the time of processing will often
differ from those of the ButtonPress. And a window drag is something that we
should be careful not to initiate on the wrong button press.

nsMouseEvents really deserve root window coordinates, but the easiest way to
implement this might be by setting nsGUIEvent::pluginEvent. BeginMoveDrag can
fail for synthetic events and WindowDraggingUtils will use the fallback code.

(I see that
http://standards.freedesktop.org/wm-spec/1.4/ar01s04.html#id2568642 adds
_NET_WM_MOVERESIZE_CANCEL, but GDK doesn't yet support it, so I guess we won't
worry about that.)

>+ // get the gdk window for this widget
>+ GdkWindow* gdk_window = mGdkWindow;
>+ if (!GDK_IS_WINDOW(gdk_window)) {
>+ return NS_ERROR_FAILURE;
>+ }
>+

Only test mGdkWindow against NULL. It won't be any other GObject type.

>+ gdk_window = gdk_window_get_toplevel(gdk_window);
>+ if (!GDK_IS_WINDOW(gdk_window)) {
>+ return NS_ERROR_FAILURE;
>+ }
>+
>+

No need to check the result.
It won't be NULL because the parameter was not NULL.