From 0a5c4b46f9de719bbc8e116cbf7707a320f7e6d3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 21 Nov 2021 11:42:44 +0100 Subject: [PATCH] Added fullscreening, 3 points off the roadmap! --- README.md | 2 +- src/KeybindManager.cpp | 12 ++++++++++++ src/KeybindManager.hpp | 1 + src/bar/Bar.cpp | 3 +++ src/utilities/Workspace.cpp | 4 ++++ src/utilities/Workspace.hpp | 5 +++++ src/window.hpp | 3 +++ src/windowManager.cpp | 29 ++++++++++++++++++++++++++++- 8 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/utilities/Workspace.cpp diff --git a/README.md b/README.md index ae8881b..7cd7a5c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Hypr is a Linux tiling window manager for Xorg. It's written in XCB with modern - [ ] Floating windows support - [ ] Config system - [x] Workspaces -- [ ] Moving windows / user input (e.g. fullscreening) +- [x] Moving windows / user input (e.g. fullscreening) ~ More to be done probably - [ ] True lerp animations

diff --git a/src/KeybindManager.cpp b/src/KeybindManager.cpp index 9b2f5ec..23add20 100644 --- a/src/KeybindManager.cpp +++ b/src/KeybindManager.cpp @@ -28,6 +28,9 @@ void KeybindManager::reloadAllKeybinds() { KeybindManager::keybinds.push_back(Keybind(MOD_SUPER, 0xff52 /* ^ */, "t", &KeybindManager::movewindow)); KeybindManager::keybinds.push_back(Keybind(MOD_SUPER, 0xff54 /* v */, "b", &KeybindManager::movewindow)); + // Fullscreen + KeybindManager::keybinds.push_back(Keybind(MOD_SUPER, 0x66 /* F */, "", &KeybindManager::toggleActiveWindowFullscreen)); + // workspace binds for (int i = 0; i < 10; ++i) { // MOD + 1-9 @@ -127,4 +130,13 @@ void KeybindManager::changeworkspace(std::string arg) { g_pWindowManager->changeWorkspaceByID(ID); g_pWindowManager->setAllWorkspaceWindowsDirtyByID(ID); } +} + +void KeybindManager::toggleActiveWindowFullscreen(std::string unusedArg) { + g_pWindowManager->setAllWorkspaceWindowsDirtyByID(g_pWindowManager->activeWorkspace->getID()); + + if (auto WINDOW = g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow) ; WINDOW) { + WINDOW->setFullscreen(!WINDOW->getFullscreen()); + g_pWindowManager->activeWorkspace->setHasFullscreenWindow(WINDOW->getFullscreen()); + } } \ No newline at end of file diff --git a/src/KeybindManager.hpp b/src/KeybindManager.hpp index 9b87b8a..25f27a8 100644 --- a/src/KeybindManager.hpp +++ b/src/KeybindManager.hpp @@ -19,4 +19,5 @@ namespace KeybindManager { void killactive(std::string args); void movewindow(std::string args); void changeworkspace(std::string args); + void toggleActiveWindowFullscreen(std::string args); }; \ No newline at end of file diff --git a/src/bar/Bar.cpp b/src/bar/Bar.cpp index 00d953c..f26dcc2 100644 --- a/src/bar/Bar.cpp +++ b/src/bar/Bar.cpp @@ -93,6 +93,9 @@ int getTextWidth(std::string text, xcb_font_t font) { void CStatusBar::draw() { + if (g_pWindowManager->activeWorkspace->getHasFullscreenWindow()) + return; // Do not draw a bar on a fullscreen window. + xcb_rectangle_t rectangles[] = {{m_vecPosition.x, m_vecPosition.y, m_vecSize.x + m_vecPosition.x, m_vecPosition.y + m_vecSize.y}}; xcb_poly_fill_rectangle(g_pWindowManager->DisplayConnection, m_iPixmap, m_mContexts["BG"].GContext, 1, rectangles); diff --git a/src/utilities/Workspace.cpp b/src/utilities/Workspace.cpp new file mode 100644 index 0000000..c75ef42 --- /dev/null +++ b/src/utilities/Workspace.cpp @@ -0,0 +1,4 @@ +#include "Workspace.hpp" + +CWorkspace::CWorkspace() { this->m_bHasFullscreenWindow = false; } +CWorkspace::~CWorkspace() { } \ No newline at end of file diff --git a/src/utilities/Workspace.hpp b/src/utilities/Workspace.hpp index aa2e945..67f2382 100644 --- a/src/utilities/Workspace.hpp +++ b/src/utilities/Workspace.hpp @@ -4,6 +4,11 @@ class CWorkspace { public: + CWorkspace(); + ~CWorkspace(); + EXPOSED_MEMBER(ID, int, i); EXPOSED_MEMBER(LastWindow, xcb_drawable_t, i); + + EXPOSED_MEMBER(HasFullscreenWindow, bool, b); }; diff --git a/src/window.hpp b/src/window.hpp index 4095900..c006464 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -26,6 +26,9 @@ public: EXPOSED_MEMBER(IsFloating, bool, b); EXPOSED_MEMBER(Drawable, xcb_drawable_t, i); + // Fullscreen + EXPOSED_MEMBER(Fullscreen, bool, b); + // Workspace pointer EXPOSED_MEMBER(WorkspaceID, int, i); diff --git a/src/windowManager.cpp b/src/windowManager.cpp index a1b49d8..ce22152 100644 --- a/src/windowManager.cpp +++ b/src/windowManager.cpp @@ -163,8 +163,12 @@ void CWindowManager::refreshDirtyWindows() { for(auto& window : windows) { if (window.getDirty()) { + // Fullscreen flag + bool bHasFullscreenWindow = activeWorkspace->getHasFullscreenWindow(); + // first and foremost, let's check if the window isn't on a different workspace - if (window.getWorkspaceID() != activeWorkspace->getID()) { + // or that it is not a non-fullscreen window in a fullscreen workspace + if ((window.getWorkspaceID() != activeWorkspace->getID()) || (bHasFullscreenWindow && !window.getFullscreen())) { // Move it to hades Values[0] = (int)1500000; // hmu when monitors actually have that many pixels Values[1] = (int)1500000; // and we are still using xorg =) @@ -178,6 +182,25 @@ void CWindowManager::refreshDirtyWindows() { continue; } + // Fullscreen window. No border, all screen. + if (window.getFullscreen()) { + Values[0] = 0; + xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_BORDER_WIDTH, Values); + + Values[0] = 0x555555; // GRAY :) + xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values); + + Values[0] = (int)Screen->width_in_pixels; + Values[1] = (int)Screen->height_in_pixels; + xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); + + Values[0] = (int)0; + Values[1] = (int)0; + xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values); + + continue; + } + Values[0] = (int)window.getEffectiveSize().x; Values[1] = (int)window.getEffectiveSize().y; xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values); @@ -402,6 +425,10 @@ void CWindowManager::fixWindowOnClose(CWindow* pClosedWindow) { if (!pClosedWindow) return; + // Fix if was fullscreen + if (pClosedWindow->getFullscreen()) + activeWorkspace->setHasFullscreenWindow(false); + // get the first neighboring window CWindow* neighbor = nullptr; for(auto& w : windows) {