kranewl

A wlroots-based dynamic Wayland compositor, written in C++, configurable with Lua
git clone git://git.deurzen.net/kranewl
Log | Files | Refs | LICENSE

commit 79fe78836bbd78fdeb49ac4e00333d19e83f7671
parent 3e4771ffa6642ee17448dca0f17f29842d95af81
Author: deurzen <m.deurzen@tum.de>
Date:   Wed, 18 May 2022 18:08:11 +0200

adds key bindings

Diffstat:
Minclude/version.hh | 4++--
Msrc/kranewl/conf/options.cc | 8++++----
Msrc/kranewl/exec.cc | 2+-
Msrc/kranewl/main.cc | 8++++++++
Msrc/kranewl/server.cc | 20++++++++++++--------
5 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/include/version.hh b/include/version.hh @@ -1 +1 @@ -#define VERSION "master/bc69f6b+" -\ No newline at end of file +#define VERSION "master/3e4771f+" +\ No newline at end of file diff --git a/src/kranewl/conf/options.cc b/src/kranewl/conf/options.cc @@ -15,8 +15,8 @@ static const std::string USAGE = "usage: kranewl [...options]\n\n" "options: \n" " -a <autostart_file> Path to an executable autostart file.\n" " -c <config_file> Path to a configuration file.\n" - " -h Prints this message.\n" - " -v Prints the version."; + " -v Prints the version.\n" + " -h Prints this message."; static std::string default_user_path(std::string const& path) noexcept @@ -88,14 +88,14 @@ parse_options(int argc, char** argv) noexcept case 'v': std::cout << VERSION << std::endl << std::flush; - exit(EXIT_SUCCESS); + std::exit(EXIT_SUCCESS); break; case '?': case 'h': default: std::cout << USAGE << std::endl << std::flush; - exit(EXIT_SUCCESS); + std::exit(EXIT_SUCCESS); break; } } diff --git a/src/kranewl/exec.cc b/src/kranewl/exec.cc @@ -7,6 +7,6 @@ exec_external(std::string& command) { if (!fork()) { setsid(); execl("/bin/sh", "/bin/sh", "-c", ("exec " + command).c_str(), NULL); - exit(EXIT_SUCCESS); + std::exit(EXIT_SUCCESS); } } diff --git a/src/kranewl/main.cc b/src/kranewl/main.cc @@ -11,11 +11,19 @@ #include <spdlog/spdlog.h> +extern "C" { +#include <wlr/util/log.h> +} + #include <string> int main(int argc, char** argv) { +#ifndef NDEBUG + wlr_log_init(WLR_DEBUG, NULL); +#endif + const Options options = parse_options(argc, argv); spdlog::info("Initializing kranewl-" VERSION); diff --git a/src/kranewl/server.cc b/src/kranewl/server.cc @@ -3,6 +3,7 @@ #include <kranewl/input/keyboard.hh> #include <kranewl/tree/output.hh> #include <kranewl/tree/view.hh> +#include <kranewl/exec.hh> #include <spdlog/spdlog.h> @@ -30,7 +31,6 @@ extern "C" { #include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xdg_shell.h> #include <wlr/util/box.h> -#include <wlr/util/log.h> #ifdef WLR_HAS_XWAYLAND #include <wlr/xwayland.h> #endif @@ -57,8 +57,6 @@ Server::Server() m_allocator(wlr_allocator_autocreate(m_backend, m_renderer)), m_socket(wl_display_add_socket_auto(m_display)) { - wlr_log_init(WLR_DEBUG, NULL); - wlr_compositor_create(m_display, m_renderer); wlr_data_device_manager_create(m_display); @@ -108,14 +106,14 @@ Server::Server() if (m_socket.empty()) { wlr_backend_destroy(m_backend); - exit(1); + std::exit(1); return; } if (!wlr_backend_start(m_backend)) { wlr_backend_destroy(m_backend); wl_display_destroy(m_display); - exit(1); + std::exit(1); return; } @@ -497,13 +495,19 @@ Server::keyboard_handle_keybinding(Server* server, xkb_keysym_t sym) case XKB_KEY_Escape: wl_display_terminate(server->m_display); break; - case XKB_KEY_F1: + case XKB_KEY_j: { if (wl_list_length(&server->m_views) < 2) break; - View* next_view = wl_container_of(server->m_views.prev, next_view, link); - focus_view(next_view, next_view->xdg_surface->surface); + View* prev_view = wl_container_of(server->m_views.prev, prev_view, link); + focus_view(prev_view, prev_view->xdg_surface->surface); + } + break; + case XKB_KEY_Return: + { + std::string foot = "foot"; + exec_external(foot); } break; default: return false;