Re: In GTK, how are screen coordinates mapped to GUI objects?



Computers are *fast*. It turns out that simply recursively walking
down all children is fast enough for most cases. It's a complicated
walk, but it's entirely doable. You can see the code for the walk
here:

https://git.gnome.org/browse/gtk+/tree/gdk/gdkwindow.c#n7247

More complex data structures, like a map of pixel to object, would
take up too much memory, or require too much effort to suitably parse.
The simple and brute force solution often works well, because you'll
never have more than 100 visible children in the worst case, and 100
is not a big enough number to optimize for.

On Mon, May 11, 2015 at 2:14 PM, George Nychis <gnychis gmail com> wrote:
I am trying to gain a very technical understanding of how operating systems
and GUI systems (like GTK) scalably map coordinates on the 2d screen to
objects.  For example, there are many applications running with graphical
interfaces to them active on the screen, and each application interface has
dozens (if not hundreds) of objects (buttons, scroll bars, etc.).  Some
objects are contained within other objects.

So, what I am trying to learn more about is how something like GTK maps a
screen coordinate (and an action like a mouse click) to an object quickly to
generate a callback to the appropriate application or object.  In
particular, when there are objects within objects, how it narrows the search
down to the "smallest" element that your mouse is hovering over when a click
event fired.

I'd love to know about what data structures and algorithms are used to
perform this mapping between the 2D graphical space to objects.

Thanks!
George

_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list




-- 
  Jasper


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