Louvre  v2.9.0-1
C++ library for Wayland compositors
Classes | Public Member Functions | List of all members
LClipboard Class Reference

Clipboard manager. More...

+ Inheritance diagram for LClipboard:

Classes

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

Public Member Functions

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

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. More...
 
virtual ~LObject () noexcept
 Destructor of the LObject class. More...
 
void notifyDestruction () noexcept
 Notifies the object destruction. More...
 

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

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 true;
}
return false;
}
virtual bool setClipboardRequest(LClient *client, const LEvent &triggeringEvent)
Client request to set the clipboard.
@ Pointer
Pointer event type.
@ Keyboard
Keyboard event type.
@ Touch
Touch event type.
LSurface * focus() const noexcept
Focused surface.
Definition: LKeyboard.cpp:269
LSurface * focus() const noexcept
Gets the focused surface.
Definition: LPointer.cpp:400
LKeyboard * keyboard() const noexcept
Access to keyboard events.
Definition: LSeat.h:146
LPointer * pointer() const noexcept
Access to pointer events.
Definition: LSeat.h:136
LClient * client() const noexcept
Client owner of the surface.
Definition: LSurface.cpp:474
LSeat * seat() noexcept
Gets the compositor's seat.
Definition: LCompositor.cpp:40

◆ 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.