diff --git a/debian/changelog b/debian/changelog index 7f8e0ab..f1756f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ pcmanfm-qt (1.2.0-0ubuntu1) UNRELEASED; urgency=medium * Lubuntuify the package slightly, to make debhelper happy. * Bump Standards-version to 4.6.1, no changes needed. * Bump build dependencies in debian/control. + * Remove reverse-applicable upstream patches. -- Simon Quigley Fri, 18 Nov 2022 18:44:59 -0600 diff --git a/debian/patches/scaling-pr-1596.patch b/debian/patches/scaling-pr-1596.patch deleted file mode 100644 index 5051c97..0000000 --- a/debian/patches/scaling-pr-1596.patch +++ /dev/null @@ -1,215 +0,0 @@ -From c84434e576ec37208237f143ad5ef8f37ce25a24 Mon Sep 17 00:00:00 2001 -From: tsujan -Date: Fri, 3 Jun 2022 05:16:58 +0430 -Subject: [PATCH] Consider device pixel ratio when drawing wallpaper (#1596) - -Previously, wallpapers weren't sharp with scale factors > 1. - -Also, an old problem is fixed in centering per-screen wallpapers with multi-screen setups. Previously, if the centered wallpaper was smaller than the screen size, the dektop background color would be removed from the screen part to its right and bottom. - -Fixes https://github.com/lxqt/pcmanfm-qt/issues/1595 ---- - pcmanfm/desktopwindow.cpp | 93 ++++++++++++++++++++++++--------------- - 1 file changed, 58 insertions(+), 35 deletions(-) - -diff --git a/pcmanfm/desktopwindow.cpp b/pcmanfm/desktopwindow.cpp -index b0734582..d69b660e 100644 ---- a/pcmanfm/desktopwindow.cpp -+++ b/pcmanfm/desktopwindow.cpp -@@ -644,88 +644,107 @@ QImage DesktopWindow::loadWallpaperFile(QSize requiredSize) { - // really generate the background pixmap according to current settings and apply it. - void DesktopWindow::updateWallpaper() { - if(wallpaperMode_ != WallpaperNone) { // use wallpaper -+ auto screen = getDesktopScreen(); -+ if(screen == nullptr) { -+ return; -+ } - QPixmap pixmap; - QImage image; - Settings& settings = static_cast(qApp)->settings(); -- auto screen = getDesktopScreen(); -- bool perScreenWallpaper(screen != nullptr && screen->virtualSiblings().size() > 1 && settings.perScreenWallpaper()); -+ const auto screens = screen->virtualSiblings(); -+ bool perScreenWallpaper(screens.size() > 1 && settings.perScreenWallpaper()); -+ -+ // the pixmap's size should be calculated by considering -+ // the positions and device pixel ratios of all screens -+ QRect pixmapRect; -+ for(const auto& scr : screens) { -+ pixmapRect |= QRect(scr->geometry().topLeft(), scr->size() * scr->devicePixelRatio()); -+ } -+ const QSize pixmapSize = pixmapRect.size(); -+ -+ // the pixmap's device pixel ratio -+ qreal DPRatio = windowHandle() ? windowHandle()->devicePixelRatio() : qApp->devicePixelRatio(); -+ - if(wallpaperMode_ == WallpaperTile) { // use the original size - image = getWallpaperImage(); - if(!image.isNull()) { - // Note: We can't use the QPainter::drawTiledPixmap(), because it doesn't tile - // correctly for background pixmaps bigger than the current screen size. -- const QSize s = size(); -- pixmap = QPixmap{s}; -+ pixmap = QPixmap{pixmapSize}; - QPainter painter{&pixmap}; -- for (int x = 0; x < s.width(); x += image.width()) { -- for (int y = 0; y < s.height(); y += image.height()) { -+ for (int x = 0; x < pixmapSize.width(); x += image.width()) { -+ for (int y = 0; y < pixmapSize.height(); y += image.height()) { - painter.drawImage(x, y, image); - } - } -+ pixmap.setDevicePixelRatio(DPRatio); - } - } - else if(wallpaperMode_ == WallpaperStretch) { - if(perScreenWallpaper) { -- const QSize s = size(); -- pixmap = QPixmap{s}; -+ pixmap = QPixmap{pixmapSize}; - QPainter painter{&pixmap}; - pixmap.fill(bgColor_); - image = getWallpaperImage(); - if(!image.isNull()) { - QImage scaled; -- const auto screens = screen->virtualSiblings(); - for(const auto& scr : screens) { -- scaled = image.scaled(scr->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -+ scaled = image.scaled(scr->size() * scr->devicePixelRatio(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - painter.drawImage(scr->geometry().x(), scr->geometry().y(), scaled); - } - } -+ pixmap.setDevicePixelRatio(DPRatio); - } - else { -- image = loadWallpaperFile(size()); -+ image = loadWallpaperFile(pixmapSize); - pixmap = QPixmap::fromImage(image); -+ pixmap.setDevicePixelRatio(DPRatio); - } - } - else { // WallpaperCenter || WallpaperFit - if(perScreenWallpaper) { -- const QSize s = size(); -- pixmap = QPixmap{s}; -+ pixmap = QPixmap{pixmapSize}; - QPainter painter{&pixmap}; - pixmap.fill(bgColor_); - image = getWallpaperImage(); - if(!image.isNull()) { - QImage scaled; - int x, y; -- const auto screens = screen->virtualSiblings(); - if(wallpaperMode_ == WallpaperCenter) { - for(const auto& scr : screens) { -+ const auto scrSize = scr->size() * scr->devicePixelRatio(); - // get the gap between image and screen to avoid overlapping and displacement -- int x_gap = (image.width() - scr->geometry().width()) / 2; -- int y_gap = (image.height() - scr->geometry().height()) / 2; -- scaled = image.copy(qMax(x_gap, 0), qMax(y_gap, 0), scr->geometry().width(), scr->geometry().height()); -+ int x_gap = (image.width() - scrSize.width()) / 2; -+ int y_gap = (image.height() - scrSize.height()) / 2; -+ scaled = image.copy(qMax(x_gap, 0), qMax(y_gap, 0), scrSize.width(), scrSize.height()); - x = scr->geometry().x() + qMax(0, -x_gap); -- y = scr->geometry().y() + qMax(0, - y_gap); -+ y = scr->geometry().y() + qMax(0, -y_gap); -+ painter.save(); -+ painter.setClipRect(QRect(x, y, image.width(), image.height())); - painter.drawImage(x, y, scaled); -+ painter.restore(); - } - } - else if((wallpaperMode_ == WallpaperFit || wallpaperMode_ == WallpaperZoom) - && image.width() > 0 && image.height() > 0) { - for(const auto& scr : screens) { -+ const auto scrSize = scr->size() * scr->devicePixelRatio(); - // get the screen-to-image ratio to calculate the scale factors -- const qreal w_ratio = static_cast(scr->geometry().width()) / image.width(); -- const qreal h_ratio = static_cast(scr->geometry().height()) / image.height(); -+ const qreal w_ratio = static_cast(scrSize.width()) / image.width(); -+ const qreal h_ratio = static_cast(scrSize.height()) / image.height(); - if(w_ratio <= h_ratio) { - if(wallpaperMode_ == WallpaperFit) { - // fit horizontally -- scaled = image.scaledToWidth(scr->geometry().width(), Qt::SmoothTransformation); -+ scaled = image.scaledToWidth(scrSize.width(), Qt::SmoothTransformation); - x = scr->geometry().x(); -- y = scr->geometry().y() + (scr->geometry().height() - scaled.height()) / 2; -+ y = scr->geometry().y() + (scrSize.height() - scaled.height()) / 2; - } - else { // zoom - // fit vertically -- scaled = image.scaledToHeight(scr->geometry().height(), Qt::SmoothTransformation); -+ scaled = image.scaledToHeight(scrSize.height(), Qt::SmoothTransformation); - // crop to avoid overlapping -- int x_gap = (scaled.width() - scr->geometry().width()) / 2; -- scaled = scaled.copy(x_gap, 0, scr->geometry().width(), scaled.height()); -+ int x_gap = (scaled.width() - scrSize.width()) / 2; -+ scaled = scaled.copy(x_gap, 0, scrSize.width(), scaled.height()); - x = scr->geometry().x(); - y = scr->geometry().y(); - } -@@ -733,16 +752,16 @@ void DesktopWindow::updateWallpaper() { - else { // w_ratio > h_ratio - if(wallpaperMode_ == WallpaperFit) { - // fit vertically -- scaled = image.scaledToHeight(scr->geometry().height(), Qt::SmoothTransformation); -- x = scr->geometry().x() + (scr->geometry().width() - scaled.width()) / 2; -+ scaled = image.scaledToHeight(scrSize.height(), Qt::SmoothTransformation); -+ x = scr->geometry().x() + (scrSize.width() - scaled.width()) / 2; - y = scr->geometry().y(); - } - else { // zoom - // fit horizonatally -- scaled = image.scaledToWidth(scr->geometry().width(), Qt::SmoothTransformation); -+ scaled = image.scaledToWidth(scrSize.width(), Qt::SmoothTransformation); - // crop to avoid overlapping -- int y_gap = (scaled.height() - scr->geometry().height()) / 2; -- scaled = scaled.copy(0, y_gap, scaled.width(), scr->geometry().height()); -+ int y_gap = (scaled.height() - scrSize.height()) / 2; -+ scaled = scaled.copy(0, y_gap, scaled.width(), scrSize.height()); - x = scr->geometry().x(); - y = scr->geometry().y(); - } -@@ -751,6 +770,7 @@ void DesktopWindow::updateWallpaper() { - } - } - } -+ pixmap.setDevicePixelRatio(DPRatio); - } - else { - if(wallpaperMode_ == WallpaperCenter) { -@@ -770,17 +790,18 @@ void DesktopWindow::updateWallpaper() { - if(origSize.isValid()) { - QSize desiredSize = origSize; - Qt::AspectRatioMode mode = (wallpaperMode_ == WallpaperFit ? Qt::KeepAspectRatio : Qt::KeepAspectRatioByExpanding); -- desiredSize.scale(width(), height(), mode); -+ desiredSize.scale(pixmapSize, mode); - image = loadWallpaperFile(desiredSize); // load the scaled image - } - } - if(!image.isNull()) { -- pixmap = QPixmap(size()); -+ pixmap = QPixmap{pixmapSize}; - QPainter painter(&pixmap); - pixmap.fill(bgColor_); -- int x = (width() - image.width()) / 2; -- int y = (height() - image.height()) / 2; -+ int x = (pixmapSize.width() - image.width()) / 2; -+ int y = (pixmapSize.height() - image.height()) / 2; - painter.drawImage(x, y, image); -+ pixmap.setDevicePixelRatio(DPRatio); - } - } - } -@@ -1239,7 +1260,9 @@ void DesktopWindow::paintBackground(QPaintEvent* event) { - painter.fillRect(event->rect(), QBrush(bgColor_)); - } - else { -- painter.drawPixmap(event->rect(), wallpaperPixmap_, event->rect()); -+ QRectF r(QPointF(event->rect().topLeft()) * wallpaperPixmap_.devicePixelRatio(), -+ QSizeF(event->rect().size()) * wallpaperPixmap_.devicePixelRatio()); -+ painter.drawPixmap(event->rect(), wallpaperPixmap_, r.toRect()); - } - } - diff --git a/debian/patches/series b/debian/patches/series index 0924de6..807f74a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,4 +1 @@ -scaling-pr-1596.patch add-manual.patch -upstream-pr-1601.patch -upstream-pr-1606.patch diff --git a/debian/patches/upstream-pr-1601.patch b/debian/patches/upstream-pr-1601.patch deleted file mode 100644 index 5e03be0..0000000 --- a/debian/patches/upstream-pr-1601.patch +++ /dev/null @@ -1,91 +0,0 @@ -From f1438b2b3eec8a1c60532ae5d9fcd654138dc5e4 Mon Sep 17 00:00:00 2001 -From: tsujan -Date: Tue, 21 Jun 2022 11:14:03 +0430 -Subject: [PATCH] Prevent an empty desktop path (#1601) - -Fall back to `$HOME/Desktop` if `~/.config/user-dirs.dirs` doesn't exist or doesn't contain a desktop path. But if `~/.config/user-dirs.dirs` contains an empty desktop path, accept it. - -See https://github.com/lxqt/lxqt-session/issues/439 for the story. ---- - pcmanfm/desktoppreferencesdialog.cpp | 1 - - pcmanfm/xdgdir.cpp | 34 ++++++++++++++++------------ - 2 files changed, 20 insertions(+), 15 deletions(-) - -diff --git a/pcmanfm/desktoppreferencesdialog.cpp b/pcmanfm/desktoppreferencesdialog.cpp -index b25f6435..465095c6 100644 ---- a/pcmanfm/desktoppreferencesdialog.cpp -+++ b/pcmanfm/desktoppreferencesdialog.cpp -@@ -27,7 +27,6 @@ - #include - #include - #include --#include - #include - #include - #include -diff --git a/pcmanfm/xdgdir.cpp b/pcmanfm/xdgdir.cpp -index 9fd9a7b0..edc5a848 100644 ---- a/pcmanfm/xdgdir.cpp -+++ b/pcmanfm/xdgdir.cpp -@@ -18,10 +18,13 @@ - - #include "xdgdir.h" - #include -+#include - #include - #include - #include - -+static const QRegularExpression desktopRegex(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\"")); -+ - QString XdgDir::readUserDirsFile() { - QFile file(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QStringLiteral("/user-dirs.dirs")); - if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { -@@ -34,30 +37,33 @@ QString XdgDir::readUserDirsFile() { - - QString XdgDir::readDesktopDir() { - QString str = readUserDirsFile(); -- if(str.isEmpty()) -- return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/Desktop"); -- QRegExp reg(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\"")); -- if(reg.lastIndexIn(str) != -1) { -- str = reg.cap(1); -- if(str.startsWith(QStringLiteral("$HOME"))) -- str = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + str.mid(5); -- return str; -+ if(!str.isEmpty()) { -+ QRegularExpressionMatch match; -+ if(str.lastIndexOf(desktopRegex, -1, &match) != -1) { -+ str = match.captured(1); -+ if(str.startsWith(QStringLiteral("$HOME"))) { -+ str = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + str.mid(5); -+ } -+ return str; -+ } - } -- return QString(); -+ return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/Desktop"); - } - - void XdgDir::setDesktopDir(QString path) { - QString home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); -- if(path.startsWith(home)) -+ if(path.startsWith(home)) { - path = QStringLiteral("$HOME") + path.mid(home.length()); -+ } - QString str = readUserDirsFile(); -- QRegExp reg(QStringLiteral("XDG_DESKTOP_DIR=\"([^\n]*)\"")); - QString line = QStringLiteral("XDG_DESKTOP_DIR=\"") + path + QLatin1Char('\"'); -- if(reg.indexIn(str) != -1) -- str.replace(reg, line); -+ if(str.contains(desktopRegex)) { -+ str.replace(desktopRegex, line); -+ } - else { -- if(!str.endsWith(QLatin1Char('\n'))) -+ if(!str.endsWith(QLatin1Char('\n'))) { - str += QLatin1Char('\n'); -+ } - str += line + QLatin1Char('\n'); - } - QString dir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); diff --git a/debian/patches/upstream-pr-1606.patch b/debian/patches/upstream-pr-1606.patch deleted file mode 100644 index 12393a4..0000000 --- a/debian/patches/upstream-pr-1606.patch +++ /dev/null @@ -1,411 +0,0 @@ -From 1151f49984ebc102c5238a9ba1d2b1a6769a1457 Mon Sep 17 00:00:00 2001 -From: tsujan -Date: Tue, 21 Jun 2022 13:27:25 +0430 -Subject: [PATCH] Allow customizing workspace margins on desktop (#1606) - -It's especially useful with panels/docks that don't reserve space but auto-hide on overlapping windows. ---- - pcmanfm/desktop-preferences.ui | 153 +++++++++++++++++++++------ - pcmanfm/desktoppreferencesdialog.cpp | 10 ++ - pcmanfm/desktopwindow.cpp | 34 ++++-- - pcmanfm/settings.cpp | 14 +++ - pcmanfm/settings.h | 9 ++ - 5 files changed, 183 insertions(+), 37 deletions(-) - -diff --git a/pcmanfm/desktop-preferences.ui b/pcmanfm/desktop-preferences.ui -index d73e7312..c23f7bdb 100644 ---- a/pcmanfm/desktop-preferences.ui -+++ b/pcmanfm/desktop-preferences.ui -@@ -136,6 +136,16 @@ - Spacing - - -+ -+ 10 -+ -+ -+ -+ -+ Lock -+ -+ -+ - - - -@@ -143,10 +153,24 @@ - - - -- -- -+ -+ -+ -+ Qt::Horizontal -+ -+ -+ -+ 20 -+ 5 -+ -+ -+ -+ -+ -+ - -- 3 px by default. -+ 1 px by default. -+A space is also reserved for 3 lines of text. - - - px -@@ -155,22 +179,14 @@ - 48 - - -- 3 -- -- -- -- -- -- -- x -+ 1 - - - -- -- -+ -+ - -- 1 px by default. --A space is also reserved for 3 lines of text. -+ 3 px by default. - - - px -@@ -179,29 +195,104 @@ A space is also reserved for 3 lines of text. - 48 - - -- 1 -+ 3 - - - -- -- -+ -+ - -- Lock -+ x - - - -- -- -- -- Qt::Horizontal -- -- -- -- 20 -- 5 -- -- -- -+ -+ -+ -+ -+ 10 -+ -+ -+ 5 -+ -+ -+ 5 -+ -+ -+ 5 -+ -+ -+ 5 -+ -+ -+ -+ -+ Margins of work area: -+ -+ -+ -+ -+ -+ -+ px -+ -+ -+ 200 -+ -+ -+ -+ -+ -+ -+ -+ -+ px -+ -+ -+ 200 -+ -+ -+ -+ -+ -+ -+ Qt::Horizontal -+ -+ -+ QSizePolicy::MinimumExpanding -+ -+ -+ -+ 20 -+ 5 -+ -+ -+ -+ -+ -+ -+ -+ px -+ -+ -+ 200 -+ -+ -+ -+ -+ -+ -+ -+ -+ px -+ -+ -+ 200 -+ -+ -+ -+ -+ - - - -diff --git a/pcmanfm/desktoppreferencesdialog.cpp b/pcmanfm/desktoppreferencesdialog.cpp -index 465095c6..04ac8bb8 100644 ---- a/pcmanfm/desktoppreferencesdialog.cpp -+++ b/pcmanfm/desktoppreferencesdialog.cpp -@@ -128,6 +128,11 @@ DesktopPreferencesDialog::DesktopPreferencesDialog(QWidget* parent, Qt::WindowFl - ui.vMargin->setValue(settings.desktopCellMargins().height()); - connect(ui.lockMargins, &QAbstractButton::clicked, this, &DesktopPreferencesDialog::lockMargins); - -+ ui.leftMargin->setValue(settings.workAreaMargins().left()); -+ ui.topMargin->setValue(settings.workAreaMargins().top()); -+ ui.rightMargin->setValue(settings.workAreaMargins().right()); -+ ui.bottomMargin->setValue(settings.workAreaMargins().bottom()); -+ - ui.defaultFileManager->setChecked(settings.openWithDefaultFileManager()); - - ui.allSticky->setChecked(settings.allSticky()); -@@ -207,6 +212,11 @@ void DesktopPreferencesDialog::applySettings() - - settings.setDesktopCellMargins(QSize(ui.hMargin->value(), ui.vMargin->value())); - -+ settings.setWorkAreaMargins(QMargins(ui.leftMargin->value(), -+ ui.topMargin->value(), -+ ui.rightMargin->value(), -+ ui.bottomMargin->value())); -+ - settings.setOpenWithDefaultFileManager(ui.defaultFileManager->isChecked()); - - settings.setAllSticky(ui.allSticky->isChecked()); -diff --git a/pcmanfm/desktopwindow.cpp b/pcmanfm/desktopwindow.cpp -index d69b660e..b2870774 100644 ---- a/pcmanfm/desktopwindow.cpp -+++ b/pcmanfm/desktopwindow.cpp -@@ -63,7 +63,6 @@ - #include - #include - --#define WORK_AREA_MARGIN 12 // margin of the work area - #define MIN_SLIDE_INTERVAL 5*60000 // 5 min - #define MAX_SLIDE_INTERVAL (24*60+55)*60000 // 24 h and 55 min - -@@ -1203,8 +1202,13 @@ void DesktopWindow::removeBottomGap() { - auto itemSize = delegate->itemSize(); - //qDebug() << "delegate:" << delegate->itemSize(); - QSize cellMargins = getMargins(); -+ Settings& settings = static_cast(qApp)->settings(); - int workAreaHeight = screen->availableVirtualGeometry().height() -- - 2 * WORK_AREA_MARGIN; -+ - settings.workAreaMargins().top() -+ - settings.workAreaMargins().bottom(); -+ if(workAreaHeight <= 0) { -+ return; -+ } - int cellHeight = itemSize.height() + listView_->spacing(); - int iconNumber = workAreaHeight / cellHeight; - int bottomGap = workAreaHeight % cellHeight; -@@ -1219,7 +1223,6 @@ void DesktopWindow::removeBottomGap() { - qreal exactNumber = (static_cast(cellHeight) - static_cast(bottomGap)) - / (2 * static_cast(iconNumber) + static_cast(2)); - int subtrahend = (int)exactNumber + ((int)exactNumber == exactNumber ? 0 : 1); -- Settings& settings = static_cast(qApp)->settings(); - int minCellHeight = settings.desktopCellMargins().height(); - if(subtrahend > 0 - && cellMargins.height() - subtrahend >= minCellHeight) { -@@ -1301,11 +1304,18 @@ void DesktopWindow::trustOurDesktopShortcut(std::shared_ptr - - QRect DesktopWindow::getWorkArea(QScreen* screen) const { - QRect workArea = screen->availableVirtualGeometry(); -- workArea.adjust(WORK_AREA_MARGIN, WORK_AREA_MARGIN, -WORK_AREA_MARGIN, -WORK_AREA_MARGIN); -+ QMargins margins = static_cast(qApp)->settings().workAreaMargins(); - // switch between right and left with RTL to use the usual (LTR) calculations later - if(layoutDirection() == Qt::RightToLeft) { -+ int right = margins.right(); -+ margins.setRight(margins.left()); -+ margins.setLeft(right); -+ workArea = workArea.marginsRemoved(margins); - workArea.moveLeft(rect().right() - workArea.right()); - } -+ else { -+ workArea = workArea.marginsRemoved(margins); -+ } - return workArea; - } - -@@ -1709,6 +1719,9 @@ QModelIndex DesktopWindow::navigateWithKey(int key, Qt::KeyboardModifiers modifi - QRect workArea = getWorkArea(screen); - int columns = workArea.width() / (itemSize.width() + listView_->spacing()); - int rows = workArea.height() / (itemSize.height() + listView_->spacing()); -+ if(columns <= 0 || rows <= 0) { -+ break; -+ } - bool rtl(layoutDirection() == Qt::RightToLeft); - while(!index.isValid() && workArea.contains(pos)) { - switch(key) { -@@ -1971,7 +1984,7 @@ void DesktopWindow::childDropEvent(QDropEvent* e) { - // move selected items to the drop position, preserving their relative positions - QPoint dropPos = e->pos(); - -- if(curIndx.isValid()) { -+ if(curIndx.isValid() && !workArea.isEmpty()) { - QPoint curPoint = listView_->visualRect(curIndx).topLeft(); - - // first move the current item to the drop position -@@ -2050,7 +2063,8 @@ void DesktopWindow::childDropEvent(QDropEvent* e) { - } - - // position dropped items successively, starting with the drop rectangle -- if(mimeData->hasUrls() -+ if(!workArea.isEmpty() -+ && mimeData->hasUrls() - && (e->dropAction() == Qt::CopyAction - || e->dropAction() == Qt::MoveAction - || e->dropAction() == Qt::LinkAction)) { -@@ -2079,6 +2093,10 @@ void DesktopWindow::childDropEvent(QDropEvent* e) { - // until it reaches the last cell and then puts the remaining items in the opposite - // direction. In this way, it creates a natural DND, especially with multiple files. - bool DesktopWindow::stickToPosition(const std::string& file, QPoint& pos, const QRect& workArea, const QSize& grid, bool reachedLastCell) { -+ if(workArea.isEmpty()) { -+ return reachedLastCell; -+ } -+ - // normalize the position, depending on the positioning direction - if(!reachedLastCell) { // default direction: top -> bottom, left -> right - -@@ -2178,6 +2196,10 @@ void DesktopWindow::alignToGrid(QPoint& pos, const QPoint& topLeft, const QSize& - // the text or icon rectangle but we make an exception for Trash because we want - // to trash dropped items once the drop point is inside the Trash cell. - QModelIndex DesktopWindow::indexForPos(bool* isTrash, const QPoint& pos, const QRect& workArea, const QSize& grid) const { -+ if(workArea.isEmpty()) { -+ return QModelIndex(); -+ } -+ - // first normalize the position - QPoint p(pos); - -diff --git a/pcmanfm/settings.cpp b/pcmanfm/settings.cpp -index c5ccc00f..b1397cab 100644 ---- a/pcmanfm/settings.cpp -+++ b/pcmanfm/settings.cpp -@@ -134,6 +134,7 @@ Settings::Settings(): - templateRunApp_(false), - folderViewCellMargins_(QSize(3, 3)), - desktopCellMargins_(QSize(3, 1)), -+ workAreaMargins_(QMargins(12, 12, 12, 12)), - openWithDefaultFileManager_(false), - allSticky_(false), - searchNameCaseInsensitive_(false), -@@ -269,6 +270,14 @@ bool Settings::loadFile(QString filePath) { - - desktopCellMargins_ = (settings.value(QStringLiteral("DesktopCellMargins"), QSize(3, 1)).toSize() - .expandedTo(QSize(0, 0))).boundedTo(QSize(48, 48)); -+ auto l = settings.value(QStringLiteral("WorkAreaMargins")).toList(); -+ if(l.size() >= 4) { -+ workAreaMargins_.setLeft(qBound(0, l.at(0).toInt(), 200)); -+ workAreaMargins_.setTop(qBound(0, l.at(1).toInt(), 200)); -+ workAreaMargins_.setRight(qBound(0, l.at(2).toInt(), 200)); -+ workAreaMargins_.setBottom(qBound(0, l.at(3).toInt(), 200)); -+ } -+ - openWithDefaultFileManager_ = settings.value(QStringLiteral("OpenWithDefaultFileManager"), false).toBool(); - allSticky_ = settings.value(QStringLiteral("AllSticky"), false).toBool(); - settings.endGroup(); -@@ -416,6 +425,11 @@ bool Settings::saveFile(QString filePath) { - settings.setValue(QStringLiteral("SortFolderFirst"), desktopSortFolderFirst_); - settings.setValue(QStringLiteral("SortHiddenLast"), desktopSortHiddenLast_); - settings.setValue(QStringLiteral("DesktopCellMargins"), desktopCellMargins_); -+ QList l{workAreaMargins_.left(), -+ workAreaMargins_.top(), -+ workAreaMargins_.right(), -+ workAreaMargins_.bottom()}; -+ settings.setValue(QStringLiteral("WorkAreaMargins"), l); - settings.setValue(QStringLiteral("OpenWithDefaultFileManager"), openWithDefaultFileManager_); - settings.setValue(QStringLiteral("AllSticky"), allSticky_); - settings.endGroup(); -diff --git a/pcmanfm/settings.h b/pcmanfm/settings.h -index 63c92b71..e9641b18 100644 ---- a/pcmanfm/settings.h -+++ b/pcmanfm/settings.h -@@ -788,6 +788,14 @@ class Settings : public QObject { - desktopCellMargins_ = size; - } - -+ QMargins workAreaMargins() const { -+ return workAreaMargins_; -+ } -+ -+ void setWorkAreaMargins(QMargins margins) { -+ workAreaMargins_ = margins; -+ } -+ - bool openWithDefaultFileManager() const { - return openWithDefaultFileManager_; - } -@@ -1145,6 +1153,7 @@ class Settings : public QObject { - - QSize folderViewCellMargins_; - QSize desktopCellMargins_; -+ QMargins workAreaMargins_; - - bool openWithDefaultFileManager_; -