You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pcmanfm-qt-packaging/debian/patches/polish-dnd-2.patch

90 lines
4.6 KiB

Description: Always drop into the cell behind cursor
Drop desktop items into the cell behind the cursor, regardless of the cursor
position inside the cell.
.
Previously, if the cursor was in the right half of the cell, the item would
be dropped into the next cell on the right, and a similar thing happened with
the right bottom half.
Author: Tsu Jan <tsujan2000@gmail.com>
Origin: upstream
Bug: https://github.com/lxqt/pcmanfm-qt/issues/728
Applied-Upstream: commit:a7898c9
Last-Update: 2018-07-14
--- a/pcmanfm/desktopwindow.cpp
+++ b/pcmanfm/desktopwindow.cpp
@@ -59,6 +59,7 @@
#include <xcb/xcb.h>
#include <X11/Xlib.h>
+#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
@@ -751,7 +752,7 @@ void DesktopWindow::removeBottomGap() {
//qDebug() << "delegate:" << delegate->itemSize();
QSize cellMargins = getMargins();
int workAreaHeight = qApp->desktop()->availableGeometry(screenNum_).height()
- - 24; // a 12-pix margin will be considered everywhere
+ - 2 * WORK_AREA_MARGIN;
int cellHeight = itemSize.height() + listView_->spacing();
int iconNumber = workAreaHeight / cellHeight;
int bottomGap = workAreaHeight % cellHeight;
@@ -827,7 +828,7 @@ void DesktopWindow::relayoutItems() {
screen = screenNum_;
}
QRect workArea = desktop->availableGeometry(screen);
- workArea.adjust(12, 12, -12, -12); // add a 12 pixel margin to the work area
+ workArea.adjust(WORK_AREA_MARGIN, WORK_AREA_MARGIN, -WORK_AREA_MARGIN, -WORK_AREA_MARGIN);
// qDebug() << "workArea" << screen << workArea;
// FIXME: we use an internal class declared in a private header here, which is pretty bad.
QPoint pos = workArea.topLeft();
@@ -902,7 +903,7 @@ void DesktopWindow::loadItemPositions()
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
auto grid = delegate->itemSize();
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
- workArea.adjust(12, 12, -12, -12);
+ workArea.adjust(WORK_AREA_MARGIN, WORK_AREA_MARGIN, -WORK_AREA_MARGIN, -WORK_AREA_MARGIN);
QString desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
desktopDir += '/';
std::vector<QPoint> usedPos;
@@ -1281,8 +1282,8 @@ void DesktopWindow::childDropEvent(QDrop
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
auto grid = delegate->itemSize();
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
- workArea.adjust(12, 12, -12, -12);
- QPoint pos = mapFromGlobal(e->pos());
+ workArea.adjust(WORK_AREA_MARGIN, WORK_AREA_MARGIN, -WORK_AREA_MARGIN, -WORK_AREA_MARGIN);
+ QPoint pos = e->pos();
const QModelIndexList indexes = selectedIndexes();
for(const QModelIndex& indx : indexes) {
if(auto file = proxyModel_->fileInfoFromIndex(indx)) {
@@ -1305,9 +1306,9 @@ void DesktopWindow::childDropEvent(QDrop
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
auto grid = delegate->itemSize();
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
- workArea.adjust(12, 12, -12, -12);
+ workArea.adjust(WORK_AREA_MARGIN, WORK_AREA_MARGIN, -WORK_AREA_MARGIN, -WORK_AREA_MARGIN);
const QString desktopDir = XdgDir::readDesktopDir() + QString(QLatin1String("/"));
- QPoint pos = mapFromGlobal(e->pos());
+ QPoint pos = e->pos();
const QList<QUrl> urlList = mimeData->urls();
for(const QUrl& url : urlList) {
QString name = url.fileName();
@@ -1352,12 +1353,10 @@ void DesktopWindow::stickToPosition(cons
}
void DesktopWindow::alignToGrid(QPoint& pos, const QPoint& topLeft, const QSize& grid, const int spacing) {
- qreal w = qAbs((qreal)pos.x() - (qreal)topLeft.x())
- / (qreal)(grid.width() + spacing);
- qreal h = qAbs((qreal)pos.y() - (qreal)topLeft.y())
- / (qreal)(grid.height() + spacing);
- pos.setX(topLeft.x() + qRound(w) * (grid.width() + spacing));
- pos.setY(topLeft.y() + qRound(h) * (grid.height() + spacing));
+ int w = qAbs(pos.x() - topLeft.x()) / (grid.width() + spacing);
+ int h = qAbs(pos.y() - topLeft.y()) / (grid.height() + spacing);
+ pos.setX(topLeft.x() + w * (grid.width() + spacing));
+ pos.setY(topLeft.y() + h * (grid.height() + spacing));
}
void DesktopWindow::closeEvent(QCloseEvent* event) {