Louvre v2.14.0-1
C++ library for Wayland compositors
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
LClipboard Class Reference

Clipboard manager. More...

#include <LClipboard.h>

+ Inheritance diagram for LClipboard:

Classes

struct  MimeTypeFile
 Structure representing a Clipboard MIME type. More...
 

Public Member Functions

 LClipboard (const void *params) noexcept
 Constructor.
 
 ~LClipboard ()
 Desructor.
 
virtual bool setClipboardRequest (LClient *client, const LEvent &triggeringEvent)
 Client request to set the clipboard.
 
virtual bool persistentMimeTypeFilter (const std::string &mimeType) const
 Filter of persistent clipboard MIME types.
 
const std::vector< MimeTypeFile > & mimeTypes () const noexcept
 Access to the current clipboard MIME types.
 
- Public Member Functions inherited from LFactoryObject
Type factoryObjectType () const noexcept
 Gets the base factory object type.
 
- Public Member Functions inherited from LObject
 LObject (const LObject &) noexcept
 Copy constructor.
 
LObjectoperator= (const LObject &) noexcept
 Assignment operator (each object has its own individual LWeak reference count).
 
void setUserData (UIntPtr data) const noexcept
 Store an unsigned integer value/pointer.
 
UIntPtr userData () const noexcept
 Retrieves the stored unsigned integer value/pointer.
 

Additional Inherited Members

- Public Types inherited from LFactoryObject
enum class  Type : Int32
 Base factory object types. More...
 
- Protected Member Functions inherited from LObject
 LObject () noexcept=default
 Constructor of the LObject class.
 
virtual ~LObject () noexcept
 Destructor of the LObject class.
 
void notifyDestruction () noexcept
 Notifies the object destruction.
 

Detailed Description

Clipboard manager.

LClipboard lets you manage which clients can set the clipboard and also specify which MIME types to make persistent.

Clients can access the clipboard when one of their surfaces acquires keyboard focus.


Class Documentation

◆ Louvre::LClipboard::MimeTypeFile

struct Louvre::LClipboard::MimeTypeFile

Structure representing a Clipboard MIME type.

Class Members
string mimeType

Mime type string.

FILE * tmp { NULL }

Clipboard content for the MIME type (can be NULL).

Constructor & Destructor Documentation

◆ LClipboard()

LClipboard ( const void params)
noexcept

Constructor.

See also
LCompositor::createClipboardRequest().

◆ ~LClipboard()

~LClipboard ( )
inline

Desructor.

Member Function Documentation

◆ setClipboardRequest()

virtual bool setClipboardRequest ( LClient client,
const LEvent triggeringEvent 
)
virtual

Client request to set the clipboard.

Returning true grants the client permission to set the clipboard and false prohibits it.
Only a single client can set the clipboard at a time.

Default Implementation

bool LClipboard::setClipboardRequest(LClient *client, const LEvent &triggeringEvent)
{
switch (triggeringEvent.type())
{
return !seat()->pointer()->focus() || seat()->pointer()->focus()->client() == client;
return !seat()->keyboard()->focus() || seat()->keyboard()->focus()->client() == client;
for (LTouchPoint *tp : seat()->touch()->touchPoints())
if (tp->surface() && tp->surface()->client() == client)
}
return false;
}
Representation of a Wayland client.
Definition LClient.h:36
virtual bool setClipboardRequest(LClient *client, const LEvent &triggeringEvent)
Client request to set the clipboard.
Base class for events.
Definition LEvent.h:10
@ Pointer
Pointer event type.
@ Keyboard
Keyboard event type.
@ Touch
Touch event type.
Type type() const noexcept
Retrieves the type of the event.
Definition LEvent.h:57
LSurface * focus() const noexcept
Focused surface.
Definition LKeyboard.cpp:271
LSurface * focus() const noexcept
Gets the focused surface.
Definition LPointer.cpp:400
LPointer * pointer() const noexcept
Access to pointer events.
Definition LSeat.h:169
LKeyboard * keyboard() const noexcept
Access to keyboard events.
Definition LSeat.h:179
LClient * client() const noexcept
Client owner of the surface.
Definition LSurface.cpp:476
Touch point within a touch device.
Definition LTouchPoint.h:26
Weak reference to an LObject.
Definition LWeak.h:25
LSeat * seat() noexcept
Gets the compositor's seat.
Definition LCompositor.cpp:42

◆ persistentMimeTypeFilter()

virtual bool persistentMimeTypeFilter ( const std::string &  mimeType) const
virtual

Filter of persistent clipboard MIME types.

Keep the clipboard data for specific MIME types even after the client owning the clipboard data is disconnected.

Returns
true to make the MIME type persistent, false otherwise.

Default Implementation

bool LClipboard::persistentMimeTypeFilter(const std::string &mimeType) const
{
return
mimeType == "image/png" ||
mimeType == "text/uri-list" ||
mimeType == "UTF8_STRING" ||
mimeType == "COMPOUND_TEXT" ||
mimeType == "TEXT" ||
mimeType == "STRING" ||
mimeType == "text/plain;charset=utf-8" ||
mimeType == "text/plain";
}
virtual bool persistentMimeTypeFilter(const std::string &mimeType) const
Filter of persistent clipboard MIME types.

◆ mimeTypes()

const std::vector< LClipboard::MimeTypeFile > & mimeTypes ( ) const
noexcept

Access to the current clipboard MIME types.