Skip to content

Commit

Permalink
chore: hide window when lost focus, cleanup some logs
Browse files Browse the repository at this point in the history
当窗口失去焦点时,(延迟)隐藏窗口。并移除部分初版调试用的日志信息。

Log:
  • Loading branch information
BLumia committed Aug 14, 2023
1 parent f00906a commit fe0d8c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
13 changes: 12 additions & 1 deletion launchercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
#include <QStandardPaths>
#include <DGuiApplicationHelper>
#include <QCommandLineParser>
#include <DRegionMonitor>

DGUI_USE_NAMESPACE

LauncherController::LauncherController(QObject *parent)
: QObject(parent)
, optShow(QStringList{"s", "show"}, tr("Show launcher (hidden by default)"))
, optToggle(QStringList{"t", "toggle"}, tr("Toggle launcher visibility"))
, m_regionMonitor(new DRegionMonitor(this))
, m_visible(false)
{
// TODO: settings should be managed in somewhere else.
Expand All @@ -42,15 +44,24 @@ LauncherController::LauncherController(QObject *parent)
}
});

// for dbus adapter signals.
// for dbus adapter signals, AND for m_regionMonitor.
connect(this, &LauncherController::visibleChanged, this, [this](bool isVisible){
if (isVisible) {
m_regionMonitor->registerRegion();
emit Shown();
} else {
m_regionMonitor->unregisterRegion();
emit Closed();
}
emit VisibleChanged(isVisible);
});

// since the launcher window is tend to be x11bypassed
m_regionMonitor->setCoordinateType(Dtk::Gui::DRegionMonitor::Original);

connect(m_regionMonitor, &DRegionMonitor::buttonPress, this, [](const QPoint &p, const int flag){
qDebug() << p << flag << "do we really need x11bypass just for hidding launcher window?";
});
}

void LauncherController::Exit()
Expand Down
6 changes: 6 additions & 0 deletions launchercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <QCommandLineOption>
#include <QObject>

namespace Dtk {
namespace Gui {
class DRegionMonitor;
}
}
class LauncherController : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -56,6 +61,7 @@ class LauncherController : public QObject
private:
explicit LauncherController(QObject *parent=nullptr);

Dtk::Gui::DRegionMonitor *m_regionMonitor;
bool m_visible;
QString m_currentFrame;
};
2 changes: 1 addition & 1 deletion qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Control {

placeholder: qsTr("Search")
onTextChanged: {
console.log(text)
// console.log(text)
SearchFilterProxyModel.setFilterRegularExpression(text)
}
}
Expand Down
18 changes: 17 additions & 1 deletion qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ ApplicationWindow {
updateWindowVisibilityAndPosition()
}

Timer {
id: delayHideTimer
interval: 500
onTriggered: {
if (!DebugHelper.avoidHideWindow) {
LauncherController.visible = false
}
}
}

onActiveChanged: {
if (!active) {
delayHideTimer.running = true
}
}

function launchApp(desktopId) {
if (DebugHelper.avoidLaunchApp) {
DTK.sendSystemMessage("dde-launchpad (debug)",
Expand Down Expand Up @@ -71,7 +87,7 @@ ApplicationWindow {

let dockGeometry = DesktopIntegration.dockGeometry
if (dockGeometry.width > 0 && dockGeometry.height > 0) {
console.log(114514, dockGeometry)
// console.log(114514, dockGeometry)
switch (DesktopIntegration.dockPosition) {
case Qt.DownArrow:
x = dockGeometry.left
Expand Down
4 changes: 2 additions & 2 deletions src/ddeintegration/appearance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ void Appearance::updateCurrentWallpaperBlurhash()
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher* call){
QDBusPendingReply<QString> reply = *call;
if (reply.isError()) {
qDebug() << "bbbbbbbbb" << reply.error();
qDebug() << "Cannot get wallpaper from dbus:" << reply.error();
} else {
QUrl wallpaperUrl(reply.value());
qDebug() << "aaaaaaaaa" << wallpaperUrl;
qDebug() << "Got wallpaper URL from dbus:" << wallpaperUrl;

QFuture<QString> blurhashFuture = QtConcurrent::run([wallpaperUrl](){
QImage image;
Expand Down

0 comments on commit fe0d8c2

Please sign in to comment.