diff --git a/desktop/gateway/gateway.cpp b/desktop/gateway/gateway.cpp index f6a48cb9..760ff9db 100644 --- a/desktop/gateway/gateway.cpp +++ b/desktop/gateway/gateway.cpp @@ -72,8 +72,8 @@ Gateway::Gateway() : } }); - DesktopWm::setSystemWindow(this, DesktopWm::SystemWindowTypeMenu); this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + DesktopWm::setSystemWindow(this, DesktopWm::SystemWindowTypeMenu); this->setFixedWidth(0); connect(GestureDaemon::instance(), &GestureDaemon::gestureBegin, this, [ = ](GestureInteractionPtr interaction) { diff --git a/startdesk/thedesk-wayland.desktop b/startdesk/thedesk-wayland.desktop index 6089cc6a..715f56ff 100644 --- a/startdesk/thedesk-wayland.desktop +++ b/startdesk/thedesk-wayland.desktop @@ -4,5 +4,5 @@ Type=Application Exec=/usr/bin/wayfire --config /usr/share/thedesk/startdesk/wayfire-thedesk-config.conf TryExec=/usr/bin/wayfire DesktopNames=theDesk -Name=theDesk (Wayland) +Name=theDesk on Wayland Comment=theDesk Desktop Environment diff --git a/startdesk/wayfire-thedesk-config.conf b/startdesk/wayfire-thedesk-config.conf index 346f9c67..7d1930ce 100644 --- a/startdesk/wayfire-thedesk-config.conf +++ b/startdesk/wayfire-thedesk-config.conf @@ -38,9 +38,6 @@ # See Output options for a complete reference. # https://github.com/WayfireWM/wayfire/wiki/Configuration#output -[output:HDMI-A-1] -mode = 3840x2160@30000 - # Core options ───────────────────────────────────────────────────────────────── [core] @@ -70,6 +67,7 @@ plugins = \ wobbly \ wrot \ zoom \ + thedesk-keygrab \ thedesk-startdesk # Note: [blur] is not enabled by default, because it can be resource-intensive. diff --git a/wayfire-plugins/keygrab-plugin/keygrab-plugin.pro b/wayfire-plugins/keygrab-plugin/keygrab-plugin.pro new file mode 100644 index 00000000..e5c3f618 --- /dev/null +++ b/wayfire-plugins/keygrab-plugin/keygrab-plugin.pro @@ -0,0 +1,19 @@ +CONFIG += qt + +TEMPLATE = lib +DEFINES += KEYGRABPLUGIN_LIBRARY +TARGET = thedesk-keygrab + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + keygrabplugin.cpp + +HEADERS += \ + keygrabplugin.h + +WAYLAND_PROTOCOL_EXTENSIONS += /usr/share/libtdesktopenvironment/wayland-protocols/tdesktopenvironment-keygrab-v1.xml + +include(../plugins.pri) diff --git a/wayfire-plugins/keygrab-plugin/keygrab-plugin_global.h b/wayfire-plugins/keygrab-plugin/keygrab-plugin_global.h new file mode 100644 index 00000000..228005f5 --- /dev/null +++ b/wayfire-plugins/keygrab-plugin/keygrab-plugin_global.h @@ -0,0 +1,31 @@ +/**************************************** + * + * INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE + * Copyright (C) 2021 Victor Tran + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +#ifndef KEYGRABPLUGIN_GLOBAL_H +#define KEYGRABPLUGIN_GLOBAL_H + +#include + +#if defined(KEYGRABPLUGIN_LIBRARY) +# define KEYGRABPLUGIN_EXPORT Q_DECL_EXPORT +#else +# define KEYGRABPLUGIN_EXPORT Q_DECL_IMPORT +#endif + +#endif // KEYGRABPLUGIN_GLOBAL_H diff --git a/wayfire-plugins/keygrab-plugin/keygrabplugin.cpp b/wayfire-plugins/keygrab-plugin/keygrabplugin.cpp new file mode 100644 index 00000000..225c185a --- /dev/null +++ b/wayfire-plugins/keygrab-plugin/keygrabplugin.cpp @@ -0,0 +1,85 @@ +/**************************************** + * + * INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE + * Copyright (C) 2021 Victor Tran + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +#include "keygrabplugin.h" + +#include +#include + +#include +#include "wayland-tdesktopenvironment-keygrab-v1-server-protocol.h" +#include + +struct KeygrabPluginPrivate { + wl_resource* tdeKeygrabManager; +}; + +KeygrabPlugin::KeygrabPlugin() { + d = new KeygrabPluginPrivate(); +} + +KeygrabPlugin::~KeygrabPlugin() { + delete d; +} + +void KeygrabPlugin::grabKey(wl_client* client, uint32_t mod, uint32_t key) { + std::cout << "Grabbing key " << key << " mod " << mod << "\n"; + output->add_key(wf::create_option(wf::keybinding_t(mod, key)), new wf::key_callback([ = ](const wf::keybinding_t& keybind) { + std::cout << "Pressed " << key << " mod " << mod << "\n"; + tdesktopenvironment_keygrab_manager_v1_send_activated(d->tdeKeygrabManager, mod, key, 0); + return true; + })); +} + +void KeygrabPlugin::ungrabKey(wl_client* client, uint32_t mod, uint32_t key) { + +} + +void KeygrabPlugin::init() { + output->add_key(wf::create_option(wf::keybinding_t(0, 36)), new wf::key_callback([ = ](const wf::keybinding_t& key) { + std::cout << "Pressed J\n"; + return true; + })); + +// wf::get_core(). + wl_global_create(wf::get_core().display, &tdesktopenvironment_keygrab_manager_v1_interface, 1, this, [](wl_client * client, void* data, uint32_t version, uint32_t id) { + KeygrabPlugin* plugin = reinterpret_cast(data); + + plugin->d->tdeKeygrabManager = wl_resource_create(client, &tdesktopenvironment_keygrab_manager_v1_interface, 1, id); + + struct tdesktopenvironment_keygrab_manager_v1_interface* interface = new struct tdesktopenvironment_keygrab_manager_v1_interface(); + interface->grab_key = [](struct wl_client * client, struct wl_resource * resource, uint32_t mod, uint32_t key) { + reinterpret_cast(resource->data)->grabKey(client, mod, key); + }; + interface->ungrab_key = [](struct wl_client * client, struct wl_resource * resource, uint32_t mod, uint32_t key) { + reinterpret_cast(resource->data)->ungrabKey(client, mod, key); + }; + interface->destroy = [](struct wl_client * client, struct wl_resource * resource) { + + }; + wl_resource_set_implementation(plugin->d->tdeKeygrabManager, interface, plugin, nullptr); + }); +} + +void KeygrabPlugin::fini() { +} + +bool KeygrabPlugin::is_unloadable() { + return false; +} diff --git a/wayfire-plugins/keygrab-plugin/keygrabplugin.h b/wayfire-plugins/keygrab-plugin/keygrabplugin.h new file mode 100644 index 00000000..89f60196 --- /dev/null +++ b/wayfire-plugins/keygrab-plugin/keygrabplugin.h @@ -0,0 +1,47 @@ +/**************************************** + * + * INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE + * Copyright (C) 2021 Victor Tran + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * *************************************/ +#ifndef KEYGRABPLUGIN_H +#define KEYGRABPLUGIN_H + +#include + +struct wl_client; +struct KeygrabPluginPrivate; +class KeygrabPlugin : public wf::plugin_interface_t { + public: + KeygrabPlugin(); + ~KeygrabPlugin(); + + void grabKey(wl_client* client, uint32_t mod, uint32_t key); + void ungrabKey(wl_client* client, uint32_t mod, uint32_t key); + + // plugin_interface_t interface + public: + void init(); + void fini(); + bool is_unloadable(); + + private: + KeygrabPluginPrivate* d; +}; + +DECLARE_WAYFIRE_PLUGIN(KeygrabPlugin) + +#endif // KEYGRABPLUGIN_H diff --git a/wayfire-plugins/plugins.pri b/wayfire-plugins/plugins.pri index 17161ac1..3c3b9735 100644 --- a/wayfire-plugins/plugins.pri +++ b/wayfire-plugins/plugins.pri @@ -9,5 +9,18 @@ CONFIG += c++17 plugin CONFIG += link_pkgconfig PKGCONFIG += wayfire wlroots +wayland_scanner_headers.output = wayland-${QMAKE_FILE_BASE}-server-protocol.h +wayland_scanner_headers.commands = wayland-scanner server-header ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT} +wayland_scanner_headers.input = WAYLAND_PROTOCOL_EXTENSIONS +wayland_scanner_headers.CONFIG += target_predeps no_link + +wayland_scanner_sources.output = wayland-${QMAKE_FILE_BASE}-server-protocol.c +wayland_scanner_sources.commands = wayland-scanner private-code ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT} +wayland_scanner_sources.input = WAYLAND_PROTOCOL_EXTENSIONS +wayland_scanner_sources.variable_out = SOURCES +wayland_scanner_headers.CONFIG += target_predeps no_link + +QMAKE_EXTRA_COMPILERS += wayland_scanner_headers wayland_scanner_sources + target.path = $$THELIBS_INSTALL_LIB/wayfire/ INSTALLS = target diff --git a/wayfire-plugins/wayfire-plugins.pro b/wayfire-plugins/wayfire-plugins.pro index 4e39e25c..b5d75495 100644 --- a/wayfire-plugins/wayfire-plugins.pro +++ b/wayfire-plugins/wayfire-plugins.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs SUBDIRS += \ + keygrab-plugin \ startdesk-plugin