Skip to content

Commit

Permalink
Do not use "primary screen" on Wayland (#2007)
Browse files Browse the repository at this point in the history
… because Wayland doesn't have the concept of primary screen. Fortunately, `qApp->primaryScreen()` was never called in practice under Wayland.

Also, the code is simplified a little because `DesktopWindow::screenName` isn't needed anymore.
  • Loading branch information
tsujan authored Jan 24, 2025
1 parent 93a53dc commit bdd1f16
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 16 deletions.
5 changes: 1 addition & 4 deletions pcmanfm/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,11 @@ void Application::onScreenRemoved(QScreen* oldScreen) {
if(desktopWindows_.isEmpty()) {
return;
}
if(desktopWindows_.size() == 1) { // a single desktop is changed
if(!underWayland_ && desktopWindows_.size() == 1) { // a single desktop is changed
if(primaryScreen() != nullptr) {
desktopWindows_.at(0)->setGeometry(primaryScreen()->virtualGeometry());
if(primaryScreen()->virtualSiblings().size() == 1) {
desktopWindows_.at(0)->setScreenNum(0); // there is no virtual desktop anymore
if(underWayland_) {
desktopWindows_.at(0)->setScreenName(primaryScreen()->name());
}
}
}
else if (screens().isEmpty()) { // for the sake of certainty
Expand Down
11 changes: 0 additions & 11 deletions pcmanfm/desktopwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,17 +2450,6 @@ void DesktopWindow::setScreenNum(int num) {
}
}

// Only on Wayland.
void DesktopWindow::setScreenName(const QString& name) {
if(screenName_ != name) {
screenName_ = name;
if(static_cast<Application*>(qApp)->underWayland()) {
loadItemPositions();
queueRelayout();
}
}
}

QScreen* DesktopWindow::getDesktopScreen() const {
QScreen* desktopScreen = nullptr;
if(static_cast<Application*>(qApp)->underWayland()) {
Expand Down
1 change: 0 additions & 1 deletion pcmanfm/desktopwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class DesktopWindow : public View {
QString screenName() const {
return screenName_;
}
void setScreenName(const QString& name);

QScreen* getDesktopScreen() const;

Expand Down

0 comments on commit bdd1f16

Please sign in to comment.