refactor: drop redundant clipboard read on selection owner change
This commit is contained in:
parent
d7d3f8d4c8
commit
67f6f893fa
2 changed files with 3 additions and 49 deletions
|
|
@ -207,8 +207,6 @@ PortalInputCapture::~PortalInputCapture()
|
||||||
g_signal_handler_disconnect(m_session, m_signals.at(Activated));
|
g_signal_handler_disconnect(m_session, m_signals.at(Activated));
|
||||||
g_signal_handler_disconnect(m_session, m_signals.at(Deactivated));
|
g_signal_handler_disconnect(m_session, m_signals.at(Deactivated));
|
||||||
g_signal_handler_disconnect(m_session, m_signals.at(ZonesChanged));
|
g_signal_handler_disconnect(m_session, m_signals.at(ZonesChanged));
|
||||||
|
|
||||||
g_signal_handler_disconnect(m_session, m_signals.at(SelectionOwnerChanged));
|
|
||||||
g_signal_handler_disconnect(m_session, m_signals.at(SelectionTransfer));
|
g_signal_handler_disconnect(m_session, m_signals.at(SelectionTransfer));
|
||||||
g_object_unref(m_session);
|
g_object_unref(m_session);
|
||||||
}
|
}
|
||||||
|
|
@ -337,40 +335,6 @@ void PortalInputCapture::readClipboardSelection(XdpSession *session)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortalInputCapture::handleSelectionOwnerChanged(XdpSession *session, GStrv mimeTypes, gboolean isOwner)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
|
||||||
LOG_DEBUG(
|
|
||||||
"selection owner changed, session owns: %s, mime types: %s", isOwner ? "yes" : "no",
|
|
||||||
mimeTypes ? formatMimeTypes(const_cast<const char **>(mimeTypes)).constData() : "(none)"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isOwner) {
|
|
||||||
LOG_DEBUG("ignoring selection owner change, session already owns the selection");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!mimeTypes) {
|
|
||||||
LOG_DEBUG("ignoring selection owner change, selection cleared");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pickSupportedMime(mimeTypes)) {
|
|
||||||
LOG_DEBUG("ignoring selection owner change, no supported mime types: %s", formatMimeTypes(mimeTypes).constData());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_screen->sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard);
|
|
||||||
|
|
||||||
if (!m_isActive) {
|
|
||||||
LOG_DEBUG("deferring clipboard read until input capture activates");
|
|
||||||
m_pendingClipboardRead = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
readClipboardSelection(session);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void PortalInputCapture::handleSelectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial)
|
void PortalInputCapture::handleSelectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
||||||
|
|
@ -488,8 +452,6 @@ void PortalInputCapture::setupSession(XdpInputCaptureSession *session)
|
||||||
handleZonesChanged(session, nullptr);
|
handleZonesChanged(session, nullptr);
|
||||||
|
|
||||||
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
||||||
m_signals.at(SelectionOwnerChanged) =
|
|
||||||
g_signal_connect(G_OBJECT(parentSession), "selection-owner-changed", G_CALLBACK(selectionOwnerChanged), this);
|
|
||||||
m_signals.at(SelectionTransfer) =
|
m_signals.at(SelectionTransfer) =
|
||||||
g_signal_connect(G_OBJECT(parentSession), "selection-transfer", G_CALLBACK(selectionTransfer), this);
|
g_signal_connect(G_OBJECT(parentSession), "selection-transfer", G_CALLBACK(selectionTransfer), this);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -895,7 +857,6 @@ void PortalInputCapture::handleActivated(
|
||||||
|
|
||||||
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
#ifdef HAVE_LIBPORTAL_CLIPBOARD
|
||||||
if (m_session) {
|
if (m_session) {
|
||||||
m_pendingClipboardRead = false;
|
|
||||||
LOG_DEBUG("reading clipboard selection on activation");
|
LOG_DEBUG("reading clipboard selection on activation");
|
||||||
m_screen->sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard);
|
m_screen->sendClipboardEvent(EventTypes::ClipboardGrabbed, kClipboardClipboard);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ private:
|
||||||
handleDeactivated(const XdpInputCaptureSession *session, const std::uint32_t activationId, const GVariant *options);
|
handleDeactivated(const XdpInputCaptureSession *session, const std::uint32_t activationId, const GVariant *options);
|
||||||
void handleZonesChanged(XdpInputCaptureSession *session, const GVariant *options);
|
void handleZonesChanged(XdpInputCaptureSession *session, const GVariant *options);
|
||||||
|
|
||||||
void handleSelectionOwnerChanged(XdpSession *session, GStrv mimeTypes, gboolean isOwner);
|
|
||||||
void handleSelectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial);
|
void handleSelectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial);
|
||||||
void readClipboardSelection(XdpSession *session);
|
void readClipboardSelection(XdpSession *session);
|
||||||
void claimClipboardOwnership(XdpSession *session);
|
void claimClipboardOwnership(XdpSession *session);
|
||||||
|
|
@ -112,10 +111,6 @@ private:
|
||||||
{
|
{
|
||||||
static_cast<PortalInputCapture *>(data)->handleZonesChanged(session, options);
|
static_cast<PortalInputCapture *>(data)->handleZonesChanged(session, options);
|
||||||
}
|
}
|
||||||
static void selectionOwnerChanged(XdpSession *session, GStrv mimeTypes, gboolean isOwner, const gpointer data)
|
|
||||||
{
|
|
||||||
static_cast<PortalInputCapture *>(data)->handleSelectionOwnerChanged(session, mimeTypes, isOwner);
|
|
||||||
}
|
|
||||||
static void selectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial, const gpointer data)
|
static void selectionTransfer(XdpSession *session, const char *mimeType, uint32_t serial, const gpointer data)
|
||||||
{
|
{
|
||||||
static_cast<PortalInputCapture *>(data)->handleSelectionTransfer(session, mimeType, serial);
|
static_cast<PortalInputCapture *>(data)->handleSelectionTransfer(session, mimeType, serial);
|
||||||
|
|
@ -131,7 +126,6 @@ private:
|
||||||
ZonesChanged,
|
ZonesChanged,
|
||||||
|
|
||||||
// Clipboard signals
|
// Clipboard signals
|
||||||
SelectionOwnerChanged,
|
|
||||||
SelectionTransfer,
|
SelectionTransfer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -188,15 +182,14 @@ private:
|
||||||
XdpInputCaptureSession *m_session = nullptr;
|
XdpInputCaptureSession *m_session = nullptr;
|
||||||
|
|
||||||
std::map<Signal, gulong> m_signals = {
|
std::map<Signal, gulong> m_signals = {
|
||||||
{Signal::SessionClosed, 0}, {Signal::Disabled, 0}, {Signal::Activated, 0},
|
{Signal::SessionClosed, 0}, {Signal::Disabled, 0}, {Signal::Activated, 0},
|
||||||
{Signal::Deactivated, 0}, {Signal::ZonesChanged, 0},
|
{Signal::Deactivated, 0}, {Signal::ZonesChanged, 0},
|
||||||
|
|
||||||
{Signal::SelectionOwnerChanged, 0}, {Signal::SelectionTransfer, 0},
|
{Signal::SelectionTransfer, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
bool m_isActive = false;
|
bool m_isActive = false;
|
||||||
bool m_pendingClipboardRead = false;
|
|
||||||
std::uint32_t m_activationId = 0;
|
std::uint32_t m_activationId = 0;
|
||||||
|
|
||||||
std::vector<XdpInputCapturePointerBarrier *> m_barriers;
|
std::vector<XdpInputCapturePointerBarrier *> m_barriers;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue