From 198ce47fecec858e642eb92b7724acc83b40943c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 19 Jan 2015 15:28:17 +0100 Subject: [PATCH 1/3] [scene-xrender] Trigger a full decoration repaint when sizes are dirty When the pixmaps are re-created we should ensure that they are filled with proper content. BUG: 342980 REVIEW: 122148 --- scene_xrender.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene_xrender.cpp b/scene_xrender.cpp index 36b7588c0f..47d9d839c4 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -1300,13 +1300,14 @@ SceneXRenderDecorationRenderer::~SceneXRenderDecorationRenderer() void SceneXRenderDecorationRenderer::render() { - const QRegion scheduled = getScheduled(); + QRegion scheduled = getScheduled(); if (scheduled.isEmpty()) { return; } if (areImageSizesDirty()) { resizePixmaps(); resetImageSizesDirty(); + scheduled = client()->client()->decorationRect(); } const QRect top(QPoint(0, 0), m_sizes[int(DecorationPart::Top)]); From 4a260c6f42f5d09f1657b750fc2eb72dafcf4f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 20 Jan 2015 15:16:38 +0100 Subject: [PATCH 2/3] [kcmkwin/tabbox] Improve locating the services used in preview mode Instead of hard coding the desktop files, let's try to use what the user actually uses. * Browser mapped from text/html mime type * File manager mapped from inode/directory mime type * Email client mapped from message/rfc822 mime type Only systemsettings is "hard coded" as there is no mime type to map. The thumbnails are not changed, though. But they are so small that it's hardly recognizable anyway. For future it could be considered to map against appdata to get a better screenshot. BUG: 310622 REVIEW: 122170 --- kcmkwin/kwintabbox/layoutpreview.cpp | 45 ++++++++++++++++------------ kcmkwin/kwintabbox/layoutpreview.h | 7 ++++- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/kcmkwin/kwintabbox/layoutpreview.cpp b/kcmkwin/kwintabbox/layoutpreview.cpp index 87ed1baea1..1575c4b1a2 100644 --- a/kcmkwin/kwintabbox/layoutpreview.cpp +++ b/kcmkwin/kwintabbox/layoutpreview.cpp @@ -29,7 +29,7 @@ along with this program. If not, see . #include #include #include -#include +#include namespace KWin { @@ -132,14 +132,21 @@ ExampleClientModel::~ExampleClientModel() void ExampleClientModel::init() { - QList applications; - applications << "konqbrowser" << "KMail2" << "systemsettings" << "dolphin"; - - foreach (const QString& application, applications) { - KService::Ptr service = KService::serviceByStorageId("kde4-" + application + ".desktop"); - if (service) { - m_nameList << service->entryPath(); - } + if (const auto s = KMimeTypeTrader::self()->preferredService(QStringLiteral("inode/directory"))) { + m_services << s; + m_fileManager = s; + } + if (const auto s = KMimeTypeTrader::self()->preferredService(QStringLiteral("text/html"))) { + m_services << s; + m_browser = s; + } + if (const auto s = KMimeTypeTrader::self()->preferredService(QStringLiteral("message/rfc822"))) { + m_services << s; + m_email = s; + } + if (const auto s = KService::serviceByDesktopName(QStringLiteral("kdesystemsettings"))) { + m_services << s; + m_systemSettings = s; } } @@ -151,22 +158,22 @@ QVariant ExampleClientModel::data(const QModelIndex &index, int role) const switch (role) { case Qt::DisplayRole: case Qt::UserRole: - return KDesktopFile(m_nameList.at(index.row())).readName(); + return m_services.at(index.row())->name(); case Qt::UserRole+1: return false; case Qt::UserRole+2: return i18nc("An example Desktop Name", "Desktop 1"); case Qt::UserRole+3: - return QIcon::fromTheme(KDesktopFile(m_nameList.at(index.row())).readIcon()); + return m_services.at(index.row())->icon(); case Qt::UserRole+4: - const QString desktopFile = KDesktopFile(m_nameList.at(index.row())).fileName().split('/').last(); - if (desktopFile == "konqbrowser.desktop") { + const auto s = m_services.at(index.row()); + if (s == m_browser) { return WindowThumbnailItem::Konqueror; - } else if (desktopFile == "KMail2.desktop") { + } else if (s == m_email) { return WindowThumbnailItem::KMail; - } else if (desktopFile == "systemsettings.desktop") { + } else if (s == m_systemSettings) { return WindowThumbnailItem::Systemsettings; - } else if (desktopFile == "dolphin.desktop") { + } else if (s == m_fileManager) { return WindowThumbnailItem::Dolphin; } return 0; @@ -177,8 +184,8 @@ QVariant ExampleClientModel::data(const QModelIndex &index, int role) const QString ExampleClientModel::longestCaption() const { QString caption; - for (QString item : m_nameList) { - QString name = KDesktopFile(item).readName(); + for (const auto item : m_services) { + const QString name = item->name(); if (name.size() > caption.size()) { caption = name; } @@ -189,7 +196,7 @@ QString ExampleClientModel::longestCaption() const int ExampleClientModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - return m_nameList.size(); + return m_services.size(); } SwitcherItem::SwitcherItem(QObject *parent) diff --git a/kcmkwin/kwintabbox/layoutpreview.h b/kcmkwin/kwintabbox/layoutpreview.h index 8180d34589..9a7d65ef5a 100644 --- a/kcmkwin/kwintabbox/layoutpreview.h +++ b/kcmkwin/kwintabbox/layoutpreview.h @@ -20,6 +20,7 @@ along with this program. If not, see . #ifndef KWIN_TABBOX_LAYOUTPREVIEW_H #define KWIN_TABBOX_LAYOUTPREVIEW_H +#include #include #include #include @@ -57,7 +58,11 @@ public: private: void init(); - QStringList m_nameList; + QList m_services; + KService::Ptr m_fileManager; + KService::Ptr m_browser; + KService::Ptr m_email; + KService::Ptr m_systemSettings; }; From 6e67badfabb420a49f90e7be01aa0bd2bacef6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 19 Jan 2015 09:24:54 +0100 Subject: [PATCH 3/3] Handle case that XCURSOR_SIZE environment variable is not set In a default startup startkde does not set XCURSOR_SIZE environment variable. Only XCURSOR_THEME is set. The size should be DPI dependent. With this patch Cursor is able to handle this situation and does not fall back to loading the config from file. Logic is taken from KHintsSettings in frameworkintegration which in turn is from KApplication. REVIEW: 122139 --- cursor.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cursor.cpp b/cursor.cpp index 1207483313..f68437dc16 100644 --- a/cursor.cpp +++ b/cursor.cpp @@ -31,6 +31,7 @@ along with this program. If not, see . #include // Qt #include +#include #include // Xlib #include @@ -78,7 +79,17 @@ void Cursor::loadThemeSettings() { QString themeName = QString::fromUtf8(qgetenv("XCURSOR_THEME")); bool ok = false; - uint themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok); + // XCURSOR_SIZE might not be set (e.g. by startkde) + uint themeSize = 0; + if (qEnvironmentVariableIsSet("XCURSOR_SIZE")) { + themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok); + } + if (!ok) { + if (QScreen *s = QGuiApplication::primaryScreen()) { + themeSize = s->logicalDotsPerInchY() * 16 / 72; + ok = true; + } + } if (!themeName.isEmpty() && ok) { updateTheme(themeName, themeSize); return;