~brandontschaefer/nux/base-window-x-input-window-wm-updates

Viewing all changes in revision 761.

  • Committer: Tarmac
  • Author(s): Sam Spilsbury
  • Date: 2013-02-25 19:20:17 UTC
  • mfrom: (756.2.2 nux.fix_1097281)
  • Revision ID: tarmac-20130225192017-48tyqzwi3b28zu73
Implement a message-passing system in nux::WindowThread and nux::ProgramFramework.

This makes it possible to define and implement protocols for WindowThreads to
communicate with each other in a thread-safe way without having to resort to
using window system events or the like.

New file descriptors can be added for watching with a watch-callback executed
inside the window thread with nux::WindowThread::WatchFdForEvents. Only
read-data is supported right now.

When there is new data available to be read, the provided FdWatchCallback will
be called by the window thread, and executed inside the window thread. From
there, clients can safely modify data contained by the WindowThread object.

Remove a watched file descriptor with UnwatchFd.

It is safe to add file descriptors for watching during the call to the provided
ThreadUserInitFunc in CreateGUIThread. This is because the main loop
implementation must be created before those file descriptors are added for
watching (particularly in the case of GLib, because nux::WindowThread::InitGlibLoop
will use the default GMainContext the first time it is called, and then create
a new one for each window thereafter.

Added three new tests to demonstrate and cover this functionality.

[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from TestWindowThread
[ RUN ] TestWindowThread.WatchFd
[ OK ] TestWindowThread.WatchFd (3213 ms)
[ RUN ] TestWindowThread.MultiWatchFd
[ OK ] TestWindowThread.MultiWatchFd (3163 ms)
[ RUN ] TestWindowThread.OneFdEvent
[ OK ] TestWindowThread.OneFdEvent (3155 ms)
[----------] 3 tests from TestWindowThread (9532 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (9532 ms total)
[ PASSED ] 3 tests.

Fixed segfaulting test xtest-text-input. That test unsafely mutated object
state contained by the WindowThread running in another thread inside of the
test thread. This resulted in a null pointer dereference because it had a
side effect of calling nux::GetWindowThread () which relies on up-to-date
thread-local-storage. That test now defines a protocol to communicate to
the running program to mutate the relevant state, and then communicate back
when it has completed execution.

(LP: #1097281)
. Fixes: https://bugs.launchpad.net/bugs/1097281.

Approved by Brandon Schaefer.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: