Back to index

nux  3.0.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends
nux::WindowThread Class Reference

Main class of a Nux window app. More...

#include <WindowThread.h>

Inheritance diagram for nux::WindowThread:
Inheritance graph
[legend]
Collaboration diagram for nux::WindowThread:
Collaboration graph
[legend]

List of all members.

Classes

struct  _EventInspectorStorage

Public Member Functions

 WindowThread (const char *WindowTitle, int width, int height, AbstractThread *Parent, bool Modal)
virtual ~WindowThread ()
virtual int Run (void *ptr=NULL)
 Start the WindowThread in the current Thread.
virtual ThreadState Start (void *ptr=NULL)
 Start the user interface Window in it own thread.
void ExitMainLoop ()
 Exit from the WindowThread loop.
void SetWindowSize (int width, int height)
 Set window size.
void SetWindowBackgroundPaintLayer (AbstractPaintLayer *background_layer)
 Set the background for the window.
GraphicsDisplayGetGraphicsDisplay () const
 Get the graphics display (this is the physical window of this thread).
GraphicsEngineGetGraphicsEngine () const
 Get the graphics engine (this is the object that renders the graphics primitives).
WindowCompositorGetWindowCompositor () const
 Get the UI compositor (this is processes events and renders ui objects).
BasePainterGetPainter () const
 Get the painter object.
TimerHandlerGetTimerHandler () const
 Get the timer manager.
UXThemeGetTheme () const
 Get the UI resource manager (load textures and other data for user interface rendering).
void SetLayout (Layout *layout)
 Set the layout for this window thread.
LayoutGetLayout ()
 Get the layout of this window.
bool IsInsideLayoutCycle () const
 Return true if the process is inside a layout cycle.
bool IsComputingLayout () const
 Deprecated. Replace with IsInsideLayoutCycle.
bool QueueObjectLayout (Area *area)
 Schedule a size computation cycle on an area before the rendering is performed.
void ComputeElementLayout (Area *bo, bool recurse_to_top_level_layout=false)
 Compute the layout of a specific element.
bool RemoveObjectFromLayoutQueue (Area *area)
 Remove an area from the list of object whose size was scheduled to be computed before the rendering cycle.
bool IsWaitingforModalWindow () const
 Return true while waiting for a modal window to return.
bool IsModalWindow () const
 Return true if this window is modal.
bool IsEmbeddedWindow ()
 Return true if this windowThread is embedded inside Compiz.
void RenderInterfaceFromForeignCmd (Geometry *clip)
 Render the interface.
void AddTimeline (Timeline *timeline)
 Add a timeline to our window.
void RemoveTimeline (Timeline *timeline)
bool ProcessTimelines (GTimeVal *frame_time)
void StartMasterClock ()
void StopMasterClock ()
int InstallEventInspector (EventInspector function, void *data)
 Set an event inspector function.
bool RemoveEventInspector (int event_inspector_id)
 Remove an event inspector.
bool RemoveEventInspector (EventInspector function)
 Remove an event inspector.
bool CallEventInspectors (Event *event)
 Call event inspectors.
TimerHandle SetAsyncTimerCallback (int time_ms, TimeOutSignal *timeout_signal, void *user_data)
 Sets a timer from a different thread.
std::string GetWindowTitle () const
 Return the Window title.
void ProcessDraw (GraphicsEngine &graphics_engine, bool force_draw)
void RequestRedraw ()
void ClearRedrawFlag ()
bool IsRedrawNeeded () const
void AddToDrawList (View *view)
void ClearDrawList ()
std::vector< GeometryGetDrawList ()
virtual ThreadState Stop (bool bForceKill=false)
 Info: Stops the thread.
ThreadState Suspend ()
ThreadState Resume ()
ThreadState ResumeStart ()
ThreadState ResumeExit ()
unsigned int GetExitCode () const
 Info: Starts the thread.
void Attach (ThreadRoutineFunc lpThreadFunc)
 Info: Attaches a Thread Function.
void Detach (void)
 Info: Detaches the Attached Thread Function.
pthread_t GetPThread ()
ThreadState GetThreadState () const
void SetThreadState (ThreadState state)

Static Public Member Functions

static ThreadWaitResult JoinThread (NThread *thread, unsigned int milliseconds)
 Wait for a thread to complete.

Public Attributes

long last_timeline_frame_time_sec_
long last_timeline_frame_time_usec_
sigc::signal< void > RedrawRequested
sigc::signal< void, int, int,
int, int > 
window_configuration
 emmitted when the window Geometry changes.

Protected Member Functions

virtual bool ThreadCtor ()
 Constructor-like function for the thread.
virtual bool ThreadDtor ()
 Destructor-like function for the thread.
void QueueLayout ()
 Causes the Main layout to be recomputed.
void RemoveQueuedLayout ()
 Empty the queue of objects set for layout computation.
void ReconfigureLayout ()
 Compute the layout of this window thread.
void EnableMouseKeyboardInput ()
 Suspend Win32 Mouse and Keyboard inputs for this window thread and its child thread that are also window (not SystemThread).
void DisableMouseKeyboardInput ()
 Enable Win32 Mouse and Keyboard inputs for this window thread and its child thread that are also window (not SystemThread).
unsigned int ExecutionLoop ()
 Entire frame of goes through this function.
virtual ThreadState StartChildThread (AbstractThread *thread, bool Modal)
virtual void AddChildThread (AbstractThread *)
virtual void RemoveChildThread (AbstractThread *)
virtual void ChildHasFinished (AbstractThread *app)
virtual void TerminateChildThreads ()
virtual ThreadState SuspendChildGraphics (WindowThread *app)
void TerminateChildWindows ()
void JoinChildThreads ()

Static Protected Member Functions

static void * EntryPoint (void *)
 Info: DONT override this method.

Protected Attributes

bool is_modal_window_
bool wait_for_modal_window_
WindowThreadmodal_window_thread_
std::list< AbstractThread * > children_thread_list_
AbstractThreadparent_
ThreadUserInitFunc user_init_func_
ThreadUserExitFunc user_exit_func_
void * initialization_data_
 This pointer maybe set by the user in ThreadInitFunc and reused in ThreadExitFunc.
std::list< NThread * > m_ThreadList
volatile ThreadState m_ThreadState
NThreadContext m_ThreadCtx
 Attributes Section.
ThreadRoutineFunc m_pThreadFunc

Private Types

typedef struct
nux::WindowThread::_EventInspectorStorage 
EventInspectorStorage

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (WindowThread, AbstractThread)
int MainLoop ()
 Execute the main loop of this thread.
void AsyncWakeUpCallback (void *user_ptr)
 Custom callback to wake up the main thread and start the execution loop.
void StartLayoutCycle ()
 Informs the system of the start of a layout cycle.
void StopLayoutCycle ()
 Informs the system of the end of a layout cycle.
void ComputeQueuedLayout ()
 Execute the size computation cycle on objects.
 WindowThread (const WindowThread &)
WindowThreadoperator= (const WindowThread &)
WindowThreadoperator& ()
unsigned int AddTimeout (unsigned int timeout_delay)
 Add a timeout and return the timeout index.

Private Attributes

TimeOutSignalasync_wake_up_signal_
TimerHandle async_wake_up_timer_handle_
GSource * _MasterClock
bool _inside_main_loop
bool _inside_timer_loop
bool _pending_wake_up_timer
std::list< Area * > _queued_layout_list
std::vector< Geometrym_dirty_areas
bool _inside_layout_cycle
 This variable is true while we are computing the layout the starting from the outmost layout(the Main Layout);.
bool queue_main_layout_
 Set to true to schedule a compute cycle on the main layout.
std::list< Timeline * > * _Timelines
bool first_pass_
 True when going through the ExecutionLoop for the first time.
unsigned int window_initial_width_
 Window height at startup.
unsigned int window_initial_height_
 Window width at startup.
std::string window_title_
 Window title.
bool _draw_requested_to_host_wm
 Flags signaling that a draw cycle has been requested to the host window manager.
Layoutmain_layout_
UXThemetheme_
BasePainterpainter_
TimerHandlertimer_manager_
GraphicsDisplaygraphics_display_
WindowCompositorwindow_compositor_
bool m_WidgetInitialized
WindowStyle window_style_
bool thread_ctor_called_
 True if the thread constructor has been called.
bool thread_dtor_called_
 True if the thread destructor has been called.
bool embedded_window_
 True when running Ubuntu Unity+Nux has a plugin of Compiz.
bool window_size_configuration_event_
 Record if there was a configuration nux_event(NUX_SIZE_CONFIGURATION) that requires a full redraw.
bool force_rendering_
std::map< int,
EventInspectorStorage
_event_inspectors_map
 Map of events inspectors.

Static Private Attributes

static const int MINIMUM_WINDOW_WIDTH = 1
 Minimum width allowed for a window.
static const int MINIMUM_WINDOW_HEIGHT = 1
 Minimum height allowed for a window.

Friends

class TimerHandler
class BasePainter
class SystemThread
WindowThreadCreateGUIThread (const char *WindowTitle, int width, int height, WindowThread *Parent, ThreadUserInitFunc UserInitFunc, void *InitData)
 Create a Nux window.
WindowThreadCreateNuxWindow (const char *WindowTitle, int width, int height, ThreadUserInitFunc UserInitFunc, void *InitData)
WindowThreadCreateNuxWindow (const char *window_title, int width, int height, WindowStyle window_border_style, AbstractThread *parent, bool modal, ThreadUserInitFunc user_init_func, void *data)
 Create the only Nux window for the current system thread.
WindowThreadCreateNuxWindowNewThread (const char *window_title, int width, int height, WindowStyle window_border_style, AbstractThread *parent, bool modal, ThreadUserInitFunc user_init_func, void *data)
 Create a Nux window to be run in a new thread.
WindowThreadCreateWindowThread (WindowStyle WndStyle, const char *WindowTitle, int width, int height, WindowThread *Parent, ThreadUserInitFunc UserInitFunc, void *InitData)
WindowThreadCreateModalWindowThread (WindowStyle WndStyle, const char *WindowTitle, int width, int height, WindowThread *Parent, ThreadUserInitFunc UserInitFunc, void *InitData)
SystemThreadCreateSystemThread (AbstractThread *Parent, ThreadUserInitFunc UserInitFunc, void *InitData)

Detailed Description

Main class of a Nux window app.

Each WindowThread runs in its own loop. There cannot be more than one WindowThread per system thread.

Definition at line 61 of file WindowThread.h.


Member Typedef Documentation


Constructor & Destructor Documentation

nux::WindowThread::WindowThread ( const char *  WindowTitle,
int  width,
int  height,
AbstractThread Parent,
bool  Modal 
)

Definition at line 54 of file WindowThread.cpp.

    : AbstractThread(Parent)
    , window_initial_width_(width)
    , window_initial_height_(height)
    , window_title_(WindowTitle)
    , m_WidgetInitialized(false)
    , window_style_(WINDOWSTYLE_NORMAL)
    , embedded_window_(false)
    , window_size_configuration_event_(false)
    , force_rendering_(false)
  {
    // Thread specific objects
    graphics_display_       = NULL;
    window_compositor_      = NULL;
    painter_                = NULL;
    timer_manager_          = NULL;
    theme_                  = NULL;
    main_layout_            = NULL;
    queue_main_layout_ = false;
    
    // Protection for ThreadCtor and ThreadDtor;
    thread_ctor_called_ = false;
    thread_dtor_called_ = false;

    //
    wait_for_modal_window_   = false;
    modal_window_thread_     = 0;
    is_modal_window_              = Modal;

    _inside_layout_cycle = 0;
    _draw_requested_to_host_wm       = false;
    first_pass_        = true;

    _Timelines = new std::list<Timeline*> ();
    GTimeVal time_val;
    g_get_current_time(&time_val);
    last_timeline_frame_time_sec_ = time_val.tv_sec;
    last_timeline_frame_time_usec_ = time_val.tv_usec;
    _MasterClock = NULL;

#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
    main_loop_glib_      = 0;
    main_loop_glib_context_   = 0;
#endif

#if defined(NUX_OS_LINUX)
    x11display_ = NULL;
    ownx11display_ = false;
#endif
    
    _pending_wake_up_timer = false;
    _inside_main_loop = false;
    _inside_timer_loop = false;
    async_wake_up_signal_ = new TimerFunctor();
    async_wake_up_signal_->time_expires.connect(sigc::mem_fun(this, &WindowThread::AsyncWakeUpCallback));
  }

Here is the call graph for this function:

Definition at line 111 of file WindowThread.cpp.

  {
#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
    CleanupGlibLoop();
#endif

    ThreadDtor();
    std::list<Timeline*>::iterator li;
    for (li=_Timelines->begin(); li!=_Timelines->end(); ++li)
    {
      (*li)->UnReference();
    }
    
    delete _Timelines;
    delete async_wake_up_signal_;

#if defined(NUX_OS_LINUX)
    if (x11display_ && ownx11display_)
    {
      XCloseDisplay(x11display_);
    }
#endif
  }

Here is the call graph for this function:


Member Function Documentation

void nux::WindowThread::AddChildThread ( AbstractThread window) [protected, virtual]

Implements nux::AbstractThread.

Definition at line 714 of file WindowThread.cpp.

  {
    if (window == NULL)
      return;

    std::list<AbstractThread*>::iterator it;
    it = find(children_thread_list_.begin(), children_thread_list_.end(), window);

    if (it == children_thread_list_.end())
    {
      children_thread_list_.push_back(window);
    }
  }

Here is the caller graph for this function:

Add a timeline to our window.

Definition at line 381 of file WindowThread.cpp.

  {
    _Timelines->push_back(timeline);
    _Timelines->unique();
    StartMasterClock();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int nux::WindowThread::AddTimeout ( unsigned int  timeout_delay) [private]

Add a timeout and return the timeout index.

This function is used internally by Nux.

Parameters:
timeout_delayTime laps before the timeout is fired.
Returns:
An index for the timeout.

Definition at line 142 of file WindowThread.cpp.

  {
#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
    return AddGLibTimeout(timeout_delay);
#endif
  }

Here is the caller graph for this function:

Definition at line 1208 of file WindowThread.cpp.

  {
    Area *parent;
    Geometry geo, pgeo;
    
    geo = view->GetAbsoluteGeometry();
    parent = view->GetToplevel();
    
    if (parent && (view != parent))
    {
//       pgeo = parent->GetGeometry();
//       geo.x += pgeo.x;
//       geo.y += pgeo.y;

      if (parent->Type().IsDerivedFromType(BaseWindow::StaticObjectType))
      {
        BaseWindow* window = NUX_STATIC_CAST(BaseWindow*, parent);
        window->_child_need_redraw = true;
      }
    }

    if (view->Type().IsDerivedFromType(BaseWindow::StaticObjectType))
    {
      // If the view is a BaseWindow, allow it to mark itself for redraw, as if it was its own  child.
      BaseWindow* window = NUX_STATIC_CAST(BaseWindow*, view);
      window->_child_need_redraw = true;
    }

    m_dirty_areas.push_back(geo);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::WindowThread::AsyncWakeUpCallback ( void *  user_ptr) [private]

Custom callback to wake up the main thread and start the execution loop.

This function is executed when async_wake_up_signal_ expires. It doesn't do anything when called, but the main thread will wake up and start the execution loop.

See also:
async_wake_up_signal_
Parameters:
user_ptrPointer to user data.

Definition at line 160 of file WindowThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::NThread::Attach ( ThreadRoutineFunc  lpThreadFunc) [inline, inherited]

Info: Attaches a Thread Function.

Used primarily for porting but can serve in developing generic thread objects

Definition at line 352 of file ThreadGNU.h.

    {
      m_pThreadFunc = lpThreadFunc;
    }

Here is the caller graph for this function:

Call event inspectors.

Call event inspectors to have a look at the event.

Returns:
True if the event should be discarded.
void nux::WindowThread::ChildHasFinished ( AbstractThread app) [protected, virtual]

Implements nux::AbstractThread.

Definition at line 740 of file WindowThread.cpp.

  {
    RemoveChildThread(thread);

    if (thread->Type().IsObjectType(WindowThread::StaticObjectType))
    {
      SuspendChildGraphics(static_cast<WindowThread*> (thread));
    }

    thread->SetThreadState(THREADSTOP);
  }

Here is the call graph for this function:

Definition at line 1239 of file WindowThread.cpp.

  {
    m_dirty_areas.clear();
  }

Definition at line 204 of file WindowThread.cpp.

void nux::WindowThread::ComputeElementLayout ( Area bo,
bool  recurse_to_top_level_layout = false 
)

Compute the layout of a specific element.

Immediate size negotiation for a View or a layout.

Definition at line 349 of file WindowThread.cpp.

  {
    NUX_RETURN_IF_NULL(area);

    bool alreadyComputingLayout = IsInsideLayoutCycle();

    if ((!alreadyComputingLayout) && (!recurse_to_top_level_layout))
    {
      // When computing the layout, setting the size of widgets may cause the system to recurse 
      // upward an look for the up most container which size is affected by its this area.
      // This happens in Area::InitiateResizeLayout();
      // The search upward is not done if we are already in a layout cycle.
      StartLayoutCycle();
    }

    if (area->Type().IsDerivedFromType(View::StaticObjectType))
    {
      View *ic = NUX_STATIC_CAST(View *, area);
      ic->QueueDraw();
    }
    else if (area->Type().IsDerivedFromType(Layout::StaticObjectType))
    {
      Layout *layout = NUX_STATIC_CAST(Layout *, area);
      layout->QueueDraw();
    }

    area->ComputeContentSize();

    if (!alreadyComputingLayout)
      StopLayoutCycle();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Execute the size computation cycle on objects.

Definition at line 299 of file WindowThread.cpp.

  {
    StartLayoutCycle();
    std::list<Area *>::iterator it;

    for (it = _queued_layout_list.begin(); it != _queued_layout_list.end(); it++)
    {
      Area *area = *it;

      if (area->Type().IsDerivedFromType(View::StaticObjectType))
      {
        View *view  = NUX_STATIC_CAST(View *, area);

        if (!view->CanBreakLayout())
          view->QueueDraw();
      }
      else if (area->Type().IsDerivedFromType(Layout::StaticObjectType))
      {
        Layout *layout = NUX_STATIC_CAST(Layout *, area);
        layout->QueueDraw();
      }
      else
      {
        continue;
      }

      (*it)->ComputeContentSize();
    }

    StopLayoutCycle();
    
    RemoveQueuedLayout();
  }

Here is the call graph for this function:

void nux::NThread::Detach ( void  ) [inline, inherited]

Info: Detaches the Attached Thread Function.

Detaches the Attached Thread Function, If any. by resetting the thread function pointer to EntryPoint1

Definition at line 363 of file ThreadGNU.h.

Here is the call graph for this function:

Enable Win32 Mouse and Keyboard inputs for this window thread and its child thread that are also window (not SystemThread).

Definition at line 940 of file WindowThread.cpp.

  {
    std::list<AbstractThread*>::iterator it;

    for (it = children_thread_list_.begin(); it != children_thread_list_.end(); it++)
    {
      if (NUX_STATIC_CAST(WindowThread *, *it)->Type().IsObjectType(WindowThread::StaticObjectType))
      {
        NUX_STATIC_CAST(WindowThread *, *it)->DisableMouseKeyboardInput();
      }
    }

    // WIN32: Disable Mouse and Keyboard inputs for all windows child of this window
#if defined(NUX_OS_WINDOWS)
    ::EnableWindow(graphics_display_->GetWindowHandle(), FALSE);
#elif defined(NUX_OS_LINUX)

#endif
    wait_for_modal_window_ = true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Suspend Win32 Mouse and Keyboard inputs for this window thread and its child thread that are also window (not SystemThread).

Definition at line 919 of file WindowThread.cpp.

  {
    std::list<AbstractThread*>::iterator it;

    for (it = children_thread_list_.begin(); it != children_thread_list_.end(); it++)
    {
      if (NUX_STATIC_CAST(WindowThread *, *it)->Type().IsObjectType(WindowThread::StaticObjectType))
      {
        NUX_STATIC_CAST(WindowThread *, *it)->EnableMouseKeyboardInput();
      }
    }

    // WIN32: Enable Mouse and Keyboard inputs for all windows child of this window
#if defined(NUX_OS_WINDOWS)
    ::EnableWindow(graphics_display_->GetWindowHandle(), TRUE);
#elif defined(NUX_OS_LINUX)

#endif
    wait_for_modal_window_ = false;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void * nux::NThread::EntryPoint ( void *  pArg) [static, protected, inherited]

Info: DONT override this method.

This function is like a standard template. Override if you are sure of what you are doing.

In C++ the entry function of a thread cannot be a normal member function of a class. However, it can be a static member function of a class. This is what we will use as the entry point. There is a gotcha here though. Static member functions do not have access to the this pointer of a C++ object. They can only access static data. Fortunately, there is way to do it. Thread entry point functions take a void * as a parameter so that the caller can typecast any data and pass in to the thread. We will use this to pass this to the static function. The static function will then typecast the void * and use it to call a non static member function

Definition at line 199 of file ThreadGNU.cpp.

  {
    NThread *pParent = reinterpret_cast<NThread *> (pArg);

    if (pParent == 0)
    {
      nuxDebugMsg (TEXT ("[NThread::EntryPoint] Invalid pointer. The thread will exit.") );
      return 0;
    }

    if (!pParent->ThreadCtor() )
    {
      // return another message saying the thread could not execute due to error in ThreadCtor;
    }

    pParent->Run ( pParent->m_ThreadCtx.m_pUserData );

    pParent->ThreadDtor();
    return 0;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int nux::WindowThread::ExecutionLoop ( ) [protected]

Entire frame of goes through this function.

It does the following: get the input events from the mouse, keyboard, touchpad processes the input events resizes views draw the frame This function is called when there is an input event or when a timer has expired.

Parameters:
timer_idThe id of the timer that has has expired.

Definition at line 497 of file WindowThread.cpp.

  {
    Event event;

    if (!IsEmbeddedWindow() && graphics_display_->IsPauseThreadGraphicsRendering())
    {
      // Do not sleep. Just return and let the GraphicsDisplay::SwapBuffer do the sleep if necessary.
      return 0;
    }

#if (!defined(NUX_OS_LINUX) && !defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) || defined(NUX_DISABLE_GLIB_LOOP)
    while (true)
#endif
    {
      _inside_main_loop = true;

      if (first_pass_)
      {
        // Reset the timers that were called before the mainloop got initialized.
        GetTimer().StartEarlyTimerObjects();
      }

      memset(&event, 0, sizeof(Event));
      graphics_display_->GetSystemEvent(&event);

      if ((event.type == NUX_DND_ENTER_WINDOW) ||
        (event.type == NUX_DND_LEAVE_WINDOW))
      {
        GetWindowCompositor().ResetDnDArea();
      }

      // Call event inspectors.
      CallEventInspectors(&event);

      if ((event.type == NUX_TERMINATE_APP) || (this->GetThreadState() == THREADSTOP))
      {
          return 0;
      }
      
      if (event.type == NUX_SIZE_CONFIGURATION)
      {
        window_size_configuration_event_ = true;
        Rect r = graphics_display_->GetWindowGeometry();
        window_configuration.emit(r.x, r.y, r.width, r.height);
      }

      int w, h;
      // Call gGfx_OpenGL.getWindowSize after the gGfx_OpenGL.get_event.
      // Otherwise, w and h may not be correct for the current frame if a resizing happened.
      graphics_display_->GetWindowSize(w, h);

      if ((event.type == NUX_MOUSE_PRESSED) ||
          (event.type == NUX_MOUSE_RELEASED) ||
          (event.type == NUX_MOUSE_DOUBLECLICK) ||
          (event.type == NUX_MOUSE_MOVE) ||
          (event.type == NUX_SIZE_CONFIGURATION) ||
          (event.type == NUX_KEYDOWN) ||
          (event.type == NUX_KEYUP) ||
          (event.type == NUX_NC_WINDOW_CONFIGURATION) ||
          (event.type == NUX_WINDOW_ENTER_FOCUS) ||
          (event.type == NUX_WINDOW_EXIT_FOCUS) ||
          (event.type == NUX_WINDOW_MOUSELEAVE) ||
          (event.type == NUX_DND_MOVE) ||
          (event.type == NUX_DND_DROP) ||
          (event.type == NUX_DND_ENTER) ||
          (event.type == NUX_DND_LEAVE) ||
          (event.type == NUX_MOUSE_WHEEL))
      {
          //DISPATCH EVENT HERE
          //event.Application = Application;
          window_compositor_->ProcessEvent(event);
      }

      if (event.type == NUX_SIZE_CONFIGURATION)
      {
          if (!graphics_display_->isWindowMinimized())
          {
              graphics_display_->SetViewPort(0, 0, event.width, event.height);
              ReconfigureLayout();
              window_compositor_->FormatRenderTargets(event.width, event.height);
          }
          window_compositor_->FloatingAreaConfigureNotify(event.width, event.height);
          window_size_configuration_event_ = true;
      }

      // Some action may have caused layouts and areas to request a recompute. 
      // Process them here before the Draw section.
      if (!graphics_display_->isWindowMinimized() && !IsEmbeddedWindow())
      {
        if (queue_main_layout_)
        {
          ReconfigureLayout();
        }
        else 
        {
          // Compute the layouts that have been queued.
          ComputeQueuedLayout();
        }
      }
      
      _inside_main_loop = false;

      if (!graphics_display_->IsPauseThreadGraphicsRendering() || IsEmbeddedWindow())
      {
        bool SwapGLBuffer = false;
        
        // Warn the host window manager to initiate a draw cycle.
        bool request_draw_cycle_to_host_wm = false;

        if (first_pass_)
        {
          if (IsEmbeddedWindow())
          {
            request_draw_cycle_to_host_wm = true;
            force_rendering_ = true;
          }
          else
          {
            window_compositor_->Draw(window_size_configuration_event_, true);
          }
          first_pass_ = false;
        }
        else
        {
          bool b = (event.type == NUX_MOUSE_PRESSED) ||
                   (event.type == NUX_MOUSE_RELEASED) ||
                   (event.type == NUX_MOUSE_DOUBLECLICK) ||
                   //(event.type == NUX_MOUSE_MOVE) ||
                   (event.type == NUX_SIZE_CONFIGURATION) ||
                   (event.type == NUX_KEYDOWN) ||
                   (event.type == NUX_KEYUP) ||
                   (event.type == NUX_NC_WINDOW_CONFIGURATION) ||
                   (event.type == NUX_WINDOW_ENTER_FOCUS) ||
                   (event.type == NUX_WINDOW_EXIT_FOCUS) ||
                   (event.type == NUX_WINDOW_DIRTY);

          if (b && window_compositor_->IsTooltipActive())
          {
            // Cancel the tooltip since an event that should cause the tooltip to disappear has occurred.
            window_compositor_->CancelTooltip();
            b |= true;
          }

          if (!window_compositor_->ValidateMouseInsideTooltipArea(event.x, event.y) && window_compositor_->IsTooltipActive())
          {
            // Cancel the tooltip since an event that should cause the tooltip to disappear has occurred.
            window_compositor_->CancelTooltip();
            b |= true;
          }

          if (b || IsRedrawNeeded())
          {
            if (IsEmbeddedWindow())
            {
              request_draw_cycle_to_host_wm = true;
            }
            else
            {
              window_compositor_->Draw(window_size_configuration_event_, false);
            }
            SwapGLBuffer = true;
          }
          else if (window_compositor_->GetWidgetDrawingOverlay() != 0)
          {
            if (IsEmbeddedWindow())
            {
              request_draw_cycle_to_host_wm = true;
            }
            else
            {
              window_compositor_->Draw(window_size_configuration_event_, false);
            }
            SwapGLBuffer = false;
          }

        }

        if (!IsEmbeddedWindow())
        {
          if (SwapGLBuffer)
          {
            // Something was rendered! Swap the rendering buffer!
            graphics_display_->SwapBuffer(true);
          }

          ClearRedrawFlag();
          GetWindowThread()->GetGraphicsEngine().ResetStats();
        }
        else if (IsEmbeddedWindow() && (_draw_requested_to_host_wm == false) && request_draw_cycle_to_host_wm)
        {
          RequestRedraw();
        }
        window_size_configuration_event_ = false;
      }
    }

    return 1;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Exit from the WindowThread loop.

Exit the WindowThread loop.

Definition at line 135 of file WindowThread.cpp.

  {
#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
    StopGLibLoop();
#endif
  }

Here is the caller graph for this function:

Definition at line 1244 of file WindowThread.cpp.

  {
    return m_dirty_areas;
  }
unsigned int nux::NThread::GetExitCode ( ) const [inherited]

Info: Starts the thread.

This function starts the thread pointed by m_pThreadFunc with default attributes

Definition at line 220 of file ThreadGNU.cpp.

Get the graphics display (this is the physical window of this thread).

Returns:
The graphics display.

Here is the caller graph for this function:

Get the graphics engine (this is the object that renders the graphics primitives).

Returns:
The graphics display.

Here is the caller graph for this function:

Get the layout of this window.

Returns:
The layout of this window.

Definition at line 236 of file WindowThread.cpp.

  {
    return main_layout_;
  }

Here is the caller graph for this function:

Get the painter object.

Returns:
The painter object.

Here is the caller graph for this function:

pthread_t nux::NThread::GetPThread ( ) [inherited]

Definition at line 225 of file ThreadGNU.cpp.

  {
    return m_ThreadCtx.m_dwTID;
  }

Here is the caller graph for this function:

Get the UI resource manager (load textures and other data for user interface rendering).

Parameters:
Theui resource manager.

Definition at line 230 of file ThreadGNU.cpp.

  {
    return m_ThreadState;
  }

Here is the caller graph for this function:

Get the timer manager.

Returns:
The timer manager.

Here is the caller graph for this function:

Get the UI compositor (this is processes events and renders ui objects).

Returns:
The UI compositor.

Here is the caller graph for this function:

std::string nux::WindowThread::GetWindowTitle ( ) const

Return the Window title.

Returns:
The window title.
int nux::WindowThread::InstallEventInspector ( EventInspector  function,
void *  data 
)

Set an event inspector function.

Inspect all events and returns the action to be taken for the event(process or discard).

If function as already been added, return its unique id.
If function is null, return 0.

Parameters:
functionEvent inspector function callback.
dataUser defined data.
Returns:
Unique id for the event inspector callback.
bool nux::WindowThread::IsComputingLayout ( ) const [inline]

Deprecated. Replace with IsInsideLayoutCycle.

Definition at line 163 of file WindowThread.h.

    {
      return IsInsideLayoutCycle();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Return true if this windowThread is embedded inside Compiz.

Returns:
True if embedded inside Compiz.

Definition at line 1249 of file WindowThread.cpp.

  {
    return embedded_window_;
  }

Here is the caller graph for this function:

Return true if the process is inside a layout cycle.

Returns:
True if the process is inside a layout cycle.

Definition at line 344 of file WindowThread.cpp.

  {
    return _inside_layout_cycle;
  }

Here is the caller graph for this function:

Return true if this window is modal.

Returns:
True if this window is modal.

Definition at line 709 of file WindowThread.cpp.

  {
    return is_modal_window_;
  }

Definition at line 209 of file WindowThread.cpp.

Return true while waiting for a modal window to return.

Returns:
True while waiting for a modal window to return.

Definition at line 704 of file WindowThread.cpp.

void nux::AbstractThread::JoinChildThreads ( ) [protected, inherited]

Definition at line 59 of file AbstractThread.cpp.

  {
#if defined(NUX_OS_WINDOWS)
    size_t sz = children_thread_list_.size();

    if (sz == 0)
    {
      return;
    }

    HANDLE *hdl = new HANDLE[sz];

    int i = 0;
    std::list<AbstractThread*>::iterator it;
    for (it = children_thread_list_.begin(); it != children_thread_list_.end(); ++it, ++i)
    {
      hdl[i] = (*it)->GetThreadHandle();
    }

    unsigned int result = WaitForMultipleObjects(sz, hdl, FALSE, INFINITE);
#else
  //#error WindowThread::JoinChildThreads has not been implemented for this platform.
  // Todo
#endif

    return;
  }

Here is the caller graph for this function:

ThreadWaitResult nux::NThread::JoinThread ( NThread thread,
unsigned int  milliseconds 
) [static, inherited]

Wait for a thread to complete.

The second parameters to this call specifies a how long to wait for the thread to complete. The following options are available: ThreadWaitTimeout::THREAD_WAIT_TIMEOUT_NONE: The function returns immediately if the thread exits. ThreadWaitTimeout::THREAD_WAIT_TIMEOUT_FOREVER: The function waits until the thread exits.

Parameters:
threadPointer to a valid NThread.
millisecondsTime to wait for the thread to complete.

Definition at line 240 of file ThreadGNU.cpp.

  {
    if (thread == NULL)
    {
      return THREAD_WAIT_RESULT_FAILED;
    }

    void *value_ptr = NULL;
    int result = pthread_join(thread->GetPThread(), &value_ptr);

    switch(result)
    {
    case 0:
      return THREAD_WAIT_RESULT_COMPLETED;
    default:
      return THREAD_WAIT_RESULT_FAILED;
    }
  }

Here is the call graph for this function:

int nux::WindowThread::MainLoop ( ) [private]

Execute the main loop of this thread.

Execute the main loop of this thread.

Returns:
And exit code. 0 if there was no error.

Definition at line 420 of file WindowThread.cpp.

  {
    if (IsEmbeddedWindow())
    {
      window_compositor_->FormatRenderTargets(graphics_display_->GetWindowWidth(), graphics_display_->GetWindowHeight());
      InitGlibLoop();
      RunGlibLoop();
      return 0;
    }
    else
    {
      graphics_display_->ShowWindow();
    }
    // Called the first time so we can initialize the size of the render targets
    // At this stage, the size of the window is known.
    window_compositor_->FormatRenderTargets(graphics_display_->GetWindowWidth(), graphics_display_->GetWindowHeight());

    while (GetThreadState() != THREADSTOP)
    {
      if (GetThreadState() == THREADRUNNING)
      {
#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
        InitGlibLoop();
        RunGlibLoop();
#else
        ExecutionLoop();
#endif

        if (parent_)
        {
          if (parent_->Type().IsObjectType(SystemThread::StaticObjectType))
            static_cast<SystemThread *> (parent_)->ChildHasFinished(this);

          if (parent_->Type().IsObjectType(WindowThread::StaticObjectType))
            static_cast<WindowThread *> (parent_)->ChildHasFinished(this);

          {
            SetThreadState(THREADSTOP);
            // All children window must be terminated.
            TerminateChildWindows();
            JoinChildThreads();

            std::list<AbstractThread*>::iterator it;
            for (it = children_thread_list_.begin(); it != children_thread_list_.end(); ++it)
            {
              delete (*it);
            }
            children_thread_list_.clear();
          }
        }
        else
        {
          SetThreadState(THREADSTOP);
          // All child window must be terminated.
          TerminateChildWindows();
          JoinChildThreads();

          std::list<AbstractThread*>::iterator it;
          for (it = children_thread_list_.begin(); it != children_thread_list_.end(); ++it)
          {
            delete (*it);
          }
          children_thread_list_.clear();
        }
      }
      else
      {
        // Do not sleep. Just return and let the GraphicsDisplay::SwapBuffer do the sleep if necessary.
      }
    }

    return 0;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

WindowThread* nux::WindowThread::operator& ( ) [private]

Reimplemented from nux::AbstractThread.

WindowThread& nux::WindowThread::operator= ( const WindowThread ) [private]
void nux::WindowThread::ProcessDraw ( GraphicsEngine graphics_engine,
bool  force_draw 
)

Definition at line 166 of file WindowThread.cpp.

  {
    if (main_layout_)
    {
      bool dirty = main_layout_->IsQueuedForDraw();

      if (dirty)
      {
        // A main layout re computation has happen. It was not initiated physically by resizing the window. We need to draw the background to
        // clean any dirty region.
        int buffer_width = graphics_engine.GetWindowWidth();
        int buffer_height = graphics_engine.GetWindowHeight();
        GetPainter().PaintBackground(graphics_engine, Geometry(0, 0, buffer_width, buffer_height));
      }

      main_layout_->ProcessDraw(graphics_engine, force_draw || dirty);
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::WindowThread::ProcessTimelines ( GTimeVal *  frame_time)

Definition at line 875 of file WindowThread.cpp.

  {
    // go through our timelines and tick them
    // return true if we still have active timelines

    long msecs;
    msecs = (frame_time->tv_sec - last_timeline_frame_time_sec_) * 1000 +
            (frame_time->tv_usec - last_timeline_frame_time_usec_) / 1000;

    if (msecs < 0)
    {
      last_timeline_frame_time_sec_ = frame_time->tv_sec;
      last_timeline_frame_time_usec_ = frame_time->tv_usec;
      return true;
    }

    if (msecs > 0)
    {
      last_timeline_frame_time_sec_ += msecs / 1000;
      last_timeline_frame_time_usec_ += msecs * 1000;
    }

    std::list<Timeline*>::iterator li;
    std::list<Timeline*> timelines_copy;

    for (li=_Timelines->begin(); li!=_Timelines->end(); ++li)
    {
      (*li)->Reference();
      timelines_copy.push_back((*li));
    }

    for(li=timelines_copy.begin(); li!=timelines_copy.end(); ++li)
    {
      (*li)->DoTick(msecs);
    }

    // unreference again
    for (li=timelines_copy.begin(); li!=timelines_copy.end(); ++li)
      (*li)->UnReference();

    // return if we have any timelines left
    return (_Timelines->size() != 0);
  }

Here is the caller graph for this function:

void nux::WindowThread::QueueLayout ( ) [protected]

Causes the Main layout to be recomputed.

Causes the main layout to be recomputed. This will happen just before the next draw cycle.

Definition at line 241 of file WindowThread.cpp.

Here is the call graph for this function:

Schedule a size computation cycle on an area before the rendering is performed.

This list contains the area whose size need to be computed.

Parameters:
areaThe object that will perform a size computation cycle.
See also:
ComputeQueuedLayout.
Returns:
True if the object was succefully queued.

Definition at line 265 of file WindowThread.cpp.

  {
    NUX_RETURN_VALUE_IF_NULL(area, false);

    std::list<Area *>::iterator it;
    it = find(_queued_layout_list.begin(), _queued_layout_list.end(), area);
    if (it == _queued_layout_list.end())
    {
      _queued_layout_list.push_back(area);
    }

    return true;
  }

Here is the caller graph for this function:

Compute the layout of this window thread.

Reconfigure the layout of this window. Start by setting the size of the layout to the size of this window. ReconfigureLayout is executed following an event of type NUX_SIZE_CONFIGURATION or a call to QueueMainLayout.

See also:
QueueMainLayout.

Definition at line 247 of file WindowThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::WindowThread::RemoveChildThread ( AbstractThread window) [protected, virtual]

Implements nux::AbstractThread.

Definition at line 728 of file WindowThread.cpp.

  {
    nuxAssert(window);
    std::list<AbstractThread*>::iterator it;
    it = find(children_thread_list_.begin(), children_thread_list_.end(), window);

    if (it != children_thread_list_.end())
    {
      children_thread_list_.erase(it);
    }
  }

Here is the caller graph for this function:

bool nux::WindowThread::RemoveEventInspector ( int  event_inspector_id)

Remove an event inspector.

Remove the event inspector identified by the provided unique id.

Parameters:
event_inspector_idUnique id for the event inspector.
Returns:
True If the event inspector exists and has been removed.

Remove an event inspector.

Remove the event inspector identified by the provided function.

Parameters:
functionEvent inspector function callback.
Returns:
True If the event inspector exists and has been removed.

Remove an area from the list of object whose size was scheduled to be computed before the rendering cycle.

Parameters:
areaThe object to remove form the list.
Returns:
True if the object was in the _queued_layout_list and has been removed.
See also:
ComputeQueuedLayout, QueueObjectLayout.

Definition at line 279 of file WindowThread.cpp.

  {
    NUX_RETURN_VALUE_IF_NULL(area, false);

    std::list<Area *>::iterator it;
    it = find(_queued_layout_list.begin(), _queued_layout_list.end(), area);

    if (it != _queued_layout_list.end())
    {
      _queued_layout_list.erase(it);
      return true;
    }
    return false;
  }

Here is the caller graph for this function:

Empty the queue of objects set for layout computation.

The queue was filled with calls to QueueObjectLayout.

Definition at line 294 of file WindowThread.cpp.

  {
    _queued_layout_list.clear();
  }

Here is the caller graph for this function:

Definition at line 388 of file WindowThread.cpp.

  {
    _Timelines->remove(timeline);
    if (_Timelines->size() == 0)
    {
      StopMasterClock();
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Render the interface.

This command is send from the pluging when the window thread is embedded. The clip region matches the surface of one single monitor screen, or a region inside that screen.

See also:
IsEmbeddedWindow.
Parameters:
clipRegion of the display to render.

Definition at line 185 of file WindowThread.cpp.

  {
    _draw_requested_to_host_wm = true;
    RedrawRequested.emit();
    
    if (!IsEmbeddedWindow())
    {
      // If the system is not in embedded mode and an asynchronous request for a Draw is made,
      // and the system is not in a timer processing cycle(always followed by a draw cycle) 
      // or not in the event processing cycle(also followed by a draw cycle), then we set a 0 delay 
      // timer that will wake up the system and initiate a draw cycle.
      if ((_inside_main_loop == false) && (_inside_timer_loop == false) && (_pending_wake_up_timer == false))
      {
        _pending_wake_up_timer = true;
        async_wake_up_timer_handle_ = this->GetTimerHandler().AddTimerHandler(0, async_wake_up_signal_, this);
      }
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 180 of file ThreadGNU.cpp.

  {
    return m_ThreadState;
  }

Definition at line 193 of file ThreadGNU.cpp.

Definition at line 186 of file ThreadGNU.cpp.

int nux::WindowThread::Run ( void *  ptr = NULL) [virtual]

Start the WindowThread in the current Thread.

Run the main loop of the window.
; The function blocks until the the main loop is stopped.

Parameters:
ptrReserved.

Implements nux::AbstractThread.

Definition at line 397 of file WindowThread.cpp.

  {
    if (GetWindowThread() != this)
    {
      nuxDebugMsg("Cannot run a several WindowThreads in the same window.");
      return 1;
    }

    if (!IsEmbeddedWindow() && (thread_ctor_called_ == false))
    {
      nuxDebugMsg("Call WindowThread::Start to run this window in its own thread.");
      return 1;
    }

    if (user_init_func_ && (m_WidgetInitialized == false))
    {
      (*user_init_func_) (this, initialization_data_);
      m_WidgetInitialized = true;
    }

    return MainLoop();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

TimerHandle nux::WindowThread::SetAsyncTimerCallback ( int  time_ms,
TimeOutSignal timeout_signal,
void *  user_data 
)

Sets a timer from a different thread.

Sets a timer and a callback. When the timer expires, the callback is executed. This function is meant to be called from a different thread. This function very carefully avoid calling any thread specific objects (TLS).

Parameters:
time_msTimer delay in milliseconds.
timeout_signalPointer to a TimeOutSignal.
user_dataPointer to user data.
Returns:
A timer handle.

Definition at line 149 of file WindowThread.cpp.

  {
    if (timeout_signal == NULL)
      return TimerHandle();

    // Use "this->" because if called from a different thread, GetTimer and GetWindowThread are invalid.
    TimerHandle handle = this->GetTimerHandler().AddTimerHandler(time_ms, timeout_signal, user_data, this);

    return handle;
  }

Here is the call graph for this function:

Set the layout for this window thread.

Parameters:
layoutThe layout of the user interface.

Definition at line 214 of file WindowThread.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::NThread::SetThreadState ( ThreadState  state) [inherited]

Definition at line 235 of file ThreadGNU.cpp.

  {
    m_ThreadState = state;
  }

Here is the caller graph for this function:

Set the background for the window.

Set the background for the window.

Parameters:
background_layerbackground layer.

Definition at line 1199 of file WindowThread.cpp.

  {
    if (background_layer == NULL)
      return;

    if (window_compositor_)
      window_compositor_->SetBackgroundPaintLayer(background_layer);
  }

Here is the call graph for this function:

void nux::WindowThread::SetWindowSize ( int  width,
int  height 
)

Set window size.

Set window size.

Parameters:
widthWindow width.
heightWindow height.

Definition at line 1181 of file WindowThread.cpp.

  {
    if (graphics_display_)
    {
      if (IsEmbeddedWindow())
      {
        // This is a passive way to set the window size through out the NuxGraphics system. This call gets the 
        // current window size and sets its accordingly to all sub-system.
        graphics_display_->ResetWindowSize();
      }
      else
      {
        graphics_display_->SetWindowSize(width, height);
        ReconfigureLayout();
      }
    }
  }

Here is the call graph for this function:

ThreadState nux::WindowThread::Start ( void *  ptr = NULL) [virtual]

Start the user interface Window in it own thread.

Start return immediately after the thread is created.

   @param ptr Reserved.

Reimplemented from nux::NThread.

Definition at line 774 of file WindowThread.cpp.

  {
    if (!parent_)
    {
      return NThread::Start();
    }
    else
    {
      if (parent_->Type().IsObjectType(SystemThread::StaticObjectType))
      {
        return static_cast<SystemThread *> (parent_)->StartChildThread(this, true);
      }
      else if (parent_->Type().IsObjectType(WindowThread::StaticObjectType))
      {
        return static_cast<WindowThread *> (parent_)->StartChildThread(this, true);
      }

      nuxAssertMsg(0, "[WindowThread::Start] This should not happen.");
      return THREAD_START_ERROR;
    }
  }

Here is the call graph for this function:

ThreadState nux::WindowThread::StartChildThread ( AbstractThread thread,
bool  Modal 
) [protected, virtual]

Implements nux::AbstractThread.

Definition at line 796 of file WindowThread.cpp.

  {
    if (wait_for_modal_window_)
    {
      // This window is already waiting for a modal window. It cannot start another windows.
      return thread->GetThreadState();
    }

    ThreadState state = thread->NThread::Start();
    //if(state == THREADRUNNING)
    {
      if (thread->Type().IsObjectType(WindowThread::StaticObjectType))
      {
        // While the child window is being created, the rendering is paused.
        // This is necessary to active OpenGL objects context sharing.
        // Cancel the pause by sending the message NUX_THREADMSG_START_RENDERING to this thread.
        //graphics_display_->PauseThreadGraphicsRendering();

        if (static_cast<WindowThread *> (thread)->is_modal_window_)
        {
          DisableMouseKeyboardInput();
          modal_window_thread_ = static_cast<WindowThread *> (thread);
//                 std::list<NThread*>::iterator it;
//                 for (it = children_thread_list_.begin(); it != children_thread_list_.end(); it++)
//                 {
//                     static_cast<WindowThread*>(*it)->wait_for_modal_window_ = true;
//                     // WIN32: Disable Mouse and Keyboard inputs for all windows child of this window
//                     ::EnableWindow(static_cast<WindowThread*>(*it)->graphics_display_->GetWindowHandle(), FALSE);
//                 }
//                 // WIN32
//                 ::EnableWindow(graphics_display_->GetWindowHandle(), FALSE);
//                 wait_for_modal_window_ = true;
        }

        static_cast<WindowThread *> (thread)->wait_for_modal_window_ = false;

        AddChildThread(thread);
      }
    }
    return state;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Informs the system of the start of a layout cycle.

This call merely sets a flag to true or false. This flag is used to decided if some actions should be performed or not. Used by the system only.

Definition at line 333 of file WindowThread.cpp.

  {
    _inside_layout_cycle = true;
  }

Here is the caller graph for this function:

Definition at line 343 of file MainLoopGLib.cpp.

  {
    // if we are not embedded and don't have a context yet
    if (!IsEmbeddedWindow() && main_loop_glib_context_ == 0)
      return;

    if (_MasterClock == NULL)
    {
      GTimeVal time_val;
      // make a source for our master clock
      _MasterClock = g_source_new(&timeline_funcs, sizeof(GSource));

      g_source_set_priority(_MasterClock, G_PRIORITY_DEFAULT + 10);
      g_source_set_callback(_MasterClock, 0, this, 0);
      g_source_set_can_recurse(_MasterClock, TRUE);

      if (IsEmbeddedWindow())
        g_source_attach(_MasterClock, NULL);
      else if (main_loop_glib_context_ != 0)
        g_source_attach(_MasterClock, main_loop_glib_context_);


      g_get_current_time(&time_val);
      last_timeline_frame_time_sec_ = time_val.tv_sec;
      last_timeline_frame_time_usec_ = time_val.tv_usec;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ThreadState nux::NThread::Stop ( bool  bForceKill = false) [virtual, inherited]

Info: Stops the thread.

This function stops the current thread. We can force kill a thread which results in a TerminateThread.

Definition at line 159 of file ThreadGNU.cpp.

  {
    int ret = pthread_detach (m_ThreadCtx.m_dwTID);

    if (ret != 0)
    {
      nuxDebugMsg (TEXT ("[NThread::Stop] Cannot detach thread.") );
      m_ThreadState = THREAD_STOP_ERROR;
      return m_ThreadState;
    }

    m_ThreadState = THREADSTOP;
    return m_ThreadState;
  }

Here is the caller graph for this function:

Informs the system of the end of a layout cycle.

This call merely sets a flag to true or false. This flag is used to decided if some actions should be performed or not. Used by the system only.

Definition at line 338 of file WindowThread.cpp.

  {
    _inside_layout_cycle = false;
  }

Here is the caller graph for this function:

Definition at line 371 of file MainLoopGLib.cpp.

  {
    if (_MasterClock)
    {
      g_source_remove(g_source_get_id(_MasterClock));
      _MasterClock = NULL;
    }
  }

Here is the caller graph for this function:

Definition at line 174 of file ThreadGNU.cpp.

Definition at line 838 of file WindowThread.cpp.

  {
    if (wait_for_modal_window_)
    {
      if (modal_window_thread_ != thread)
      {
        nuxAssertMsg(0, "[WindowThread::SuspendChildGraphics] cannot supend thread that is not the modal window.");
        return thread->GetThreadState();
      }
    }

    ThreadState state = thread->GetThreadState();

    if (wait_for_modal_window_)
    {
      modal_window_thread_ = 0;

      EnableMouseKeyboardInput();
//         std::list<NThread*>::iterator it;
//         for (it = children_thread_list_.begin(); it != children_thread_list_.end(); it++)
//         {
//             static_cast<WindowThread*>(*it)->wait_for_modal_window_ = false;
//
//             // WIN32
//             ::EnableWindow(static_cast<WindowThread*>(*it)->graphics_display_->GetWindowHandle(), TRUE);
//         }
    }

    // WIN32
#if defined(NUX_OS_WINDOWS)
    ::EnableWindow(graphics_display_->GetWindowHandle(), TRUE);
#elif defined(NUX_OS_LINUX)

#endif
    return state;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nux::WindowThread::TerminateChildThreads ( ) [protected, virtual]

Implements nux::AbstractThread.

Definition at line 752 of file WindowThread.cpp.

  {
    std::list<AbstractThread*>::iterator it;

    for (it = children_thread_list_.begin(); it != children_thread_list_.end(); it++)
    {
      (*it)->SetThreadState(THREADSTOP);

      if ((*it)->Type().IsObjectType(WindowThread::StaticObjectType))
      {
        // Terminate by shutting down the main loop
        static_cast<WindowThread*>(*it)->ExitMainLoop();
      }

      if ((*it)->Type().IsObjectType(SystemThread::StaticObjectType))
      {
        // Just kill the thread
        static_cast<SystemThread*>(*it)->Stop(true);
      }
    }
  }

Here is the call graph for this function:

void nux::AbstractThread::TerminateChildWindows ( ) [protected, inherited]

Definition at line 45 of file AbstractThread.cpp.

  {
    std::list<AbstractThread*>::iterator it;

    for (it = children_thread_list_.begin(); it != children_thread_list_.end(); it++)
    {
      if ((*it)->Type().IsObjectType(WindowThread::StaticObjectType))
      {
        // Exit the main loop of a window.
        static_cast<WindowThread*>(*it)->ExitMainLoop();
      }
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::WindowThread::ThreadCtor ( ) [protected, virtual]

Constructor-like function for the thread.

Will be called by EntryPoint before executing the thread body. For the main window, ThreadCtor is called in nux::CreateMainWindow. ThreadCtor creates and initialize the following elements:

  • Graphics Window
  • Timer
  • Painter
  • Compositor
  • Theme engine After ThreadCtor is called, thread_ctor_called_ is set to true;

Reimplemented from nux::NThread.

Definition at line 961 of file WindowThread.cpp.

  {
    if(thread_ctor_called_)
    {
      nuxDebugMsg("[WindowThread::ThreadCtor] ThreadCtor should not be entered more than once per WindowThread.");
      return true;
    }

#if defined(NUX_OS_WINDOWS)
    SetWin32ThreadName(GetThreadId(), window_title_.c_str());
#endif

    if (RegisterNuxThread(this) == FALSE)
    {
      nuxDebugMsg("[WindowThread::ThreadCtor] Failed to register the WindowThread.");
      return false;
    }

    inlSetThreadLocalStorage(ThreadLocal_InalogicAppImpl, this);
    GraphicsDisplay *parent_window = NULL;

    if (parent_ && static_cast<WindowThread *> (parent_)->Type().IsObjectType(WindowThread::StaticObjectType))
    {
      parent_window = &static_cast<WindowThread *> (parent_)->GetGraphicsDisplay();
    }
    else
    {
      parent_window = NULL;
    }

    graphics_display_ = gGLWindowManager.CreateGLWindow(window_title_.c_str(), window_initial_width_, window_initial_height_, window_style_, parent_window, false);

    if (graphics_display_ == NULL)
    {
      nuxDebugMsg("[WindowThread::ThreadCtor] Failed to create the window.");
      return false;
    }

    if (parent_ && parent_->Type().IsObjectType(WindowThread::StaticObjectType))
    {
      // Cancel the effect of PauseThreadGraphicsRendering on the parent window.
      //PostThreadMessage(parent_->GetThreadId(), NUX_THREADMSG_START_RENDERING, (UINT_PTR)((void*)this), 0);
    }

    painter_ = new BasePainter(this);
    timer_manager_ = new TimerHandler(this);
    window_compositor_ = new WindowCompositor(this);

    SetThreadState(THREADRUNNING);
    thread_ctor_called_ = true;
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool nux::WindowThread::ThreadDtor ( ) [protected, virtual]

Destructor-like function for the thread.

Will be called by EntryPoint after executing the thread body. After ThreadDtor is called, thread_dtor_called_ is set to true. ThreadDtor is also called in the destructor of the WindowThread but is protected by thread_dtor_called_ so it is not called twice. In the case of the main window, ThreadDtor is called in the destructor of WindowThread.

Reimplemented from nux::NThread.

Definition at line 1141 of file WindowThread.cpp.

  {
    if(thread_dtor_called_)
    {
      return true;
    }

    // Cleanup
    RemoveQueuedLayout();

    window_compositor_->BeforeDestructor();

    if (main_layout_)
    {
      main_layout_->UnReference();
    }

    NUX_SAFE_DELETE(window_compositor_);
    NUX_SAFE_DELETE(timer_manager_);
    NUX_SAFE_DELETE(painter_);
    NUX_SAFE_DELETE(theme_);
    NUX_SAFE_DELETE(graphics_display_);

#if defined(NUX_OS_WINDOWS)
    PostThreadMessage(NUX_GLOBAL_OBJECT_INSTANCE(NProcess).GetMainThreadID(),
                       NUX_THREADMSG_THREAD_TERMINATED,
                       NUX_GLOBAL_OBJECT_INSTANCE(NProcess).GetCurrentThreadID(),
                       0);
#elif defined(NUX_OS_LINUX)

#else
#error PostThreadMessage not implemented for this platform.
#endif

    inlSetThreadLocalStorage(ThreadLocal_InalogicAppImpl, 0);
    UnregisterNuxThread(this);
    thread_dtor_called_ = true;
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class BasePainter [friend]

Definition at line 626 of file WindowThread.h.

WindowThread* CreateGUIThread ( const char *  WindowTitle,
int  width,
int  height,
WindowThread Parent,
ThreadUserInitFunc  UserInitFunc,
void *  InitData 
) [friend]

Create a Nux window.

Create a Nux window. The window

Parameters:
window_titleThe window title.
widthThe window width.
heightThe window height.
parentThe window height parent. Should be NULL.
user_init_funcInitialization function to be called before starting the window loop.
dataParameter to the initialization function.

Definition at line 61 of file Nux.cpp.

  {
    return CreateNuxWindow(window_title, width, height, WINDOWSTYLE_NORMAL, parent, false, user_init_func, data);
  }
WindowThread* CreateModalWindowThread ( WindowStyle  WndStyle,
const char *  WindowTitle,
int  width,
int  height,
WindowThread Parent,
ThreadUserInitFunc  UserInitFunc,
void *  InitData 
) [friend]
Parameters:
window_styleThe window style.
window_titleThe window title.
widthThe window width.
heightThe window height.
parentThe window height parent. Should be NULL.
user_init_funcInitialization function to be called before starting the window loop.
dataParameter to the initialization function.

Definition at line 251 of file Nux.cpp.

  {
    if (width <= WindowThread::MINIMUM_WINDOW_WIDTH)
    {
      width = WindowThread::MINIMUM_WINDOW_WIDTH;
    }

    if (height <= WindowThread::MINIMUM_WINDOW_HEIGHT)
    {
      height = WindowThread::MINIMUM_WINDOW_HEIGHT;
    }

    WindowThread *w = _CreateModalWindowThread(window_title, width, height, parent, user_init_func, data, true);

    if (w == 0)
    {
      nuxDebugMsg("[CreateWindowThread] WindowThread creation failed.");
      return NULL;
    }

    w->user_init_func_ = user_init_func;
    w->user_exit_func_ = 0;
    w->initialization_data_ = data;
    w->window_style_ = WndStyle;

    return w;
  }
WindowThread* CreateNuxWindow ( const char *  WindowTitle,
int  width,
int  height,
ThreadUserInitFunc  UserInitFunc,
void *  InitData 
) [friend]
WindowThread* CreateNuxWindow ( const char *  window_title,
int  width,
int  height,
WindowStyle  window_border_style,
AbstractThread parent,
bool  modal,
ThreadUserInitFunc  user_init_func,
void *  data 
) [friend]

Create the only Nux window for the current system thread.

There can be only one NuxWindow per system thread. This function creates the only Nux window allowed in the current thread.
The first time this function is called in the current system thread, it returns a valid pointer to a NuxWindow object. The next time it is called, the system detects that a NuxWindow has already been created in the thread and it returns NULL.
When CreateNuxWindow successfully returns, the NuxWindow internals (GraphicsDisplay, Compositor, Painter, TimerManager) have been initialized. Calling nux::GetThreadNuxWindow() returns a pointer to the NuxWindow that has been successfully created in the current thread.
To start the main loop of a NuxWindow created with CreateNuxWindow, call NuxWindow::Run();
The modal parameter specifies if the window is blocking while it is active. This is valid only if the parent thread is a WindowThread.

Parameters:
window_titleThe window title.
widthThe window width.
heightThe window height.
window_border_styleThe window border style.
parentThe window parent.
modalModality of the window.
user_init_funcInitialization function to be called before starting the window loop.
dataParameter to the initialization function.
Returns:
A valid pointer to a NuxWindow if the window has been successfully created. NULL otherwise.

Definition at line 71 of file Nux.cpp.

  {
    if (GetWindowThread())
    {
      // An WindowThread already exist for this thread.
      nuxDebugMsg("[CreateGUIThread] You may have only one Nux window per system thread.");
      return NULL;
    }

    modal = (modal && parent && parent->Type().IsObjectType(WindowThread::StaticObjectType));

    if (width <= WindowThread::MINIMUM_WINDOW_WIDTH)
    {
      width = WindowThread::MINIMUM_WINDOW_WIDTH;
    }
    
    if (height <= WindowThread::MINIMUM_WINDOW_HEIGHT)
    {
      height = WindowThread::MINIMUM_WINDOW_HEIGHT;
    }

    WindowThread *w = new WindowThread(window_title, width, height, parent, modal);

    if (w == NULL)
    {
      nuxDebugMsg("[CreateGUIThread] WindowThread creation failed.");
      return NULL;
    }

    w->user_init_func_ = user_init_func;
    w->user_exit_func_ = 0;
    w->initialization_data_ = data;
    w->window_style_ = window_border_style;
    w->ThreadCtor();
    return w;
  }
WindowThread* CreateNuxWindowNewThread ( const char *  window_title,
int  width,
int  height,
WindowStyle  window_border_style,
AbstractThread parent,
bool  modal,
ThreadUserInitFunc  user_init_func,
void *  data 
) [friend]

Create a Nux window to be run in a new thread.

Create a Nux window that will run in a new thread. Unlike CreateNuxWindow, CreateNuxWindowNewThread should always successfully return a valid NuxWindow pointer. However, the internal objects of the NuxWindow (GraphicsDisplay, Compositor, Painter, TimerManager) have not been initialized yet. So, calling NuxWindow::GetWindowCompositor(), NuxWindow::GetGraphicsDisplay() will fail.
To start the main loop of a NuxWindow created with CreateNuxWindow, call NuxWindow::Run();
The modal parameter specifies if the window is blocking its parent window while it is active. This is valid only if the parent thread is a WindowThread.

Parameters:
window_titleThe window title.
widthThe window width.
heightThe window height.
window_border_styleThe window border style.
parentThe window parent.
modalModality of the window.
user_init_funcInitialization function to be called before starting the window loop.
dataParameter to the initialization function.
Returns:
A valid pointer to a NuxWindow if the window has been successfully created. NULL otherwise.

Definition at line 115 of file Nux.cpp.

  {
    modal = (modal && parent && parent->Type().IsObjectType(WindowThread::StaticObjectType));

    if (width <= WindowThread::MINIMUM_WINDOW_WIDTH)
    {
      width = WindowThread::MINIMUM_WINDOW_WIDTH;
    }

    if (height <= WindowThread::MINIMUM_WINDOW_HEIGHT)
    {
      height = WindowThread::MINIMUM_WINDOW_HEIGHT;
    }

    WindowThread *w = new WindowThread(window_title, width, height, parent, modal);
    if (w == NULL)
    {
      nuxDebugMsg("[CreateNuxWindowNewThread] WindowThread creation failed.");
      return NULL;
    }

    w->user_init_func_ = user_init_func;
    w->user_exit_func_ = 0;
    w->initialization_data_ = data;
    w->window_style_ = window_border_style;
    // Do not call WindowThread::ThreadCtor();
    return w;
  }
SystemThread* CreateSystemThread ( AbstractThread Parent,
ThreadUserInitFunc  UserInitFunc,
void *  InitData 
) [friend]

Definition at line 285 of file Nux.cpp.

  {
    SystemThread *system_thread = new SystemThread(parent);
    
    if (system_thread == 0)
    {
      nuxDebugMsg("[CreateSimpleThread] SystemThread creation failed.");
      return NULL;
    }
    system_thread->user_init_func_ = user_init_func;
    system_thread->user_exit_func_ = 0;
    system_thread->initialization_data_ = data;
    return system_thread;
  }
WindowThread* CreateWindowThread ( WindowStyle  WndStyle,
const char *  WindowTitle,
int  width,
int  height,
WindowThread Parent,
ThreadUserInitFunc  UserInitFunc,
void *  InitData 
) [friend]
Parameters:
window_styleThe window style.
window_titleThe window title.
widthThe window width.
heightThe window height.
parentThe window parent.
user_init_funcInitialization function to be called before starting the window loop.
dataParameter to the initialization function.

Definition at line 216 of file Nux.cpp.

  {
    if (width <= WindowThread::MINIMUM_WINDOW_WIDTH)
    {
      width = WindowThread::MINIMUM_WINDOW_WIDTH;
    }

    if (height <= WindowThread::MINIMUM_WINDOW_HEIGHT)
    {
      height = WindowThread::MINIMUM_WINDOW_HEIGHT;
    }

    WindowThread *w = _CreateModalWindowThread(window_title, width, height, parent, user_init_func, data, false);

    if (w == 0)
    {
      nuxDebugMsg("[CreateWindowThread] WindowThread creation failed.");
      return NULL;
    }

    w->user_init_func_ = user_init_func;
    w->user_exit_func_ = 0;
    w->initialization_data_ = data;
    w->window_style_ = WndStyle;

    return w;
  }
friend class SystemThread [friend]

Definition at line 627 of file WindowThread.h.

friend class TimerHandler [friend]

Definition at line 625 of file WindowThread.h.


Member Data Documentation

Flags signaling that a draw cycle has been requested to the host window manager.

Definition at line 539 of file WindowThread.h.

Map of events inspectors.

Events inspectors get to examine events before they are processed. They may also stop an event from being processed if they return true. map of events inspectors

Definition at line 595 of file WindowThread.h.

This variable is true while we are computing the layout the starting from the outmost layout(the Main Layout);.

Definition at line 527 of file WindowThread.h.

Definition at line 515 of file WindowThread.h.

Definition at line 516 of file WindowThread.h.

GSource* nux::WindowThread::_MasterClock [private]

Definition at line 507 of file WindowThread.h.

Definition at line 517 of file WindowThread.h.

This list contains the layout that need to be recomputed following the resizing of one of the sub element.

Definition at line 523 of file WindowThread.h.

std::list<Timeline*>* nux::WindowThread::_Timelines [private]

Definition at line 532 of file WindowThread.h.

Definition at line 482 of file WindowThread.h.

Definition at line 483 of file WindowThread.h.

std::list<AbstractThread*> nux::AbstractThread::children_thread_list_ [protected, inherited]

Definition at line 52 of file AbstractThread.h.

True when running Ubuntu Unity+Nux has a plugin of Compiz.

Definition at line 567 of file WindowThread.h.

True when going through the ExecutionLoop for the first time.

Definition at line 534 of file WindowThread.h.

Definition at line 575 of file WindowThread.h.

Definition at line 547 of file WindowThread.h.

void* nux::AbstractThread::initialization_data_ [protected, inherited]

This pointer maybe set by the user in ThreadInitFunc and reused in ThreadExitFunc.

Definition at line 60 of file AbstractThread.h.

Definition at line 459 of file WindowThread.h.

Definition at line 234 of file WindowThread.h.

Definition at line 235 of file WindowThread.h.

Definition at line 524 of file WindowThread.h.

Definition at line 486 of file ThreadGNU.h.

NThreadContext nux::NThread::m_ThreadCtx [protected, inherited]

Attributes Section.

Info: Members of NThread

Definition at line 485 of file ThreadGNU.h.

std::list<NThread *> nux::AbstractThread::m_ThreadList [protected, inherited]

Definition at line 62 of file AbstractThread.h.

volatile ThreadState nux::NThread::m_ThreadState [protected, inherited]

Definition at line 386 of file ThreadGNU.h.

Definition at line 549 of file WindowThread.h.

Definition at line 540 of file WindowThread.h.

const int nux::WindowThread::MINIMUM_WINDOW_HEIGHT = 1 [static, private]

Minimum height allowed for a window.

Definition at line 623 of file WindowThread.h.

const int nux::WindowThread::MINIMUM_WINDOW_WIDTH = 1 [static, private]

Minimum width allowed for a window.

Definition at line 622 of file WindowThread.h.

Definition at line 461 of file WindowThread.h.

Definition at line 543 of file WindowThread.h.

Definition at line 53 of file AbstractThread.h.

Set to true to schedule a compute cycle on the main layout.

Definition at line 530 of file WindowThread.h.

Definition at line 240 of file WindowThread.h.

Definition at line 542 of file WindowThread.h.

True if the thread constructor has been called.

This is a form of per-WindowThread reentry protection.

Definition at line 556 of file WindowThread.h.

True if the thread destructor has been called.

This is a form of per-WindowThread reentry protection.

Definition at line 562 of file WindowThread.h.

Definition at line 544 of file WindowThread.h.

Definition at line 55 of file AbstractThread.h.

Definition at line 54 of file AbstractThread.h.

Definition at line 460 of file WindowThread.h.

Definition at line 548 of file WindowThread.h.

sigc::signal<void, int, int, int, int> nux::WindowThread::window_configuration

emmitted when the window Geometry changes.

Definition at line 241 of file WindowThread.h.

Window width at startup.

Definition at line 536 of file WindowThread.h.

Window height at startup.

Definition at line 535 of file WindowThread.h.

Record if there was a configuration nux_event(NUX_SIZE_CONFIGURATION) that requires a full redraw.

Used in the case where event processing and rendering are decoupled(with foreign windows).

Definition at line 573 of file WindowThread.h.

Definition at line 550 of file WindowThread.h.

std::string nux::WindowThread::window_title_ [private]

Window title.

Definition at line 537 of file WindowThread.h.


The documentation for this class was generated from the following files: