Re: Problems with querying the pointer



Tim Janik <timj gtk org> writes:

> On Mon, 30 Sep 2002, Owen Taylor wrote:
> 
> > I frankly don't see any remotely reasonable way to fix this, so
> > I think what we need to do is just say that 
> > gdk_window_set_pointer_hooks() is a non-multihead safe API, and
> > augment it with a new multihead-aware API. My proposal for this
> > is:
> >  
> > struct _GdkDisplayPointerHooks 
> > {
> >   void (*get_pointer)              (GdkDisplay	    *display,
> >                                     GdkWindow      **root_window,
> > 			            gint	    *x,
> > 			            gint   	    *y,
> > 			            GdkModifierType *mask);
> >   GdkWindow* (*window_get_pointer) (GdkDisplay      *display,
> >                                     GdkWindow	    *window,
> > 			            gint	    *x,
> > 			            gint   	    *y,
> > 			            GdkModifierType *mask);
> >   GdkWindow* (*window_at_pointer)  (GdkDisplay      *display,
> >                                     gint            *win_x,
> >                                     gint            *win_y);
> > };
> > 
> > GdkPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay            *display,
> >                                                 const GdkPointerHooks *new_hooks);
> > void             gdk_display_get_pointer     (GdkDisplay      *display,
> >                                               GdkWindow      **root_window,
> >         			              gint	      *x,
> >         			              gint 	      *y,
> > 			                      GdkModifierType *mask);
> > GdkWindow *      gdk_display_get_window_at_pointer (GdkDisplay      *display,
> >         			                    gint	    *win_x,
> >         			                    gint 	    *win_y);
> > 
> > And remove gdk_screen_get_window_at_pointer().
> > 
> > gdk_set_pointer_hooks() would set the GdkDisplayPointerHooks for the default 
> > display to a thunk set of pointer hooks that would work for the single-screen,
> > single-display case.
> 
> for event recording you need to hook into all XQueryPointer() calls, so why
> will you want to set pointer hooks per-display? i.e. introducing a new
> GdkDisplayPointerHooks is fine (the old API needs to be deprecated then
> btw) but should be set only once and globally, not per display.

I agree that there isn't much of a reason why pointer hooks have
to be per-display. I did it that way basically because it felt
more comfortable.

 - If you are writing a multi-display event tracker (that sounds like
   a real job!) you'll need to track displays opening and closing
   using GdkDisplayManager anyways, so it doesn't _hurt_ to have
   them per-display.

   (And if you just want to record events on the default display,
   it's easier not to get hooked for other displays as well.)

 - All event / pointer handling is now localized per display, so 
   I think it's nice to avoiding adding non-localized globals.

 - Given the choice between adding methods and adding non-method
   functions, methods are easier for object-oriented 
   language bindings to handle.

It's not a big deal either way from my perspective.

As for deprecation, the policy we've being doing so far is "no new
deprecations in 2.2, save them to be added to 2.4". I'll make sure
there is a bug open to deprecate it for 2.4.

> > (*) The question would remain whether we should:
> > 
> >   a) Change gdk_screen_get_window_at_Pointer() to 
> >      gdk_display_get_window_at_pointer(), and leave a mismatch
> >      between this and GdkPointerHooks.
> 
> well, you'll have to keep gdk_screen_get_window_at_pointer() for binary
> compat anyway, so this and GdkPointerHooks will simply be deprecated and
> gdk_display_get_window_at_pointer() matches GdkDisplayPointerHooks.
> 
> >   b) Keep the match and expose the oddity
> >      (gdk_screen_get_window_at_pointer() can return a window
> >      on a different screen) in a more common API.
> >   
> >     It would still be messy.

This footnote was about what we'd have to do if we didn't add  
GdkDisplayPointerHooks. Since GdkDisplayPointerHooks worked out well,
it's not really relevant.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]