mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-25 22:35:58 +01:00
multiple small changes, bar better, fullscreen, updating
This commit is contained in:
parent
ca6a375e62
commit
c6cd584410
5 changed files with 66 additions and 32 deletions
|
@ -116,10 +116,7 @@ void KeybindManager::changeworkspace(std::string arg) {
|
||||||
MONITOR = g_pWindowManager->getMonitorFromCursor();
|
MONITOR = g_pWindowManager->getMonitorFromCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
g_pWindowManager->setAllWorkspaceWindowsDirtyByID(g_pWindowManager->activeWorkspaces[MONITOR->ID]);
|
|
||||||
g_pWindowManager->changeWorkspaceByID(ID);
|
g_pWindowManager->changeWorkspaceByID(ID);
|
||||||
g_pWindowManager->setAllWorkspaceWindowsDirtyByID(ID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,31 +132,33 @@ void CStatusBar::draw() {
|
||||||
if (WORKSPACE->getHasFullscreenWindow())
|
if (WORKSPACE->getHasFullscreenWindow())
|
||||||
return; // Do not draw a bar on a fullscreen window.
|
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}};
|
// TODO: CRIT! Status bar flashes, workspaces are wonky (wrong IDs?)
|
||||||
|
|
||||||
|
xcb_rectangle_t rectangles[] = {{(int)0, (int)0, (int)m_vecSize.x, (int)m_vecSize.y}};
|
||||||
xcb_poly_fill_rectangle(g_pWindowManager->DisplayConnection, m_iPixmap, m_mContexts["BG"].GContext, 1, rectangles);
|
xcb_poly_fill_rectangle(g_pWindowManager->DisplayConnection, m_iPixmap, m_mContexts["BG"].GContext, 1, rectangles);
|
||||||
|
|
||||||
// Draw workspaces
|
// Draw workspaces
|
||||||
int drawnWorkspaces = 0;
|
int drawnWorkspaces = 0;
|
||||||
for (int i = 0; i <= g_pWindowManager->getHighestWorkspaceID(); ++i) {
|
for (int i = 0; i < openWorkspaces.size(); ++i) {
|
||||||
|
|
||||||
const auto WORKSPACE = g_pWindowManager->getWorkspaceByID(i);
|
const auto WORKSPACE = openWorkspaces[i];
|
||||||
|
|
||||||
// The LastWindow may be on a different one. This is where the mouse is.
|
// The LastWindow may be on a different one. This is where the mouse is.
|
||||||
const auto MOUSEWORKSPACEID = g_pWindowManager->activeWorkspaces[g_pWindowManager->getMonitorFromCursor()->ID];
|
const auto MOUSEWORKSPACEID = m_iCurrentWorkspace;
|
||||||
|
|
||||||
if (!WORKSPACE)
|
if (!WORKSPACE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string workspaceName = std::to_string(i);
|
std::string workspaceName = std::to_string(openWorkspaces[i]);
|
||||||
|
|
||||||
if (WORKSPACE->getID() == MOUSEWORKSPACEID) {
|
if (WORKSPACE == MOUSEWORKSPACEID) {
|
||||||
xcb_rectangle_t rectangleActive[] = { { m_vecSize.y * drawnWorkspaces, 0, m_vecSize.y, m_vecSize.y } };
|
xcb_rectangle_t rectangleActive[] = { { m_vecSize.y * drawnWorkspaces, 0, m_vecSize.y, m_vecSize.y } };
|
||||||
xcb_poly_fill_rectangle(g_pWindowManager->DisplayConnection, m_iPixmap, m_mContexts["MEDBG"].GContext, 1, rectangleActive);
|
xcb_poly_fill_rectangle(g_pWindowManager->DisplayConnection, m_iPixmap, m_mContexts["MEDBG"].GContext, 1, rectangleActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_image_text_8(g_pWindowManager->DisplayConnection, workspaceName.length(), m_iPixmap,
|
xcb_image_text_8(g_pWindowManager->DisplayConnection, workspaceName.length(), m_iPixmap,
|
||||||
WORKSPACE->getID() == MOUSEWORKSPACEID ? m_mContexts["HITEXT"].GContext : m_mContexts["BASETEXT"].GContext,
|
WORKSPACE == MOUSEWORKSPACEID ? m_mContexts["HITEXT"].GContext : m_mContexts["BASETEXT"].GContext,
|
||||||
m_vecSize.y * drawnWorkspaces + m_vecSize.y / 2.f - 2, m_vecSize.y - (m_vecSize.y - 10) / 2, workspaceName.c_str());
|
m_vecSize.y * drawnWorkspaces + m_vecSize.y / 2.f - (WORKSPACE > 9 ? 4 : 2), m_vecSize.y - (m_vecSize.y - 10) / 2, workspaceName.c_str());
|
||||||
|
|
||||||
drawnWorkspaces++;
|
drawnWorkspaces++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ public:
|
||||||
void setup(int MonitorID);
|
void setup(int MonitorID);
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
|
std::vector<int> openWorkspaces;
|
||||||
|
EXPOSED_MEMBER(CurrentWorkspace, int, i);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector2D m_vecSize;
|
Vector2D m_vecSize;
|
||||||
Vector2D m_vecPosition;
|
Vector2D m_vecPosition;
|
||||||
|
|
|
@ -147,6 +147,9 @@ void CWindowManager::setupManager() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update bar info
|
||||||
|
updateBarInfo();
|
||||||
|
|
||||||
// start its' update thread
|
// start its' update thread
|
||||||
Events::setThread();
|
Events::setThread();
|
||||||
|
|
||||||
|
@ -267,6 +270,9 @@ void CWindowManager::cleanupUnusedWorkspaces() {
|
||||||
workspaces.push_back(work);
|
workspaces.push_back(work);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update bar info
|
||||||
|
updateBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::refreshDirtyWindows() {
|
void CWindowManager::refreshDirtyWindows() {
|
||||||
|
@ -303,12 +309,14 @@ void CWindowManager::refreshDirtyWindows() {
|
||||||
Values[0] = 0x555555; // GRAY :)
|
Values[0] = 0x555555; // GRAY :)
|
||||||
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
||||||
|
|
||||||
Values[0] = (int)Screen->width_in_pixels;
|
const auto MONITOR = getMonitorFromWindow(&window);
|
||||||
Values[1] = (int)Screen->height_in_pixels;
|
|
||||||
|
Values[0] = (int)MONITOR->vecSize.x;
|
||||||
|
Values[1] = (int)MONITOR->vecSize.y;
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
||||||
|
|
||||||
Values[0] = (int)0;
|
Values[0] = (int)MONITOR->vecPosition.x;
|
||||||
Values[1] = (int)0;
|
Values[1] = (int)MONITOR->vecPosition.y;
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -318,8 +326,10 @@ void CWindowManager::refreshDirtyWindows() {
|
||||||
Values[1] = (int)window.getEffectiveSize().y;
|
Values[1] = (int)window.getEffectiveSize().y;
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
||||||
|
|
||||||
Values[0] = (int)window.getEffectivePosition().x;
|
// Update the position because the border makes the window jump
|
||||||
Values[1] = (int)window.getEffectivePosition().y;
|
// I have added the bordersize vec2d before in the setEffectiveSizePosUsingConfig function.
|
||||||
|
Values[0] = (int)window.getEffectivePosition().x - ConfigManager::getInt("border_size");
|
||||||
|
Values[1] = (int)window.getEffectivePosition().y - ConfigManager::getInt("border_size");
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
||||||
|
|
||||||
// Focused special border.
|
// Focused special border.
|
||||||
|
@ -327,19 +337,11 @@ void CWindowManager::refreshDirtyWindows() {
|
||||||
Values[0] = (int)ConfigManager::getInt("border_size");
|
Values[0] = (int)ConfigManager::getInt("border_size");
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_BORDER_WIDTH, Values);
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_BORDER_WIDTH, Values);
|
||||||
|
|
||||||
// Update the position because the border makes the window jump
|
|
||||||
// I have added the bordersize vec2d before in the setEffectiveSizePosUsingConfig function.
|
|
||||||
Values[0] = (int)window.getEffectivePosition().x - ConfigManager::getInt("border_size");
|
|
||||||
Values[1] = (int)window.getEffectivePosition().y - ConfigManager::getInt("border_size");
|
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
|
||||||
|
|
||||||
Values[0] = 0xFF3333; // RED :)
|
Values[0] = 0xFF3333; // RED :)
|
||||||
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
||||||
} else {
|
} else {
|
||||||
Values[0] = 0;
|
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_BORDER_WIDTH, Values);
|
|
||||||
|
|
||||||
Values[0] = 0x555555; // GRAY :)
|
Values[0] = 0x222222; // GRAY :)
|
||||||
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,8 +357,11 @@ void CWindowManager::setFocusedWindow(xcb_drawable_t window) {
|
||||||
xcb_set_input_focus(DisplayConnection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
|
xcb_set_input_focus(DisplayConnection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
|
||||||
|
|
||||||
// Fix border from the old window that was in focus.
|
// Fix border from the old window that was in focus.
|
||||||
if (const auto PLASTWINDOW = getWindowFromDrawable(LastWindow); PLASTWINDOW)
|
Values[0] = 0x555555; // GRAY :)
|
||||||
PLASTWINDOW->setDirty(true);
|
xcb_change_window_attributes(DisplayConnection, LastWindow, XCB_CW_BORDER_PIXEL, Values);
|
||||||
|
|
||||||
|
Values[0] = 0xFF3333; // RED :)
|
||||||
|
xcb_change_window_attributes(DisplayConnection, window, XCB_CW_BORDER_PIXEL, Values);
|
||||||
|
|
||||||
LastWindow = window;
|
LastWindow = window;
|
||||||
}
|
}
|
||||||
|
@ -412,10 +417,12 @@ void CWindowManager::setEffectiveSizePosUsingConfig(CWindow* pWindow) {
|
||||||
pWindow->setEffectivePosition(pWindow->getPosition() + Vector2D(ConfigManager::getInt("border_size"), ConfigManager::getInt("border_size")));
|
pWindow->setEffectivePosition(pWindow->getPosition() + Vector2D(ConfigManager::getInt("border_size"), ConfigManager::getInt("border_size")));
|
||||||
pWindow->setEffectiveSize(pWindow->getSize() - (Vector2D(ConfigManager::getInt("border_size"), ConfigManager::getInt("border_size")) * 2));
|
pWindow->setEffectiveSize(pWindow->getSize() - (Vector2D(ConfigManager::getInt("border_size"), ConfigManager::getInt("border_size")) * 2));
|
||||||
|
|
||||||
|
//TODO: make windows with no bar taller, this aint working chief
|
||||||
|
|
||||||
// do gaps, set top left
|
// do gaps, set top left
|
||||||
pWindow->setEffectivePosition(pWindow->getEffectivePosition() + Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYTOP ? ConfigManager::getInt("gaps_out") + ConfigManager::getInt("bar_height") : ConfigManager::getInt("gaps_in")));
|
pWindow->setEffectivePosition(pWindow->getEffectivePosition() + Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYTOP ? ConfigManager::getInt("gaps_out") + (MONITOR->ID != statusBar.getMonitorID() ? ConfigManager::getInt("bar_height") : 0) : ConfigManager::getInt("gaps_in")));
|
||||||
// fix to old size bottom right
|
// fix to old size bottom right
|
||||||
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYTOP ? ConfigManager::getInt("gaps_out") + ConfigManager::getInt("bar_height") : ConfigManager::getInt("gaps_in")));
|
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - Vector2D(DISPLAYLEFT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYTOP ? ConfigManager::getInt("gaps_out") + (MONITOR->ID != statusBar.getMonitorID() ? ConfigManager::getInt("bar_height") : 0) : ConfigManager::getInt("gaps_in")));
|
||||||
// set bottom right
|
// set bottom right
|
||||||
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - Vector2D(DISPLAYRIGHT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYBOTTOM ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in")));
|
pWindow->setEffectiveSize(pWindow->getEffectiveSize() - Vector2D(DISPLAYRIGHT ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in"), DISPLAYBOTTOM ? ConfigManager::getInt("gaps_out") : ConfigManager::getInt("gaps_in")));
|
||||||
}
|
}
|
||||||
|
@ -700,8 +707,10 @@ void CWindowManager::moveActiveWindowTo(char dir) {
|
||||||
|
|
||||||
void CWindowManager::changeWorkspaceByID(int ID) {
|
void CWindowManager::changeWorkspaceByID(int ID) {
|
||||||
|
|
||||||
const auto MONITOR = g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow)
|
const auto MONITOR = getMonitorFromCursor();
|
||||||
? g_pWindowManager->getMonitorFromWindow(g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow)) : getMonitorFromCursor();
|
|
||||||
|
// mark old workspace dirty
|
||||||
|
setAllWorkspaceWindowsDirtyByID(activeWorkspaces[MONITOR->ID]);
|
||||||
|
|
||||||
for (auto& workspace : workspaces) {
|
for (auto& workspace : workspaces) {
|
||||||
if (workspace.getID() == ID) {
|
if (workspace.getID() == ID) {
|
||||||
|
@ -711,6 +720,12 @@ void CWindowManager::changeWorkspaceByID(int ID) {
|
||||||
// Perform a sanity check for the new workspace
|
// Perform a sanity check for the new workspace
|
||||||
performSanityCheckForWorkspace(ID);
|
performSanityCheckForWorkspace(ID);
|
||||||
|
|
||||||
|
// Update bar info
|
||||||
|
updateBarInfo();
|
||||||
|
|
||||||
|
// mark new as dirty
|
||||||
|
setAllWorkspaceWindowsDirtyByID(activeWorkspaces[MONITOR->ID]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -725,6 +740,11 @@ void CWindowManager::changeWorkspaceByID(int ID) {
|
||||||
|
|
||||||
// Perform a sanity check for the new workspace
|
// Perform a sanity check for the new workspace
|
||||||
performSanityCheckForWorkspace(ID);
|
performSanityCheckForWorkspace(ID);
|
||||||
|
|
||||||
|
// Update bar info
|
||||||
|
updateBarInfo();
|
||||||
|
|
||||||
|
// no need for the new dirty, it's empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::setAllWindowsDirty() {
|
void CWindowManager::setAllWindowsDirty() {
|
||||||
|
@ -806,3 +826,14 @@ bool CWindowManager::isWorkspaceVisible(int workspaceID) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWindowManager::updateBarInfo() {
|
||||||
|
statusBar.openWorkspaces.clear();
|
||||||
|
for (auto& workspace : workspaces) {
|
||||||
|
statusBar.openWorkspaces.push_back(workspace.getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(statusBar.openWorkspaces.begin(), statusBar.openWorkspaces.end());
|
||||||
|
|
||||||
|
statusBar.setCurrentWorkspace(activeWorkspaces[getMonitorFromCursor()->ID]);
|
||||||
|
}
|
|
@ -81,6 +81,7 @@ public:
|
||||||
void setEffectiveSizePosUsingConfig(CWindow* pWindow);
|
void setEffectiveSizePosUsingConfig(CWindow* pWindow);
|
||||||
void cleanupUnusedWorkspaces();
|
void cleanupUnusedWorkspaces();
|
||||||
xcb_visualtype_t* setupColors();
|
xcb_visualtype_t* setupColors();
|
||||||
|
void updateBarInfo();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue