From 78882ff6b13ea8c5e7c14bee51c87f199e9c8a20 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Fri, 18 Oct 2013 18:42:41 +0200 Subject: Fix MainWindow Icon; Fix WM_CLASS issue; now links QX11Extras and libxcb on linux --- CMakeLists.txt | 11 +++++++- gui/EditNotesDialog.cpp | 2 ++ gui/IconPickerDialog.cpp | 2 ++ gui/LegacyModEditDialog.cpp | 2 ++ gui/OneSixModEditDialog.cpp | 4 ++- gui/ProgressDialog.cpp | 2 ++ gui/aboutdialog.cpp | 2 ++ gui/consolewindow.cpp | 3 +++ gui/instancesettings.cpp | 2 ++ gui/logindialog.cpp | 4 ++- gui/lwjglselectdialog.cpp | 2 ++ gui/mainwindow.cpp | 2 ++ gui/mainwindow.ui | 4 +++ gui/newinstancedialog.cpp | 2 ++ gui/platform.h | 35 +++++++++++++++++++++++++ gui/platform_other.cpp | 27 ++++++++++++++++++++ gui/platform_x11.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++ gui/settingsdialog.cpp | 2 ++ gui/versionselectdialog.cpp | 2 ++ 19 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 gui/platform.h create mode 100644 gui/platform_other.cpp create mode 100644 gui/platform_x11.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 64823772..b7dd6ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,15 @@ IF(WIN32) SET(MULTIMC_RCS multimc.rc) ENDIF() +####### X11 Stuff ####### +IF(UNIX AND NOT APPLE) + SET(MultiMC_QT_ADDITIONAL_MODULES ${MultiMC_QT_ADDITIONAL_MODULES} X11Extras) + SET(MultiMC_LINK_ADDITIONAL_LIBS ${MultiMC_LINK_ADDITIONAL_LIBS} xcb) + LIST(APPEND MULTIMC_SOURCES gui/platform_x11.cpp) +ELSE() + LIST(APPEND MULTIMC_SOURCES gui/platform_other.cpp) +ENDIF() + ################################ COMPILE ################################ @@ -380,7 +389,7 @@ ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 # Link TARGET_LINK_LIBRARIES(MultiMC xz-embedded unpack200 quazip libUtil libSettings libGroupView ${MultiMC_LINK_ADDITIONAL_LIBS}) -QT5_USE_MODULES(MultiMC Core Widgets Network Xml) +QT5_USE_MODULES(MultiMC Core Widgets Network Xml ${MultiMC_QT_ADDITIONAL_MODULES}) ADD_DEPENDENCIES(MultiMC MultiMCLauncher) option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF) diff --git a/gui/EditNotesDialog.cpp b/gui/EditNotesDialog.cpp index 5b90ef53..535ca804 100644 --- a/gui/EditNotesDialog.cpp +++ b/gui/EditNotesDialog.cpp @@ -1,5 +1,6 @@ #include "EditNotesDialog.h" #include "ui_EditNotesDialog.h" +#include "gui/platform.h" #include #include @@ -10,6 +11,7 @@ EditNotesDialog::EditNotesDialog( QString notes, QString name, QWidget* parent ) QDialog(parent), ui(new Ui::EditNotesDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); ui->noteEditor->setText(notes); setWindowTitle(tr("Edit notes of %1").arg(m_instance_name)); diff --git a/gui/IconPickerDialog.cpp b/gui/IconPickerDialog.cpp index 6a1ca546..ebacf87c 100644 --- a/gui/IconPickerDialog.cpp +++ b/gui/IconPickerDialog.cpp @@ -3,6 +3,7 @@ #include "instancedelegate.h" #include "ui_IconPickerDialog.h" #include "logic/lists/IconList.h" +#include "gui/platform.h" #include #include #include @@ -11,6 +12,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) : QDialog(parent), ui(new Ui::IconPickerDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); setWindowModality(Qt::WindowModal); diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 82532cfd..b230193a 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -21,6 +21,7 @@ #include "ui_LegacyModEditDialog.h" #include "logic/ModList.h" #include "logic/lists/ForgeVersionList.h" +#include "gui/platform.h" #include #include @@ -32,6 +33,7 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) : m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); // Jar mods diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index e072a238..88738938 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -20,8 +20,9 @@ #include "logic/OneSixVersion.h" #include "logic/EnabledItemFilter.h" #include "logic/lists/ForgeVersionList.h" -#include +#include "logic/ForgeInstaller.h" #include "gui/versionselectdialog.h" +#include "gui/platform.h" #include "ProgressDialog.h" #include @@ -35,6 +36,7 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) : m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); // libraries! diff --git a/gui/ProgressDialog.cpp b/gui/ProgressDialog.cpp index 154ab1c0..2e5251a0 100644 --- a/gui/ProgressDialog.cpp +++ b/gui/ProgressDialog.cpp @@ -19,11 +19,13 @@ #include #include "logic/tasks/Task.h" +#include "gui/platform.h" ProgressDialog::ProgressDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ProgressDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); updateSize(); diff --git a/gui/aboutdialog.cpp b/gui/aboutdialog.cpp index 9792d4fe..7105446c 100644 --- a/gui/aboutdialog.cpp +++ b/gui/aboutdialog.cpp @@ -2,11 +2,13 @@ #include "ui_aboutdialog.h" #include #include +#include "gui/platform.h" AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64)); diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp index 5cd332c4..deeedd65 100644 --- a/gui/consolewindow.cpp +++ b/gui/consolewindow.cpp @@ -4,12 +4,15 @@ #include #include +#include + ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : QDialog(parent), ui(new Ui::ConsoleWindow), m_mayclose(true), proc(mcproc) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded())); } diff --git a/gui/instancesettings.cpp b/gui/instancesettings.cpp index dfb04f3d..73eb6627 100644 --- a/gui/instancesettings.cpp +++ b/gui/instancesettings.cpp @@ -19,12 +19,14 @@ #include "instancesettings.h" #include "ui_instancesettings.h" +#include "gui/platform.h" InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) : m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); loadSettings(); } diff --git a/gui/logindialog.cpp b/gui/logindialog.cpp index fdc94ac7..ed3983b7 100644 --- a/gui/logindialog.cpp +++ b/gui/logindialog.cpp @@ -16,12 +16,14 @@ #include "logindialog.h" #include "ui_logindialog.h" #include "keyring.h" +#include "gui/platform.h" #include LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) : QDialog(parent), ui(new Ui::LoginDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); //: Use offline mode one time @@ -194,4 +196,4 @@ void LoginDialog::forceOnline() { onlineForced = true; offlineButton->setEnabled(false); -} \ No newline at end of file +} diff --git a/gui/lwjglselectdialog.cpp b/gui/lwjglselectdialog.cpp index 4518e8cd..09963ce0 100644 --- a/gui/lwjglselectdialog.cpp +++ b/gui/lwjglselectdialog.cpp @@ -16,6 +16,7 @@ #include "MultiMC.h" #include "lwjglselectdialog.h" #include "ui_lwjglselectdialog.h" +#include "gui/platform.h" #include "logic/lists/LwjglVersionList.h" @@ -23,6 +24,7 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LWJGLSelectDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); ui->labelStatus->setVisible(false); auto lwjgllist = MMC->lwjgllist(); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index ae244d91..294ffd3d 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -48,6 +48,7 @@ #include "gui/lwjglselectdialog.h" #include "gui/consolewindow.h" #include "gui/instancesettings.h" +#include "gui/platform.h" #include "logic/lists/InstanceList.h" #include "logic/lists/MinecraftVersionList.h" @@ -72,6 +73,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); setWindowTitle(QString("MultiMC %1").arg(MMC->version().toString())); diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 4c288d5f..0f883d13 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -13,6 +13,10 @@ MultiMC 5 + + + :/icons/multimc/scalable/apps/multimc.svg:/icons/multimc/scalable/apps/multimc.svg + diff --git a/gui/newinstancedialog.cpp b/gui/newinstancedialog.cpp index 04b38316..c37db2ac 100644 --- a/gui/newinstancedialog.cpp +++ b/gui/newinstancedialog.cpp @@ -23,6 +23,7 @@ #include "logic/lists/MinecraftVersionList.h" #include "logic/tasks/Task.h" +#include "gui/platform.h" #include "versionselectdialog.h" #include "ProgressDialog.h" #include "IconPickerDialog.h" @@ -33,6 +34,7 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) : QDialog(parent), ui(new Ui::NewInstanceDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); resize(minimumSizeHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); diff --git a/gui/platform.h b/gui/platform.h new file mode 100644 index 00000000..5cf9ed80 --- /dev/null +++ b/gui/platform.h @@ -0,0 +1,35 @@ +/* Copyright 2013 MultiMC Contributors + * + * Authors: Orochimarufan + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PLATFORM_H +#define PLATFORM_H + +/** + * @file platform.h + * This file contains platform-specific functions, tweaks and fixes. + */ + +#include + +class MultiMCPlatform +{ +public: + // X11 WM_CLASS + static void fixWM_CLASS(QWidget *widget); +}; + +#endif // PLATFORM_H diff --git a/gui/platform_other.cpp b/gui/platform_other.cpp new file mode 100644 index 00000000..0d7bcbe7 --- /dev/null +++ b/gui/platform_other.cpp @@ -0,0 +1,27 @@ +/* Copyright 2013 MultiMC Contributors + * + * Authors: Orochimarufan + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +/** + * Stub for non-X11 platforms + * @brief MultiMCPlatform::fixWM_CLASS + * @param widget + */ +MultiMCPlatform::fixWM_CLASS(QWidget *widget) +{ + Q_UNUSED(widget); +} diff --git a/gui/platform_x11.cpp b/gui/platform_x11.cpp new file mode 100644 index 00000000..0401e8bf --- /dev/null +++ b/gui/platform_x11.cpp @@ -0,0 +1,62 @@ +/* Copyright 2013 MultiMC Contributors + * + * Authors: Orochimarufan + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +static QByteArray WM_CLASS = "MultiMC5\0MultiMC5"; + +template +static inline unsigned int XcbCallVoid(xcb_void_cookie_t (*func)(xcb_connection_t *, ArgTypes...), ArgTypes2... args...) +{ + return func(QX11Info::connection(), args...).sequence; +} + +static void getAtoms(size_t n, xcb_atom_t *atoms, const char *const names[], bool create) +{ + xcb_connection_t *conn = QX11Info::connection(); + xcb_intern_atom_cookie_t *cookies = (xcb_intern_atom_cookie_t *)malloc(sizeof(xcb_intern_atom_cookie_t) * 2); + for (size_t i = 0; i < n; ++i) + cookies[i] = xcb_intern_atom(conn, create, strlen(names[i]), names[i]); + memset(atoms, 0, sizeof(xcb_atom_t) * n); + for (size_t i = 0; i < n; ++i) + { + xcb_intern_atom_reply_t *r = xcb_intern_atom_reply(conn, cookies[i], 0); + if (r) + { + atoms[i] = r->atom; + free(r); + } + } + free(cookies); +} + +static inline xcb_atom_t getAtom(const char *name, bool create=false) +{ + xcb_atom_t atom; + getAtoms(1, &atom, &name, create); + return atom; +} + +void MultiMCPlatform::fixWM_CLASS(QWidget *widget) +{ + static const xcb_atom_t atom = getAtom("WM_CLASS"); + XcbCallVoid(xcb_change_property, XCB_PROP_MODE_REPLACE, + widget->winId(), atom, XCB_ATOM_STRING, 8, WM_CLASS.count(), + WM_CLASS.constData()); +} diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index a3347680..14eba492 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -18,6 +18,7 @@ #include "ui_settingsdialog.h" #include "logic/JavaUtils.h" #include "gui/versionselectdialog.h" +#include "gui/platform.h" #include "logic/lists/JavaVersionList.h" #include @@ -28,6 +29,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); loadSettings(MMC->settings().get()); diff --git a/gui/versionselectdialog.cpp b/gui/versionselectdialog.cpp index 900cd092..8fa62f75 100644 --- a/gui/versionselectdialog.cpp +++ b/gui/versionselectdialog.cpp @@ -21,6 +21,7 @@ #include #include +#include "gui/platform.h" #include #include @@ -29,6 +30,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent, bool cancelable) : QDialog(parent), ui(new Ui::VersionSelectDialog) { + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); setWindowModality(Qt::WindowModal); setWindowTitle(title); -- cgit v1.2.3 From dcf58cdf12ae9370ba1bf9d6bb789649db82e520 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Fri, 18 Oct 2013 19:01:40 +0200 Subject: Derp - typo in platform_other.cpp --- gui/platform_other.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/platform_other.cpp b/gui/platform_other.cpp index 0d7bcbe7..a41abe36 100644 --- a/gui/platform_other.cpp +++ b/gui/platform_other.cpp @@ -21,7 +21,7 @@ * @brief MultiMCPlatform::fixWM_CLASS * @param widget */ -MultiMCPlatform::fixWM_CLASS(QWidget *widget) +void MultiMCPlatform::fixWM_CLASS(QWidget *widget) { Q_UNUSED(widget); } -- cgit v1.2.3