mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-07 16:35:59 +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-cursor
|
||||
xcb-shape
|
||||
xcb-util
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
|
@ -59,7 +59,7 @@ int64_t barMainThread() {
|
|||
g_pWindowManager->setupRandrMonitors();
|
||||
|
||||
// Init depth
|
||||
g_pWindowManager->setupDepth();
|
||||
g_pWindowManager->setupColormapAndStuff();
|
||||
|
||||
// Setup our bar
|
||||
CStatusBar STATUSBAR;
|
||||
|
@ -154,12 +154,15 @@ void CStatusBar::setup(int MonitorID) {
|
|||
message.windowID = m_iWindowID;
|
||||
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,
|
||||
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,
|
||||
XCB_CW_EVENT_MASK, values);
|
||||
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, g_pWindowManager->VisualType->visual_id,
|
||||
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
|
||||
xcb_atom_t dockAtom[] = { HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] };
|
||||
|
|
|
@ -2,28 +2,26 @@
|
|||
#include "./events/events.hpp"
|
||||
#include <string.h>
|
||||
|
||||
xcb_visualtype_t* CWindowManager::setupColors() {
|
||||
xcb_visualtype_t* CWindowManager::setupColors(const int& desiredDepth) {
|
||||
auto depthIter = xcb_screen_allowed_depths_iterator(Screen);
|
||||
xcb_visualtype_iterator_t visualIter;
|
||||
for (; depthIter.rem; xcb_depth_next(&depthIter)) {
|
||||
if (depthIter.data->depth == Depth) {
|
||||
visualIter = xcb_depth_visuals_iterator(depthIter.data);
|
||||
return visualIter.data;
|
||||
if (depthIter.data) {
|
||||
for (; depthIter.rem; xcb_depth_next(&depthIter)) {
|
||||
if (desiredDepth == 0 || desiredDepth == depthIter.data->depth) {
|
||||
for (auto it = xcb_depth_visuals_iterator(depthIter.data); it.rem; xcb_visualtype_next(&it)) {
|
||||
return it.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (desiredDepth > 0) {
|
||||
return setupColors(0);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CWindowManager::setupDepth() {
|
||||
// init visual type, default 32 bit depth
|
||||
// TODO: fix this, ugh
|
||||
Depth = 24; //32
|
||||
VisualType = setupColors();
|
||||
if (VisualType == NULL) {
|
||||
Depth = 24;
|
||||
VisualType = setupColors();
|
||||
}
|
||||
Depth = 24;
|
||||
VisualType = setupColors(Depth);
|
||||
}
|
||||
|
||||
void CWindowManager::createAndOpenAllPipes() {
|
||||
|
@ -49,6 +47,22 @@ void CWindowManager::updateRootCursor() {
|
|||
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() {
|
||||
|
||||
XCBQUERYCHECK(RANDRVER, xcb_randr_query_version_reply(
|
||||
|
@ -136,6 +150,7 @@ void CWindowManager::setupRandrMonitors() {
|
|||
}
|
||||
|
||||
void CWindowManager::setupManager() {
|
||||
setupColormapAndStuff();
|
||||
EWMH::setupInitEWMH();
|
||||
setupRandrMonitors();
|
||||
|
||||
|
@ -162,8 +177,6 @@ void CWindowManager::setupManager() {
|
|||
Debug::log(LOG, "Workspace protos done.");
|
||||
//
|
||||
|
||||
setupDepth();
|
||||
|
||||
// ---- INIT THE THREAD FOR ANIM & CONFIG ---- //
|
||||
|
||||
// start its' update thread
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
uint8_t Depth = 32;
|
||||
xcb_visualtype_t* VisualType;
|
||||
xcb_colormap_t Colormap;
|
||||
|
||||
std::vector<CWindow> windows; // windows never left. It has always been hiding amongst us.
|
||||
xcb_drawable_t LastWindow = -1;
|
||||
|
@ -98,6 +99,7 @@ public:
|
|||
void setupRandrMonitors();
|
||||
void createAndOpenAllPipes();
|
||||
void setupDepth();
|
||||
void setupColormapAndStuff();
|
||||
|
||||
void updateActiveWindowName();
|
||||
void updateBarInfo();
|
||||
|
@ -115,7 +117,7 @@ public:
|
|||
void calculateNewFloatingWindow(CWindow* pWindow);
|
||||
void setEffectiveSizePosUsingConfig(CWindow* pWindow);
|
||||
void cleanupUnusedWorkspaces();
|
||||
xcb_visualtype_t* setupColors();
|
||||
xcb_visualtype_t* setupColors(const int&);
|
||||
void updateRootCursor();
|
||||
void applyRoundedCornersToWindow(CWindow* pWindow);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue