2021-11-18 18:04:09 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "defines.hpp"
|
|
|
|
#include "window.hpp"
|
|
|
|
|
|
|
|
#include <vector>
|
2021-11-21 11:25:26 +01:00
|
|
|
#include <thread>
|
|
|
|
#include <xcb/xcb.h>
|
2021-11-18 18:04:09 +01:00
|
|
|
|
2021-11-19 20:20:05 +01:00
|
|
|
#include "KeybindManager.hpp"
|
2021-11-21 11:25:26 +01:00
|
|
|
#include "utilities/Workspace.hpp"
|
|
|
|
#include "bar/Bar.hpp"
|
2021-11-21 12:40:03 +01:00
|
|
|
#include "config/ConfigManager.hpp"
|
2021-11-21 17:40:02 +01:00
|
|
|
#include "utilities/Monitor.hpp"
|
2021-11-21 18:34:20 +01:00
|
|
|
#include "utilities/Util.hpp"
|
2021-11-23 18:48:03 +01:00
|
|
|
#include "utilities/AnimationUtil.hpp"
|
2021-11-18 22:08:28 +01:00
|
|
|
|
2021-11-20 09:25:21 +01:00
|
|
|
class CWindowManager {
|
|
|
|
public:
|
|
|
|
xcb_connection_t* DisplayConnection;
|
|
|
|
xcb_screen_t* Screen;
|
|
|
|
xcb_drawable_t Drawable;
|
|
|
|
uint32_t Values[3];
|
2021-11-18 18:04:09 +01:00
|
|
|
|
2021-11-21 17:40:02 +01:00
|
|
|
std::vector<SMonitor> monitors;
|
|
|
|
|
2021-11-21 15:25:57 +01:00
|
|
|
bool modKeyDown = false;
|
2021-11-22 21:20:32 +01:00
|
|
|
int mouseKeyDown = 0;
|
|
|
|
Vector2D mouseLastPos = Vector2D(0, 0);
|
|
|
|
int64_t actingOnWindowFloating = 0;
|
2021-11-21 15:25:57 +01:00
|
|
|
|
2021-11-21 11:25:26 +01:00
|
|
|
uint8_t Depth = 32;
|
|
|
|
xcb_visualtype_t* VisualType;
|
|
|
|
|
2021-11-20 09:25:21 +01:00
|
|
|
std::vector<CWindow> windows; // windows never left. It has always been hiding amongst us.
|
|
|
|
xcb_drawable_t LastWindow = -1;
|
2021-11-18 18:04:09 +01:00
|
|
|
|
2021-11-20 10:04:14 +01:00
|
|
|
std::vector<CWorkspace> workspaces;
|
2021-11-21 19:59:59 +01:00
|
|
|
std::vector<int> activeWorkspaces;
|
2021-11-20 10:04:14 +01:00
|
|
|
|
2021-11-21 11:25:26 +01:00
|
|
|
CStatusBar statusBar;
|
2021-11-21 16:53:06 +01:00
|
|
|
std::thread* barThread;
|
2021-11-21 11:25:26 +01:00
|
|
|
|
2021-11-23 18:48:03 +01:00
|
|
|
std::atomic<bool> mainThreadBusy = false;
|
|
|
|
std::atomic<bool> animationUtilBusy = false;
|
|
|
|
|
2021-11-22 18:43:55 +01:00
|
|
|
CWindow* getWindowFromDrawable(int64_t);
|
2021-11-18 18:04:09 +01:00
|
|
|
void addWindowToVectorSafe(CWindow);
|
2021-11-23 17:41:30 +01:00
|
|
|
void removeWindowFromVectorSafe(int64_t);
|
2021-11-18 18:04:09 +01:00
|
|
|
|
|
|
|
void setupManager();
|
|
|
|
bool handleEvent();
|
|
|
|
void refreshDirtyWindows();
|
|
|
|
|
|
|
|
void setFocusedWindow(xcb_drawable_t);
|
|
|
|
|
|
|
|
void calculateNewWindowParams(CWindow*);
|
|
|
|
void fixWindowOnClose(CWindow*);
|
2021-11-19 22:29:44 +01:00
|
|
|
|
|
|
|
void moveActiveWindowTo(char);
|
2021-11-19 23:08:59 +01:00
|
|
|
void warpCursorTo(Vector2D);
|
2021-11-20 09:25:21 +01:00
|
|
|
|
2021-11-20 10:04:14 +01:00
|
|
|
void changeWorkspaceByID(int);
|
|
|
|
void setAllWorkspaceWindowsDirtyByID(int);
|
2021-11-21 11:25:26 +01:00
|
|
|
int getHighestWorkspaceID();
|
|
|
|
CWorkspace* getWorkspaceByID(int);
|
2021-11-21 20:21:58 +01:00
|
|
|
bool isWorkspaceVisible(int workspaceID);
|
2021-11-20 10:04:14 +01:00
|
|
|
|
2021-11-21 12:40:03 +01:00
|
|
|
void setAllWindowsDirty();
|
2021-11-23 17:43:27 +01:00
|
|
|
void setAllFloatingWindowsTop();
|
2021-11-21 12:40:03 +01:00
|
|
|
|
2021-11-21 17:40:02 +01:00
|
|
|
SMonitor* getMonitorFromWindow(CWindow*);
|
|
|
|
SMonitor* getMonitorFromCursor();
|
|
|
|
|
2021-11-22 21:20:32 +01:00
|
|
|
Vector2D getCursorPos();
|
|
|
|
|
2021-11-22 18:43:55 +01:00
|
|
|
// finds a window that's tiled at cursor.
|
|
|
|
CWindow* findWindowAtCursor();
|
|
|
|
|
2021-11-23 22:15:36 +01:00
|
|
|
bool shouldBeFloatedOnInit(int64_t);
|
|
|
|
|
2021-11-21 17:40:02 +01:00
|
|
|
private:
|
2021-11-20 09:25:21 +01:00
|
|
|
|
|
|
|
// Internal WM functions that don't have to be exposed
|
2021-11-20 10:04:14 +01:00
|
|
|
|
2021-11-21 17:40:02 +01:00
|
|
|
void setupRandrMonitors();
|
|
|
|
|
2021-11-20 09:25:21 +01:00
|
|
|
CWindow* getNeighborInDir(char dir);
|
|
|
|
void eatWindow(CWindow* a, CWindow* toEat);
|
|
|
|
bool canEatWindow(CWindow* a, CWindow* toEat);
|
|
|
|
bool isNeighbor(CWindow* a, CWindow* b);
|
|
|
|
void calculateNewTileSetOldTile(CWindow* pWindow);
|
2021-11-21 15:15:33 +01:00
|
|
|
void calculateNewFloatingWindow(CWindow* pWindow);
|
2021-11-20 09:25:21 +01:00
|
|
|
void setEffectiveSizePosUsingConfig(CWindow* pWindow);
|
2021-11-20 10:04:14 +01:00
|
|
|
void cleanupUnusedWorkspaces();
|
2021-11-21 11:25:26 +01:00
|
|
|
xcb_visualtype_t* setupColors();
|
2021-11-21 22:24:38 +01:00
|
|
|
void updateBarInfo();
|
2021-11-20 09:25:21 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-11-20 10:04:14 +01:00
|
|
|
inline std::unique_ptr<CWindowManager> g_pWindowManager = std::make_unique<CWindowManager>();
|