fix: Only enable the screen after connecting to the client

To be able to react to rules in screen->activate() that are enabled in setPrimaryClient, we have to reverse the order of the two calls. The same goes for screen->deactivate()
This commit is contained in:
KoljaFrahm 2026-09-10 22:22:22 +02:00 committed by Nick Bolton
parent adb4f89453
commit d6874dfe27

View file

@ -126,10 +126,19 @@ Server::Server(ServerConfig &config, PrimaryClient *primaryClient, deskflow::Scr
// set initial configuration
setConfig(config);
// If we are using libportal, we need to set the primary client first.
// This enables the rules of the primary client. The hotkeys are then enabled in EiScreen.cpp after the rules
// registered them.
#if WINAPI_LIBPORTAL
// enable primary client
m_inputFilter->setPrimaryClient(m_primaryClient);
m_primaryClient->enable();
// If we are on Mac, X11 or Windows, we need a key map, which is created in screen->enable().
// So we need to enable the screen first, then enable the primary client.
#else
m_primaryClient->enable();
m_inputFilter->setPrimaryClient(m_primaryClient);
#endif
// Determine if scroll lock is already set. If so, lock the cursor to the
// primary screen (unless the user has disabled lock to screen in config)
if (!m_disableLockToScreen && (m_primaryClient->getToggleMask() & KeyModifierScrollLock)) {
@ -175,11 +184,16 @@ Server::~Server()
delete client;
}
// remove input filter
m_inputFilter->setPrimaryClient(nullptr);
// See at Server::Server for why we do this in this order.
#if WINAPI_LIBPORTAL
// disable and disconnect primary client
m_primaryClient->disable();
// remove input filter
m_inputFilter->setPrimaryClient(nullptr);
#else
m_inputFilter->setPrimaryClient(nullptr);
m_primaryClient->disable();
#endif
removeClient(m_primaryClient);
}