x11: Hard-code 0 default screen

The screen number matters only on multi-head setups.
This commit is contained in:
Vlad Zahorodnii 2022-07-20 11:05:00 +03:00
parent 8f2748b1e1
commit c7af7adda6
9 changed files with 15 additions and 71 deletions

View file

@ -129,7 +129,6 @@ void XwaylandServerCrashTest::testCrash()
QCOMPARE(kwinApp()->x11Connection(), nullptr);
QCOMPARE(kwinApp()->x11DefaultScreen(), nullptr);
QCOMPARE(kwinApp()->x11RootWindow(), XCB_WINDOW_NONE);
QCOMPARE(kwinApp()->x11ScreenNumber(), -1);
// Render a frame to ensure that the compositor doesn't crash.
Compositor::self()->scene()->addRepaintFull();

View file

@ -17,8 +17,6 @@
namespace KWin
{
int screen_number = 0;
InputRedirection *InputRedirection::s_self = nullptr;
void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action)
@ -101,7 +99,6 @@ private:
void TestVirtualDesktops::init()
{
VirtualDesktopManager::create();
screen_number = 0;
}
void TestVirtualDesktops::cleanup()

View file

@ -331,9 +331,7 @@ void Compositor::initializeX11()
}
if (!m_selectionOwner) {
char selection_name[100];
sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber());
m_selectionOwner = std::make_unique<CompositorSelectionOwner>(selection_name);
m_selectionOwner = std::make_unique<CompositorSelectionOwner>("_NET_WM_CM_S0");
connect(m_selectionOwner.get(), &CompositorSelectionOwner::lostOwnership, this, &Compositor::stop);
}
if (!m_selectionOwner->owning()) {

View file

@ -60,23 +60,9 @@ namespace KWin
{
Options *options;
Atoms *atoms;
int screen_number = -1;
int Application::crashes = 0;
void Application::setX11ScreenNumber(int screenNumber)
{
screen_number = screenNumber;
}
int Application::x11ScreenNumber()
{
return screen_number;
}
Application::Application(Application::OperationMode mode, int &argc, char **argv)
: QApplication(argc, argv)
, m_eventFilter(new XcbEventFilter())

View file

@ -58,7 +58,6 @@ class KWIN_EXPORT Application : public QApplication
Q_PROPERTY(quint32 x11Time READ x11Time WRITE setX11Time)
Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT)
Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged)
Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT)
Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig)
Q_PROPERTY(KSharedConfigPtr kxkbConfig READ kxkbConfig WRITE setKxkbConfig)
public:
@ -149,15 +148,6 @@ public:
*/
static void createAboutData();
/**
* @returns the X11 Screen number. If not applicable it's set to @c -1.
*/
static int x11ScreenNumber();
/**
* Sets the X11 screen number of this KWin instance to @p screenNumber.
*/
static void setX11ScreenNumber(int screenNumber);
/**
* @returns the X11 root window.
*/

View file

@ -108,8 +108,8 @@ class KWinSelectionOwner : public KSelectionOwner
{
Q_OBJECT
public:
explicit KWinSelectionOwner(int screen)
: KSelectionOwner(make_selection_atom(screen), screen)
explicit KWinSelectionOwner()
: KSelectionOwner(make_selection_atom())
{
}
@ -150,13 +150,9 @@ private:
}
}
xcb_atom_t make_selection_atom(int screen_P)
xcb_atom_t make_selection_atom()
{
if (screen_P < 0) {
screen_P = QX11Info::appScreen();
}
QByteArray screen(QByteArrayLiteral("WM_S"));
screen.append(QByteArray::number(screen_P));
QByteArray screen(QByteArrayLiteral("WM_S0"));
ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply(
kwinApp()->x11Connection(),
xcb_intern_atom_unchecked(kwinApp()->x11Connection(), false, screen.length(), screen.constData()),
@ -209,28 +205,15 @@ void ApplicationX11::lostSelection()
quit();
}
static xcb_screen_t *findXcbScreen(xcb_connection_t *connection, int screen)
{
for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(connection));
it.rem;
--screen, xcb_screen_next(&it)) {
if (screen == 0) {
return it.data;
}
}
return nullptr;
}
void ApplicationX11::performStartup()
{
crashChecking();
if (Application::x11ScreenNumber() == -1) {
Application::setX11ScreenNumber(QX11Info::appScreen());
}
setX11DefaultScreen(findXcbScreen(x11Connection(), x11ScreenNumber()));
xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(x11Connection())).data;
Q_ASSERT(screen);
setX11DefaultScreen(screen);
owner.reset(new KWinSelectionOwner(Application::x11ScreenNumber()));
owner.reset(new KWinSelectionOwner());
connect(owner.data(), &KSelectionOwner::failedToClaimOwnership, [] {
fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").toLocal8Bit().constData(), stderr);
::exit(1);

View file

@ -20,7 +20,6 @@
namespace KWin
{
extern int screen_number;
std::unique_ptr<RootInfo> RootInfo::s_self;
@ -116,7 +115,7 @@ RootInfo *RootInfo::create()
| NET::ActionChangeDesktop
| NET::ActionClose;
s_self.reset(new RootInfo(supportWindow, "KWin", properties, types, states, properties2, actions, screen_number));
s_self.reset(new RootInfo(supportWindow, "KWin", properties, types, states, properties2, actions));
return s_self.get();
}

View file

@ -1976,15 +1976,9 @@ static inline int defaultDepth()
if (depth != 0) {
return depth;
}
int screen = Application::x11ScreenNumber();
for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(connection()));
it.rem;
--screen, xcb_screen_next(&it)) {
if (screen == 0) {
depth = it.data->root_depth;
break;
}
}
xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(connection())).data;
Q_ASSERT(screen);
depth = screen->root_depth;
return depth;
}

View file

@ -261,7 +261,6 @@ bool Xwayland::createX11Connection()
m_app->setX11Connection(connection);
m_app->setX11DefaultScreen(screen);
m_app->setX11ScreenNumber(0);
m_app->setX11RootWindow(screen->root);
m_app->createAtoms();
@ -269,8 +268,8 @@ bool Xwayland::createX11Connection()
installSocketNotifier();
// Note that it's very important to have valid x11RootWindow(), x11ScreenNumber(), and
// atoms when the rest of kwin is notified about the new X11 connection.
// Note that it's very important to have valid x11RootWindow(), and atoms when the
// rest of kwin is notified about the new X11 connection.
Q_EMIT m_app->x11ConnectionChanged();
return true;
@ -292,7 +291,6 @@ void Xwayland::destroyX11Connection()
m_app->setX11Connection(nullptr);
m_app->setX11DefaultScreen(nullptr);
m_app->setX11ScreenNumber(-1);
m_app->setX11RootWindow(XCB_WINDOW_NONE);
Q_EMIT m_app->x11ConnectionChanged();