Louvre  v1.2.1-2
C++ library for Wayland compositors
List of all members | Public Member Functions
LScene Class Reference

#include <LScene.h>

The LScene class is an optional utility that significantly simplifies rendering. More...

Detailed Description

The LScene class is an optional utility that significantly simplifies rendering.

It encompasses a primary LSceneView which can host multiple children and even nested scenes. A single LScene can drive multiple outputs and also manage pointer and keyboard Wayland events, while also providing per-view input events. You might opt to leverage LScene for rendering instead of relying solely on the basic rendering functions from the LPainter class or your custom OpenGL shaders.

LScene achieves high efficiency by rendering only damaged regions and avoiding rendering content obscured by opaque areas.

Alternatively, you can still use your own OpenGL shaders or LPainter functions for rendering, either in conjunction with LScene or independently. These approaches can be applied before or after handlePaintGL() is invoked, or by creating your custom LView that overrides the LView::paintRect() virtual method.

Rendering

For proper rendering with LScene, you need to "plug" the following methods into each LOutput you intend to manage with LScene:

Warning
Make sure to "plug" the scene to all the output events mentioned earlier. Failing to do so may result in scene initialization issues, memory leaks, and potential compositor crashes.

For example, like this:

#include <LOutput.h>
class YourCustomOutput : public LOutput
{
LScene *scene;
...
void initializeGL(LOutput *output) override
{
scene->handleInitializeGL(output);
}
void paintGL(LOutput *output) override
{
scene->handlePaintGL(output);
}
void moveGL(LOutput *output) override
{
scene->handleMoveGL(output);
}
void resizeGL(LOutput *output) override
{
scene->handleResizeGL(output);
}
void uninitializeGL(LOutput *output) override
{
scene->handleUninitializeGL(output);
}
};
LScene()
Default constructor for LScene.
Definition: LScene.cpp:19

Pointer Events

Similar to rendering, you can integrate the handlePointerXXX methods into the LPointer class.
This enables LScene to dispatch pointer events to each LView, invoking methods such as LView::pointerEnterEvent(), LView::pointerMoveEvent(), and more. Additionally, the scene can manage pointer focus for LSurfaces and transmit pointer events accordingly to clients. You also have the option to disable this behavior if you prefer to handle this logic independently. To deactivate the handling of Wayland events, use the enableHandleWaylandPointerEvents() method.

Keyboard Events

Similar to rendering, you can integrate the handleKeyXXX methods into the LKeyboard class.
This empowers LScene to dispatch keyboard events to each LView, triggering methods like LView::keyEvent(), LView::keyModifiersEvent(), and more. Furthermore, the scene can manage keyboard focus for LSurfaces and transmit keyboard events correspondingly to clients. If desired, you can also opt to disable this behavior and manage the logic independently. To deactivate the handling of Wayland events, utilize the enableHandleWaylandKeyboardEvents() method.

Public Member Functions

 LScene ()
 Default constructor for LScene. More...
 
 ~LScene ()
 Destructor for LScene. More...
 
void handleInitializeGL (LOutput *output)
 Handle the OpenGL initialization for an LOutput. More...
 
void handlePaintGL (LOutput *output)
 Handle the OpenGL painting for an LOutput. More...
 
void handleMoveGL (LOutput *output)
 Handle the OpenGL movement for an LOutput. More...
 
void handleResizeGL (LOutput *output)
 Handle the OpenGL resizing for an LOutput. More...
 
void handleUninitializeGL (LOutput *output)
 Handle the OpenGL uninitialization for an LOutput. More...
 
LViewhandlePointerMoveEvent (Float32 x, Float32 y, bool absolute, LPoint *localPos=nullptr)
 Handle pointer movement event. More...
 
void handlePointerButtonEvent (LPointer::Button button, LPointer::ButtonState state)
 Handle pointer button event. More...
 
void handlePointerAxisEvent (Float64 axisX, Float64 axisY, Int32 discreteX, Int32 discreteY, LPointer::AxisSource source)
 Handle pointer axis event. More...
 
bool handleWaylandPointerEventsEnabled () const
 Check if handling of Wayland pointer events is enabled. More...
 
void enableHandleWaylandPointerEvents (bool enabled)
 Enable or disable handling of Wayland pointer events. More...
 
void handleKeyModifiersEvent (UInt32 depressed, UInt32 latched, UInt32 locked, UInt32 group)
 Handle key modifiers event. More...
 
void handleKeyEvent (UInt32 keyCode, LKeyboard::KeyState keyState)
 Handle key event. More...
 
bool handleWaylandKeyboardEventsEnabled () const
 Check if handling of Wayland keyboard events is enabled. More...
 
void enableHandleWaylandKeyboardEvents (bool enabled)
 Enable or disable handling of Wayland keyboard events. More...
 
bool auxKeyboardImplementationEnabled () const
 Check if auxiliary keyboard implementation is enabled. More...
 
void enableAuxKeyboardImplementation (bool enabled)
 Enable or disable auxiliary keyboard implementation. More...
 
LSceneViewmainView () const
 Retrieve the main view of the scene. More...
 
LViewviewAt (const LPoint &pos)
 Retrieve the view located at the specified position. More...
 
- Public Member Functions inherited from LObject
 LObject ()=default
 Constructor of the LObject class. More...
 
 ~LObject ()
 Destructor of the LObject class. More...
 
std::shared_ptr< const bool > isAlive () const
 Object's liveness status. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from LObject
static LCompositorcompositor ()
 Quick access to the global compositor instance. More...
 
static LSeatseat ()
 Quick access to the global seat instance. More...
 
static LCursorcursor ()
 Quick access to the global cursor instance. More...
 

Constructor & Destructor Documentation

◆ LScene()

LScene ( )

Default constructor for LScene.

◆ ~LScene()

~LScene ( )

Destructor for LScene.

Member Function Documentation

◆ handleInitializeGL()

void handleInitializeGL ( LOutput output)

Handle the OpenGL initialization for an LOutput.

This method should be integrated into LOutput::initializeGL() to properly handle OpenGL initialization for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL initialization for.

◆ handlePaintGL()

void handlePaintGL ( LOutput output)

Handle the OpenGL painting for an LOutput.

This method should be integrated into LOutput::paintGL() to properly handle OpenGL painting for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL painting for.

◆ handleMoveGL()

void handleMoveGL ( LOutput output)

Handle the OpenGL movement for an LOutput.

This method should be integrated into LOutput::moveGL() to properly handle OpenGL movement for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL movement for.

◆ handleResizeGL()

void handleResizeGL ( LOutput output)

Handle the OpenGL resizing for an LOutput.

This method should be integrated into LOutput::resizeGL() to properly handle OpenGL resizing for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL resizing for.

◆ handleUninitializeGL()

void handleUninitializeGL ( LOutput output)

Handle the OpenGL uninitialization for an LOutput.

This method should be integrated into LOutput::uninitializeGL() to properly handle OpenGL uninitialization for the associated output.

Parameters
outputThe LOutput instance to handle OpenGL uninitialization for.

◆ handlePointerMoveEvent()

LView * handlePointerMoveEvent ( Float32  x,
Float32  y,
bool  absolute,
LPoint localPos = nullptr 
)

Handle pointer movement event.

This method should be integrated into LPointer::pointerMoveEvent() to effectively manage pointer movement events.

Parameters
xThe x-component of the new pointer position or delta from its previous position.
yThe y-component of the new pointer position or delta from its previous position.
absoluteIf true, the (x, y) values represent absolute coordinates; if false, they are deltas from the previous position.
localPosLocal pos of the first view found under the cursor.
Returns
The first LView found under the cursor.

◆ handlePointerButtonEvent()

void handlePointerButtonEvent ( LPointer::Button  button,
LPointer::ButtonState  state 
)

Handle pointer button event.

This method should be integrated into LPointer::pointerButtonEvent() to handle pointer button events.

Parameters
buttonThe button involved in the event.
stateThe state of the button (pressed or released).

◆ handlePointerAxisEvent()

void handlePointerAxisEvent ( Float64  axisX,
Float64  axisY,
Int32  discreteX,
Int32  discreteY,
LPointer::AxisSource  source 
)

Handle pointer axis event.

This method should be integrated into LPointer::pointerAxisEvent() to manage pointer axis events.

Parameters
axisXThe x-axis value of the event.
axisYThe y-axis value of the event.
discreteXThe discrete value on the x-axis.
discreteYThe discrete value on the y-axis.
sourceThe source of the event.

◆ handleWaylandPointerEventsEnabled()

bool handleWaylandPointerEventsEnabled ( ) const

Check if handling of Wayland pointer events is enabled.

This method allows you to check whether the handling of Wayland pointer events is currently enabled.

Returns
True if Wayland pointer events handling is enabled, false otherwise.

◆ enableHandleWaylandPointerEvents()

void enableHandleWaylandPointerEvents ( bool  enabled)

Enable or disable handling of Wayland pointer events.

This method enables or disables the handling of Wayland pointer events by LScene.

Parameters
enabledTrue to enable handling of Wayland pointer events, false to disable.

◆ handleKeyModifiersEvent()

void handleKeyModifiersEvent ( UInt32  depressed,
UInt32  latched,
UInt32  locked,
UInt32  group 
)

Handle key modifiers event.

This method should be integrated into LKeyboard::keyModifiersEvent() to manage key modifiers events.

Parameters
depressedThe bitfield representing depressed modifiers.
latchedThe bitfield representing latched modifiers.
lockedThe bitfield representing locked modifiers.
groupThe keyboard group.

◆ handleKeyEvent()

void handleKeyEvent ( UInt32  keyCode,
LKeyboard::KeyState  keyState 
)

Handle key event.

This method should be integrated into LKeyboard::keyEvent() to handle key events.

Parameters
keyCodeThe code of the key involved in the event.
keyStateThe state of the key (pressed or released).

◆ handleWaylandKeyboardEventsEnabled()

bool handleWaylandKeyboardEventsEnabled ( ) const

Check if handling of Wayland keyboard events is enabled.

This method allows you to check whether the handling of Wayland keyboard events is currently enabled.

Returns
True if Wayland keyboard events handling is enabled, false otherwise.

◆ enableHandleWaylandKeyboardEvents()

void enableHandleWaylandKeyboardEvents ( bool  enabled)

Enable or disable handling of Wayland keyboard events.

This method enables or disables the handling of Wayland keyboard events by LScene.

Parameters
enabledTrue to enable handling of Wayland keyboard events, false to disable.

◆ auxKeyboardImplementationEnabled()

bool auxKeyboardImplementationEnabled ( ) const

Check if auxiliary keyboard implementation is enabled.

This method allows you to check whether auxiliary keyboard functions, such as closing the compositor with Ctrl + Alt + Esc, executing weston-terminal with F1, or modifying the drag-and-drop action with Shift, Alt, or Ctrl keys, are currently enabled.

Returns
True if auxiliary keyboard implementation is enabled, false otherwise.

◆ enableAuxKeyboardImplementation()

void enableAuxKeyboardImplementation ( bool  enabled)

Enable or disable auxiliary keyboard implementation.

This method enables or disables auxiliary keyboard functions, such as custom key actions.

Parameters
enabledTrue to enable auxiliary keyboard implementation, false to disable.

◆ mainView()

LSceneView * mainView ( ) const

Retrieve the main view of the scene.

This method returns the main LSceneView associated with the LScene.

Returns
A pointer to the main LSceneView of the scene.

◆ viewAt()

LView * viewAt ( const LPoint pos)

Retrieve the view located at the specified position.

This method returns the LView instance that occupies the given position within the scene.

Parameters
posThe position to query.
Returns
A pointer to the LView at the specified position, or nullptr if no view is found.