mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-12-25 10:49:49 +01:00
Added fullscreening, 3 points off the roadmap!
This commit is contained in:
parent
c5935ca560
commit
0a5c4b46f9
8 changed files with 57 additions and 2 deletions
|
@ -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
|
||||
|
||||
<br/><br/>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
};
|
|
@ -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);
|
||||
|
||||
|
|
4
src/utilities/Workspace.cpp
Normal file
4
src/utilities/Workspace.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include "Workspace.hpp"
|
||||
|
||||
CWorkspace::CWorkspace() { this->m_bHasFullscreenWindow = false; }
|
||||
CWorkspace::~CWorkspace() { }
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue