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-12-22 20:40:24 +01:00
|
|
|
#include <deque>
|
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"
|
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-24 18:37:45 +01:00
|
|
|
#include "utilities/XCBProps.hpp"
|
2021-11-24 21:23:14 +01:00
|
|
|
#include "ewmh/ewmh.hpp"
|
2021-11-27 13:28:30 +01:00
|
|
|
#include "bar/Bar.hpp"
|
2021-12-06 18:56:24 +01:00
|
|
|
#include "utilities/Tray.hpp"
|
2021-11-27 13:28:30 +01:00
|
|
|
|
|
|
|
#include "ipc/ipc.hpp"
|
2021-11-18 22:08:28 +01:00
|
|
|
|
2021-11-20 09:25:21 +01:00
|
|
|
class CWindowManager {
|
|
|
|
public:
|
2021-11-29 21:17:06 +01:00
|
|
|
xcb_connection_t* DisplayConnection = nullptr;
|
|
|
|
xcb_ewmh_connection_t* EWMHConnection = nullptr; // Bar uses this
|
|
|
|
xcb_screen_t* Screen = nullptr;
|
2021-11-20 09:25:21 +01:00
|
|
|
xcb_drawable_t Drawable;
|
2021-12-22 14:53:53 +01:00
|
|
|
int RandREventBase = -1;
|
2021-11-20 09:25:21 +01:00
|
|
|
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-29 21:51:01 +01:00
|
|
|
xcb_colormap_t Colormap;
|
2021-11-21 11:25:26 +01:00
|
|
|
|
2021-12-22 20:40:24 +01:00
|
|
|
std::deque<CWindow> windows; // windows never left. It has always been hiding amongst us.
|
|
|
|
std::deque<CWindow> unmappedWindows;
|
2021-11-20 09:25:21 +01:00
|
|
|
xcb_drawable_t LastWindow = -1;
|
2021-11-18 18:04:09 +01:00
|
|
|
|
2021-12-22 20:40:24 +01:00
|
|
|
std::deque<CWorkspace> workspaces;
|
|
|
|
std::deque<int> activeWorkspaces;
|
2021-11-20 10:04:14 +01:00
|
|
|
|
2021-11-27 13:28:30 +01:00
|
|
|
// Pipes
|
|
|
|
SIPCPipe m_sIPCBarPipeIn = {ISDEBUG ? "/tmp/hypr/hyprbarind" : "/tmp/hypr/hyprbarin", 0};
|
|
|
|
SIPCPipe m_sIPCBarPipeOut = {ISDEBUG ? "/tmp/hypr/hyprbaroutd" : "/tmp/hypr/hyprbarout", 0};
|
|
|
|
CStatusBar* statusBar = nullptr;
|
2021-11-28 13:04:07 +01:00
|
|
|
Vector2D lastKnownBarPosition = {-1,-1};
|
2021-11-27 13:28:30 +01:00
|
|
|
uint64_t barWindowID = 0;
|
|
|
|
GThread* barThread; /* Well right now anything but the bar but lol */
|
2021-12-06 18:56:24 +01:00
|
|
|
|
2021-12-22 20:40:24 +01:00
|
|
|
std::deque<CTrayClient> trayclients;
|
2021-11-21 11:25:26 +01:00
|
|
|
|
2021-12-17 23:27:27 +01:00
|
|
|
bool mainThreadBusy = false;
|
|
|
|
bool animationUtilBusy = false;
|
2021-11-23 18:48:03 +01:00
|
|
|
|
2021-11-25 17:57:50 +01:00
|
|
|
xcb_cursor_t pointerCursor;
|
|
|
|
xcb_cursor_context_t* pointerContext;
|
|
|
|
|
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();
|
2021-12-06 18:56:24 +01:00
|
|
|
void recieveEvent();
|
2021-11-18 18:04:09 +01:00
|
|
|
void refreshDirtyWindows();
|
|
|
|
|
|
|
|
void setFocusedWindow(xcb_drawable_t);
|
2021-12-02 15:08:19 +01:00
|
|
|
void refocusWindowOnClosed();
|
2021-11-18 18:04:09 +01:00
|
|
|
|
|
|
|
void calculateNewWindowParams(CWindow*);
|
|
|
|
void fixWindowOnClose(CWindow*);
|
2021-11-24 21:50:44 +01:00
|
|
|
void closeWindowAllChecks(int64_t);
|
2021-11-19 22:29:44 +01:00
|
|
|
|
|
|
|
void moveActiveWindowTo(char);
|
2021-12-05 12:05:44 +01:00
|
|
|
void moveActiveFocusTo(char);
|
2021-11-25 17:44:46 +01:00
|
|
|
void moveActiveWindowToWorkspace(int);
|
2021-11-19 23:08:59 +01:00
|
|
|
void warpCursorTo(Vector2D);
|
2021-12-17 19:57:07 +01:00
|
|
|
void toggleWindowFullscrenn(const int&);
|
2021-12-17 20:58:32 +01:00
|
|
|
void recalcAllDocks();
|
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-12-06 19:43:01 +01:00
|
|
|
void setAWindowTop(xcb_window_t);
|
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-12-21 18:30:35 +01:00
|
|
|
CWindow* findFirstWindowOnWorkspace(const int&);
|
|
|
|
|
2021-11-23 22:15:36 +01:00
|
|
|
bool shouldBeFloatedOnInit(int64_t);
|
2021-11-28 11:52:40 +01:00
|
|
|
void doPostCreationChecks(CWindow*);
|
2021-11-30 16:43:28 +01:00
|
|
|
void getICCCMWMProtocols(CWindow*);
|
2021-11-23 22:15:36 +01:00
|
|
|
|
2021-11-27 13:28:30 +01:00
|
|
|
void setupRandrMonitors();
|
|
|
|
void createAndOpenAllPipes();
|
|
|
|
void setupDepth();
|
2021-11-29 21:51:01 +01:00
|
|
|
void setupColormapAndStuff();
|
2021-11-27 13:28:30 +01:00
|
|
|
|
2021-11-27 19:07:33 +01:00
|
|
|
void updateActiveWindowName();
|
|
|
|
void updateBarInfo();
|
|
|
|
|
2021-12-04 23:16:24 +01:00
|
|
|
int getWindowsOnWorkspace(const int&);
|
|
|
|
|
|
|
|
void recalcAllWorkspaces();
|
|
|
|
|
2021-12-11 12:54:45 +01:00
|
|
|
void moveWindowToUnmapped(int64_t);
|
|
|
|
void moveWindowToMapped(int64_t);
|
|
|
|
bool isWindowUnmapped(int64_t);
|
|
|
|
|
2021-12-11 14:50:29 +01:00
|
|
|
void setAllWorkspaceWindowsAboveFullscreen(const int&);
|
|
|
|
void setAllWorkspaceWindowsUnderFullscreen(const int&);
|
|
|
|
|
2021-12-17 19:57:07 +01:00
|
|
|
void handleClientMessage(xcb_client_message_event_t*);
|
|
|
|
|
2021-12-06 18:56:24 +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-24 18:51:34 +01:00
|
|
|
void sanityCheckOnWorkspace(int);
|
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-29 21:51:01 +01:00
|
|
|
xcb_visualtype_t* setupColors(const int&);
|
2021-11-25 17:57:50 +01:00
|
|
|
void updateRootCursor();
|
2021-12-06 19:43:01 +01:00
|
|
|
void applyShapeToWindow(CWindow* pWindow);
|
2021-12-04 23:16:24 +01:00
|
|
|
SMonitor* getMonitorFromWorkspace(const int&);
|
|
|
|
void recalcEntireWorkspace(const int&);
|
|
|
|
void fixMasterWorkspaceOnClosed(CWindow* pWindow);
|
2021-12-12 13:40:13 +01:00
|
|
|
CWindow* getFullscreenWindowByWorkspace(const int&);
|
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>();
|
2021-11-24 18:37:45 +01:00
|
|
|
|
2021-11-29 21:17:06 +01:00
|
|
|
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {
|
2021-11-24 18:37:45 +01:00
|
|
|
HYPRATOM("_NET_SUPPORTED"),
|
|
|
|
HYPRATOM("_NET_SUPPORTING_WM_CHECK"),
|
|
|
|
HYPRATOM("_NET_WM_NAME"),
|
|
|
|
HYPRATOM("_NET_WM_VISIBLE_NAME"),
|
|
|
|
HYPRATOM("_NET_WM_MOVERESIZE"),
|
|
|
|
HYPRATOM("_NET_WM_STATE_STICKY"),
|
|
|
|
HYPRATOM("_NET_WM_STATE_FULLSCREEN"),
|
|
|
|
HYPRATOM("_NET_WM_STATE_DEMANDS_ATTENTION"),
|
|
|
|
HYPRATOM("_NET_WM_STATE_MODAL"),
|
|
|
|
HYPRATOM("_NET_WM_STATE_HIDDEN"),
|
|
|
|
HYPRATOM("_NET_WM_STATE_FOCUSED"),
|
|
|
|
HYPRATOM("_NET_WM_STATE"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION"),
|
|
|
|
HYPRATOM("_NET_WM_DESKTOP"),
|
|
|
|
HYPRATOM("_NET_WM_STRUT_PARTIAL"),
|
|
|
|
HYPRATOM("_NET_CLIENT_LIST"),
|
|
|
|
HYPRATOM("_NET_CLIENT_LIST_STACKING"),
|
|
|
|
HYPRATOM("_NET_CURRENT_DESKTOP"),
|
|
|
|
HYPRATOM("_NET_NUMBER_OF_DESKTOPS"),
|
|
|
|
HYPRATOM("_NET_DESKTOP_NAMES"),
|
|
|
|
HYPRATOM("_NET_DESKTOP_VIEWPORT"),
|
|
|
|
HYPRATOM("_NET_ACTIVE_WINDOW"),
|
|
|
|
HYPRATOM("_NET_CLOSE_WINDOW"),
|
|
|
|
HYPRATOM("_NET_MOVERESIZE_WINDOW"),
|
|
|
|
HYPRATOM("_NET_WM_USER_TIME"),
|
|
|
|
HYPRATOM("_NET_STARTUP_ID"),
|
|
|
|
HYPRATOM("_NET_WORKAREA"),
|
|
|
|
HYPRATOM("_NET_WM_ICON"),
|
|
|
|
HYPRATOM("WM_PROTOCOLS"),
|
|
|
|
HYPRATOM("WM_DELETE_WINDOW"),
|
|
|
|
HYPRATOM("UTF8_STRING"),
|
|
|
|
HYPRATOM("WM_STATE"),
|
|
|
|
HYPRATOM("WM_CLIENT_LEADER"),
|
|
|
|
HYPRATOM("WM_TAKE_FOCUS"),
|
|
|
|
HYPRATOM("WM_WINDOW_ROLE"),
|
|
|
|
HYPRATOM("_NET_REQUEST_FRAME_EXTENTS"),
|
|
|
|
HYPRATOM("_NET_FRAME_EXTENTS"),
|
|
|
|
HYPRATOM("_MOTIF_WM_HINTS"),
|
|
|
|
HYPRATOM("WM_CHANGE_STATE"),
|
2021-12-06 18:56:24 +01:00
|
|
|
HYPRATOM("_NET_SYSTEM_TRAY_OPCODE"),
|
|
|
|
HYPRATOM("_NET_SYSTEM_TRAY_COLORS"),
|
|
|
|
HYPRATOM("_NET_SYSTEM_TRAY_VISUAL"),
|
|
|
|
HYPRATOM("_NET_SYSTEM_TRAY_ORIENTATION"),
|
|
|
|
HYPRATOM("_XEMBED_INFO"),
|
2021-11-29 21:17:06 +01:00
|
|
|
HYPRATOM("MANAGER")};
|