Server-side widgets

Mark Thomas <[email protected]> Thu, 22 Jul 2004 18:09:06 +0100 (BST)
Newsgroups gmane.comp.graphics.y.devel
Message-ID <[email protected]>
Hi all,

Last week, I read some posts on the X.org mailing list about server-side
widgets, and there seems to be some confusion out there about what they
actually mean, and how they provide any performance advantage over
client-side widgets.  Since I'm not subscribed to that list, and since
it's probably more relevent here since I don't imagine X will ever get any
type of server-side widgets, I thought I'd answer some of the points here.

I think part of the confusion maybe in the terminology.  "Server-side
widgets" makes people think all of the widgets are entirely server-side.
Perhaps "widget-aware server" would be a better way of putting it.  Y will
be a "widget-aware" server, as opposed to X which is "widget-unaware".

The main point is that the server divides the screen into regions of
nested and overlapping "widgets", and recognises that there are different
kinds of widgets that must be treated differently.  This is slightly more
advanced than a "widget-unaware" server, which divides the screen into
regions of nested and overlapping "windows" that are all treated
essentially the same.

Firstly, there are kinds of widgets (Buttons, Labels, Checkboxes...) that
given a small amount of data (i.e. a few strings or integers), the server
can deal with entirely. This is a fairly common scenario, and it is also
the scenario in which we win big.  Moving, resizing, and to a certain
extent interacting with windows which consist solely of these kinds of
widgets will have zero client-server interaction, zero context switches
and thus near-zero latency.

Secondly, there are kinds of widgets that depend on a large amount of
client-side data.  It doesn't make sense to transfer all of this data
across the connection, and I've never suggested that we do.  However, just
because the server doesn't know what data appears in a TreeView doesn't
mean the server can't know that there is a TreeView, and just because the
server is slightly more intelligent doesn't mean the client has to be
completely dumb.  Instead, we make the server and client speak to each
other in terms of the widget, rather than in terms of pixels.  For
example, the user moves the scrollbar on a TreeView so that the entire
contents must be redrawn, compare:

"widget-unaware", server, e.g. X:

  --> MouseMove (window, dx, dy)
      (client determines what happened is the scrollbar was moved
       in a way which means the entire contents of the widget must be
       redrawn)
  <-- SetGC (window, backgroundGC)
  <-- ClearRect (window, x, y, w, h)
  <-- SetGC (window, treeviewLinesGC)
  <-- DrawLines (window, ...)
  <-- SetGC (window, treeviewPartsGC)
  <-- DrawLines (window, ...)
  <-- DrawPixmap (window, icon, ...)
  <-- DrawText (window, text, ...)
      (these last steps repeated for each object in the treeview)


"widget-aware" server, e.g. Y:

      (server determines scrollbar was moved and entire contents pane
       must be redrawn)
  --> treeview.Redraw (startElementSpec, endElementSpec)
  <-- treeview.DrawElement (elementSpec, icon, text)
      (this last step repeated for each object in the treeview)

If you think of it in MVC terms, only the View is on the server.

Now, I think you'll agree that the "widget-aware" server will perform in
the worst-case exactly the same as the "widget-unaware" server.  More
likely it will be better since the amount of data transferred is lower and
the amount of work to do is slightly less, but let's call it a draw for
now.

So that's a "win" in the low-data, high-count widgets, and a "draw" (maybe
"win") in the high-data, low-count widgets.  I'm not sure about the rest
of you, but for me, ("win", "draw") counts as an overall "win".

Finally, there are custom widgets.  I'm not talking about custom buttons
which look completely different from normal buttons and go "ding" when you
hover your mouse over them, they're bad and should be discouraged.  The
useful kind of custom widgets are specialised views of custom data.  In
both widget-aware servers and widget-unaware servers with client library
toolkits, they are implemented exactly the same way: canvasses.  The
performance difference here will be negligible.

I hope this helps to clear up any misunderstandings and misgivings people
had about server-side widgets.  If you have any more questions, ask them.

Regards,

  Mark.
-- 
|| Mark Thomas
|| efaref.net
||
|| Don't anthropomorphize computers, they don't like it.