mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 21:35:58 +01:00
Bar now fully works with transparency.
This commit is contained in:
parent
da0029d45c
commit
1a05147c92
4 changed files with 41 additions and 22 deletions
|
@ -32,5 +32,6 @@ target_link_libraries(Hypr
|
||||||
xcb-xinerama
|
xcb-xinerama
|
||||||
xcb-cursor
|
xcb-cursor
|
||||||
xcb-shape
|
xcb-shape
|
||||||
|
xcb-util
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
|
@ -59,7 +59,7 @@ int64_t barMainThread() {
|
||||||
g_pWindowManager->setupRandrMonitors();
|
g_pWindowManager->setupRandrMonitors();
|
||||||
|
|
||||||
// Init depth
|
// Init depth
|
||||||
g_pWindowManager->setupDepth();
|
g_pWindowManager->setupColormapAndStuff();
|
||||||
|
|
||||||
// Setup our bar
|
// Setup our bar
|
||||||
CStatusBar STATUSBAR;
|
CStatusBar STATUSBAR;
|
||||||
|
@ -154,12 +154,15 @@ void CStatusBar::setup(int MonitorID) {
|
||||||
message.windowID = m_iWindowID;
|
message.windowID = m_iWindowID;
|
||||||
IPCSendMessage(g_pWindowManager->m_sIPCBarPipeOut.szPipeName, message);
|
IPCSendMessage(g_pWindowManager->m_sIPCBarPipeOut.szPipeName, message);
|
||||||
|
|
||||||
values[0] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE;
|
values[0] = ConfigManager::getInt("bar:col.bg");
|
||||||
|
values[1] = ConfigManager::getInt("bar:col.bg");
|
||||||
|
values[2] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE;
|
||||||
|
values[3] = g_pWindowManager->Colormap;
|
||||||
|
|
||||||
xcb_create_window(g_pWindowManager->DisplayConnection, g_pWindowManager->Depth, m_iWindowID,
|
xcb_create_window(g_pWindowManager->DisplayConnection, g_pWindowManager->Depth, m_iWindowID,
|
||||||
g_pWindowManager->Screen->root, m_vecPosition.x, m_vecPosition.y, m_vecSize.x, m_vecSize.y,
|
g_pWindowManager->Screen->root, m_vecPosition.x, m_vecPosition.y, m_vecSize.x, m_vecSize.y,
|
||||||
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, g_pWindowManager->Screen->root_visual,
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, g_pWindowManager->VisualType->visual_id,
|
||||||
XCB_CW_EVENT_MASK, values);
|
XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP, values);
|
||||||
|
|
||||||
// Set the state to dock to avoid some issues
|
// Set the state to dock to avoid some issues
|
||||||
xcb_atom_t dockAtom[] = { HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] };
|
xcb_atom_t dockAtom[] = { HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] };
|
||||||
|
|
|
@ -2,28 +2,26 @@
|
||||||
#include "./events/events.hpp"
|
#include "./events/events.hpp"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
xcb_visualtype_t* CWindowManager::setupColors() {
|
xcb_visualtype_t* CWindowManager::setupColors(const int& desiredDepth) {
|
||||||
auto depthIter = xcb_screen_allowed_depths_iterator(Screen);
|
auto depthIter = xcb_screen_allowed_depths_iterator(Screen);
|
||||||
xcb_visualtype_iterator_t visualIter;
|
if (depthIter.data) {
|
||||||
for (; depthIter.rem; xcb_depth_next(&depthIter)) {
|
for (; depthIter.rem; xcb_depth_next(&depthIter)) {
|
||||||
if (depthIter.data->depth == Depth) {
|
if (desiredDepth == 0 || desiredDepth == depthIter.data->depth) {
|
||||||
visualIter = xcb_depth_visuals_iterator(depthIter.data);
|
for (auto it = xcb_depth_visuals_iterator(depthIter.data); it.rem; xcb_visualtype_next(&it)) {
|
||||||
return visualIter.data;
|
return it.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (desiredDepth > 0) {
|
||||||
|
return setupColors(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::setupDepth() {
|
void CWindowManager::setupDepth() {
|
||||||
// init visual type, default 32 bit depth
|
Depth = 24;
|
||||||
// TODO: fix this, ugh
|
VisualType = setupColors(Depth);
|
||||||
Depth = 24; //32
|
|
||||||
VisualType = setupColors();
|
|
||||||
if (VisualType == NULL) {
|
|
||||||
Depth = 24;
|
|
||||||
VisualType = setupColors();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::createAndOpenAllPipes() {
|
void CWindowManager::createAndOpenAllPipes() {
|
||||||
|
@ -49,6 +47,22 @@ void CWindowManager::updateRootCursor() {
|
||||||
xcb_change_window_attributes(DisplayConnection, Screen->root, XCB_CW_CURSOR, values);
|
xcb_change_window_attributes(DisplayConnection, Screen->root, XCB_CW_CURSOR, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWindowManager::setupColormapAndStuff() {
|
||||||
|
VisualType = xcb_aux_find_visual_by_attrs(Screen, -1, 32); // Transparency by default
|
||||||
|
|
||||||
|
Depth = xcb_aux_get_depth_of_visual(Screen, VisualType->visual_id);
|
||||||
|
Colormap = xcb_generate_id(DisplayConnection);
|
||||||
|
const auto COOKIE = xcb_create_colormap(DisplayConnection, XCB_COLORMAP_ALLOC_NONE, Colormap, Screen->root, VisualType->visual_id);
|
||||||
|
|
||||||
|
const auto XERR = xcb_request_check(DisplayConnection, COOKIE);
|
||||||
|
|
||||||
|
if (XERR != NULL) {
|
||||||
|
Debug::log(ERR, "Error in setupColormapAndStuff! Code: " + std::to_string(XERR->error_code));
|
||||||
|
}
|
||||||
|
|
||||||
|
free(XERR);
|
||||||
|
}
|
||||||
|
|
||||||
void CWindowManager::setupRandrMonitors() {
|
void CWindowManager::setupRandrMonitors() {
|
||||||
|
|
||||||
XCBQUERYCHECK(RANDRVER, xcb_randr_query_version_reply(
|
XCBQUERYCHECK(RANDRVER, xcb_randr_query_version_reply(
|
||||||
|
@ -136,6 +150,7 @@ void CWindowManager::setupRandrMonitors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::setupManager() {
|
void CWindowManager::setupManager() {
|
||||||
|
setupColormapAndStuff();
|
||||||
EWMH::setupInitEWMH();
|
EWMH::setupInitEWMH();
|
||||||
setupRandrMonitors();
|
setupRandrMonitors();
|
||||||
|
|
||||||
|
@ -162,8 +177,6 @@ void CWindowManager::setupManager() {
|
||||||
Debug::log(LOG, "Workspace protos done.");
|
Debug::log(LOG, "Workspace protos done.");
|
||||||
//
|
//
|
||||||
|
|
||||||
setupDepth();
|
|
||||||
|
|
||||||
// ---- INIT THE THREAD FOR ANIM & CONFIG ---- //
|
// ---- INIT THE THREAD FOR ANIM & CONFIG ---- //
|
||||||
|
|
||||||
// start its' update thread
|
// start its' update thread
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
|
|
||||||
uint8_t Depth = 32;
|
uint8_t Depth = 32;
|
||||||
xcb_visualtype_t* VisualType;
|
xcb_visualtype_t* VisualType;
|
||||||
|
xcb_colormap_t Colormap;
|
||||||
|
|
||||||
std::vector<CWindow> windows; // windows never left. It has always been hiding amongst us.
|
std::vector<CWindow> windows; // windows never left. It has always been hiding amongst us.
|
||||||
xcb_drawable_t LastWindow = -1;
|
xcb_drawable_t LastWindow = -1;
|
||||||
|
@ -98,6 +99,7 @@ public:
|
||||||
void setupRandrMonitors();
|
void setupRandrMonitors();
|
||||||
void createAndOpenAllPipes();
|
void createAndOpenAllPipes();
|
||||||
void setupDepth();
|
void setupDepth();
|
||||||
|
void setupColormapAndStuff();
|
||||||
|
|
||||||
void updateActiveWindowName();
|
void updateActiveWindowName();
|
||||||
void updateBarInfo();
|
void updateBarInfo();
|
||||||
|
@ -115,7 +117,7 @@ public:
|
||||||
void calculateNewFloatingWindow(CWindow* pWindow);
|
void calculateNewFloatingWindow(CWindow* pWindow);
|
||||||
void setEffectiveSizePosUsingConfig(CWindow* pWindow);
|
void setEffectiveSizePosUsingConfig(CWindow* pWindow);
|
||||||
void cleanupUnusedWorkspaces();
|
void cleanupUnusedWorkspaces();
|
||||||
xcb_visualtype_t* setupColors();
|
xcb_visualtype_t* setupColors(const int&);
|
||||||
void updateRootCursor();
|
void updateRootCursor();
|
||||||
void applyRoundedCornersToWindow(CWindow* pWindow);
|
void applyRoundedCornersToWindow(CWindow* pWindow);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue