Revert "Disable PrimarySelection in seat setPrimarySelection"
This reverts commit e60f26e0ab
.
Cancelling the primary selection breaks text selection in applications
such as gedit. In those apps, you can't select text neither with your
mouse nor keyboard.
BUG: 461498
This commit is contained in:
parent
c709511c81
commit
da229ebe85
7 changed files with 16 additions and 54 deletions
|
@ -202,7 +202,7 @@ void ApplicationWayland::refreshSettings(const KConfigGroup &group, const QByteA
|
|||
}
|
||||
|
||||
if (group.name() == "Wayland" && names.contains("EnablePrimarySelection")) {
|
||||
waylandServer()->seat()->setPrimarySelectionEnabled(group.readEntry("EnablePrimarySelection", true));
|
||||
waylandServer()->setEnablePrimarySelection(group.readEntry("EnablePrimarySelection", true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,16 +120,11 @@ public:
|
|||
void requestData(const QString &mimeType, qint32 fd) override
|
||||
{
|
||||
};
|
||||
void cancel() override
|
||||
{
|
||||
Q_EMIT cancelled();
|
||||
};
|
||||
void cancel() override{};
|
||||
QStringList mimeTypes() const override
|
||||
{
|
||||
return {"text/test1", "text/test2"};
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void cancelled();
|
||||
};
|
||||
|
||||
// The test itself
|
||||
|
@ -146,7 +141,6 @@ private Q_SLOTS:
|
|||
void testCopyFromControl();
|
||||
void testCopyFromControlPrimarySelection();
|
||||
void testKlipperCase();
|
||||
void testPrimarySelectionDisabled();
|
||||
|
||||
private:
|
||||
KWayland::Client::ConnectionThread *m_connection;
|
||||
|
@ -302,32 +296,6 @@ void DataControlInterfaceTest::testCopyToControlPrimarySelection()
|
|||
QCOMPARE(offer->receivedOffers()[1], "text/test2");
|
||||
}
|
||||
|
||||
void DataControlInterfaceTest::testPrimarySelectionDisabled()
|
||||
{
|
||||
// we set a dummy data source on the seat using abstract client directly
|
||||
// then confirm we receive the offer despite not having a surface
|
||||
|
||||
// disable primary selection
|
||||
m_seat->setPrimarySelectionEnabled(false);
|
||||
|
||||
std::unique_ptr<DataControlDevice> dataControlDevice(new DataControlDevice);
|
||||
dataControlDevice->init(m_dataControlDeviceManager->get_data_device(*m_clientSeat));
|
||||
|
||||
QSignalSpy newOfferSpy(dataControlDevice.get(), &DataControlDevice::dataControlOffer);
|
||||
QSignalSpy selectionSpy(dataControlDevice.get(), &DataControlDevice::primary_selection);
|
||||
|
||||
std::unique_ptr<TestDataSource> testSelection(new TestDataSource);
|
||||
QSignalSpy cancelSpy(testSelection.get(), &TestDataSource::cancelled);
|
||||
|
||||
m_seat->setPrimarySelection(testSelection.get());
|
||||
|
||||
// selection will be sent after we've been sent a new offer object and the mimes have been sent to that object
|
||||
cancelSpy.wait();
|
||||
|
||||
QCOMPARE(newOfferSpy.count(), 0);
|
||||
QCOMPARE(cancelSpy.count(), 1);
|
||||
}
|
||||
|
||||
void DataControlInterfaceTest::testCopyFromControl()
|
||||
{
|
||||
// we create a data device and set a selection
|
||||
|
|
|
@ -1291,14 +1291,6 @@ AbstractDataSource *SeatInterface::primarySelection() const
|
|||
return d->currentPrimarySelection;
|
||||
}
|
||||
|
||||
void SeatInterface::setPrimarySelectionEnabled(bool enabled)
|
||||
{
|
||||
if (enabled != d->primarySelectionEnabled) {
|
||||
setPrimarySelection(nullptr);
|
||||
d->primarySelectionEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
void SeatInterface::setPrimarySelection(AbstractDataSource *selection)
|
||||
{
|
||||
if (d->currentPrimarySelection == selection) {
|
||||
|
@ -1309,13 +1301,6 @@ void SeatInterface::setPrimarySelection(AbstractDataSource *selection)
|
|||
disconnect(d->currentPrimarySelection, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
if (!d->primarySelectionEnabled) {
|
||||
if (selection) {
|
||||
selection->cancel();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection) {
|
||||
auto cleanup = [this]() {
|
||||
setPrimarySelection(nullptr);
|
||||
|
|
|
@ -170,8 +170,6 @@ public:
|
|||
void setTimestamp(quint32 time);
|
||||
quint32 timestamp() const;
|
||||
|
||||
void setPrimarySelectionEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @name Drag'n'Drop related methods
|
||||
*/
|
||||
|
|
|
@ -67,7 +67,6 @@ public:
|
|||
// the last thing copied into the clipboard content
|
||||
AbstractDataSource *currentSelection = nullptr;
|
||||
AbstractDataSource *currentPrimarySelection = nullptr;
|
||||
bool primarySelectionEnabled = true;
|
||||
|
||||
// Pointer related members
|
||||
struct Pointer
|
||||
|
|
|
@ -320,6 +320,16 @@ void WaylandServer::handleOutputDisabled(Output *output)
|
|||
}
|
||||
}
|
||||
|
||||
void WaylandServer::setEnablePrimarySelection(bool enable)
|
||||
{
|
||||
if (!enable && m_primarySelectionDeviceManager != nullptr) {
|
||||
delete m_primarySelectionDeviceManager;
|
||||
m_primarySelectionDeviceManager = nullptr;
|
||||
} else if (enable && m_primarySelectionDeviceManager == nullptr) {
|
||||
m_primarySelectionDeviceManager = new PrimarySelectionDeviceManagerV1Interface(m_display, m_display);
|
||||
}
|
||||
}
|
||||
|
||||
bool WaylandServer::start()
|
||||
{
|
||||
return m_display->start();
|
||||
|
@ -420,8 +430,7 @@ bool WaylandServer::init(InitializationFlags flags)
|
|||
new DataControlDeviceManagerV1Interface(m_display, m_display);
|
||||
|
||||
const auto kwinConfig = kwinApp()->config();
|
||||
m_seat->setPrimarySelectionEnabled(kwinConfig->group("Wayland").readEntry("EnablePrimarySelection", true));
|
||||
new PrimarySelectionDeviceManagerV1Interface(m_display, m_display);
|
||||
setEnablePrimarySelection(kwinConfig->group("Wayland").readEntry("EnablePrimarySelection", true));
|
||||
|
||||
m_idle = new IdleInterface(m_display, m_display);
|
||||
auto idleInhibition = new IdleInhibition(m_idle);
|
||||
|
|
|
@ -47,6 +47,7 @@ class LinuxDmaBufV1ClientBuffer;
|
|||
class TabletManagerV2Interface;
|
||||
class KeyboardShortcutsInhibitManagerV1Interface;
|
||||
class XdgDecorationManagerV1Interface;
|
||||
class PrimarySelectionDeviceManagerV1Interface;
|
||||
class XWaylandKeyboardGrabManagerV1Interface;
|
||||
class ContentTypeManagerV1Interface;
|
||||
class DrmLeaseManagerV1;
|
||||
|
@ -227,6 +228,7 @@ public:
|
|||
{
|
||||
m_linuxDmabufBuffers.remove(buffer);
|
||||
}
|
||||
void setEnablePrimarySelection(bool enable);
|
||||
|
||||
/**
|
||||
* Returns the first socket name that can be used to connect to this server.
|
||||
|
@ -293,6 +295,7 @@ private:
|
|||
KWaylandServer::ClientConnection *m_screenLockerClientConnection = nullptr;
|
||||
KWaylandServer::XdgForeignV2Interface *m_XdgForeign = nullptr;
|
||||
XdgActivationV1Integration *m_xdgActivationIntegration = nullptr;
|
||||
KWaylandServer::PrimarySelectionDeviceManagerV1Interface *m_primarySelectionDeviceManager = nullptr;
|
||||
KWaylandServer::XWaylandKeyboardGrabManagerV1Interface *m_xWaylandKeyboardGrabManager = nullptr;
|
||||
KWaylandServer::ContentTypeManagerV1Interface *m_contentTypeManager = nullptr;
|
||||
KWaylandServer::TearingControlManagerV1Interface *m_tearingControlInterface = nullptr;
|
||||
|
|
Loading…
Reference in a new issue