Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/bar/Bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bool isParentDead() {

void parseEvent() {
while(1) {
g_pWindowManager->recieveEvent();
g_pWindowManager->receiveEvent("bar");
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@ void CStatusBar::setupTray() {
free(SELREPLY);
free(TRAYREPLY);

Debug::log(LOG, "Tray setup done, sending message!");
Debug::log(LOG, "Tray setup done, sending message! Tray window id: " + std::to_string(trayWindowID));

uint8_t buf[32] = {NULL};
xcb_client_message_event_t* event = (xcb_client_message_event_t*)buf;
Expand All @@ -268,6 +268,7 @@ void CStatusBar::fixTrayOnCreate() {

if (m_bHasTray && ConfigManager::getInt("bar:no_tray_saving") == 0) {
for (auto& tray : g_pWindowManager->trayclients) {
Debug::log(LOG, "Fixing tray client on create " + std::to_string(tray.window) + " by reparenting to tray " + std::to_string(g_pWindowManager->statusBar->trayWindowID));
xcb_reparent_window(g_pWindowManager->DisplayConnection, tray.window, g_pWindowManager->statusBar->trayWindowID, 0, 0);
xcb_map_window(g_pWindowManager->DisplayConnection, tray.window);
tray.hidden = false;
Expand Down Expand Up @@ -300,6 +301,7 @@ void CStatusBar::saveTrayOnDestroy() {
return;

for (auto& tray : g_pWindowManager->trayclients) {
Debug::log(LOG, "Saving tray client on destroy " + std::to_string(tray.window) + " by reparenting to root " + std::to_string(g_pWindowManager->Screen->root));
xcb_reparent_window(g_pWindowManager->DisplayConnection, tray.window, g_pWindowManager->Screen->root, 30000, 30000);
}
}
Expand Down Expand Up @@ -383,13 +385,13 @@ void CStatusBar::setup(int MonitorID) {
// fix tray
fixTrayOnCreate();

Debug::log(LOG, "Bar setup done!");
Debug::log(LOG, "Bar setup done! Bar window id " + std::to_string(m_iWindowID));

m_bIsDestroyed = false;
}

void CStatusBar::destroy() {
Debug::log(LOG, "Destroying the bar!");
Debug::log(LOG, "Destroying bar! Bar window id " + std::to_string(m_iWindowID));

if (m_bIsDestroyed)
return;
Expand All @@ -411,6 +413,7 @@ void CStatusBar::destroy() {
m_pCairo = nullptr;

m_bIsDestroyed = true;
Debug::log(LOG, "Destroyed bar! Bar window id " + std::to_string(m_iWindowID));
}

int CStatusBar::getTextWidth(std::string text, std::string font, double size) {
Expand Down Expand Up @@ -694,4 +697,4 @@ void CStatusBar::ensureTrayClientHidden(xcb_window_t window, bool hide) {
if (trayitem.window == window)
trayitem.hidden = hide;
}
}
}
2 changes: 1 addition & 1 deletion src/bar/Bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ class CStatusBar {
};

// Main thread for the bar. Is only initted once in main.cpp so we can do this.
int64_t barMainThread();
int64_t barMainThread();
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ void ConfigManager::loadConfigLoadVars() {

// Reload the bar as well, don't load it before the default is loaded.
if (loadBar && g_pWindowManager->statusBar && (configValues["bar:enabled"].intValue == 1 || parseError != "")) {
Debug::log(WARN, "Destroying bar because reloading! Bar window id " + std::to_string(g_pWindowManager->statusBar->getWindowID()));
g_pWindowManager->statusBar->destroy();

// make the bar height visible
Expand Down
23 changes: 14 additions & 9 deletions src/events/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ void Events::eventLeave(xcb_generic_event_t* event) {
void Events::eventDestroy(xcb_generic_event_t* event) {
const auto E = reinterpret_cast<xcb_destroy_notify_event_t*>(event);

Debug::log(LOG, "Destroy called on event " + std::to_string(E->event) + " window " + std::to_string(E->window));

// let bar check if it wasnt a tray item
if (g_pWindowManager->statusBar)
g_pWindowManager->statusBar->ensureTrayClientDead(E->window);

RETURNIFBAR;

Debug::log(LOG, "Destroy called on " + std::to_string(E->window));

g_pWindowManager->closeWindowAllChecks(E->window);

// refocus on new window
Expand All @@ -145,6 +145,8 @@ void Events::eventDestroy(xcb_generic_event_t* event) {
void Events::eventUnmapWindow(xcb_generic_event_t* event) {
const auto E = reinterpret_cast<xcb_unmap_notify_event_t*>(event);

Debug::log(LOG, "Unmap called on event " + std::to_string(E->event) + " window " + std::to_string(E->window));

// let bar check if it wasnt a tray item
if (g_pWindowManager->statusBar)
g_pWindowManager->statusBar->ensureTrayClientHidden(E->window, true);
Expand All @@ -154,11 +156,11 @@ void Events::eventUnmapWindow(xcb_generic_event_t* event) {
const auto PCLOSEDWINDOW = g_pWindowManager->getWindowFromDrawable(E->window);

if (!PCLOSEDWINDOW) {
Debug::log(LOG, "Unmap called on an invalid window: " + std::to_string(E->window));
Debug::log(LOG, "Unmap called on an invalid window: event " + std::to_string(E->event) + " window " + std::to_string(E->window));
return; // bullshit window?
}

Debug::log(LOG, "Unmap called on " + std::to_string(E->window) + " -> " + PCLOSEDWINDOW->getName());
Debug::log(LOG, "Unmap called on event " + std::to_string(E->event) + " window " + std::to_string(E->window) + " -> " + PCLOSEDWINDOW->getName());

if (!PCLOSEDWINDOW->getDock())
g_pWindowManager->closeWindowAllChecks(E->window);
Expand Down Expand Up @@ -635,17 +637,19 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) {
void Events::eventMapWindow(xcb_generic_event_t* event) {
const auto E = reinterpret_cast<xcb_map_request_event_t*>(event);

// Ignore sequence
ignoredEvents.push_back(E->sequence);

// let bar check if it wasnt a tray item
if (g_pWindowManager->statusBar)
g_pWindowManager->statusBar->ensureTrayClientHidden(E->window, false);

RETURNIFBAR;

// Map the window
xcb_map_window(g_pWindowManager->DisplayConnection, E->window);
const auto COOKIE = xcb_map_window(g_pWindowManager->DisplayConnection, E->window);

// Ignore sequence
Debug::log(LOG, "Will ignore map request event sequence " + std::to_string(E->sequence) + " on window " + std::to_string(E->window));
auto ignoreEvent = std::make_tuple(COOKIE.sequence, XCB_MAP_REQUEST);
Events::ignoredEvents.push_back(ignoreEvent);

// We check if the window is not on our tile-blacklist and if it is, we have a special treatment procedure for it.
// this func also sets some stuff
Expand Down Expand Up @@ -941,6 +945,7 @@ void Events::eventClientMessage(xcb_generic_event_t* event) {
g_pWindowManager->trayclients.push_back(newTrayClient);

xcb_map_window(g_pWindowManager->DisplayConnection, CLIENT);
Debug::log(LOG, "Docked window " + std::to_string(CLIENT) + " to the bar " + std::to_string(g_pWindowManager->statusBar->getWindowID()));
}
}
}
Expand Down Expand Up @@ -1029,4 +1034,4 @@ void Events::eventRandRScreenChange(xcb_generic_event_t* event) {

// Make all windows dirty and recalc all workspaces
g_pWindowManager->recalcAllWorkspaces();
}
}
6 changes: 4 additions & 2 deletions src/events/events.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cstdint>
#include <inttypes.h>

#include <thread>
Expand All @@ -17,6 +18,7 @@ namespace Events {
EVENT(MotionNotify);
EVENT(ClientMessage);
EVENT(Configure);
EVENT(Property);

EVENT(RandRScreenChange);

Expand All @@ -32,9 +34,9 @@ namespace Events {
inline bool nextWindowCentered = false;

// Fix focus on open
inline std::deque<uint64_t> ignoredEvents;
inline std::deque<std::tuple<uint64_t, int32_t>> ignoredEvents;

// Fix spammed RandR events
inline std::chrono::high_resolution_clock::time_point lastRandREvent = std::chrono::high_resolution_clock::now();
inline int susRandREventNo = 0;
};
};
2 changes: 1 addition & 1 deletion src/utilities/AnimationUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ void AnimationUtil::move() {

if (updateRequired)
emptyEvent(); // send a fake request to update dirty windows
}
}
2 changes: 1 addition & 1 deletion src/utilities/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ std::vector<std::string> splitString(std::string in, char c) {
}

return returns;
}
}
77 changes: 76 additions & 1 deletion src/utilities/XCBProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,79 @@ uint8_t getWindowState(const int& win) {
free(REPLY);
}
return returns;
}
}

std::string eventCodeToString(const uint8_t& code) {
switch (code) {
case XCB_KEY_PRESS:
return "XCB_KEY_PRESS";
case XCB_KEY_RELEASE:
return "XCB_KEY_RELEASE";
case XCB_BUTTON_PRESS:
return "XCB_BUTTON_PRESS";
case XCB_BUTTON_RELEASE:
return "XCB_BUTTON_RELEASE";
case XCB_MOTION_NOTIFY:
return "XCB_MOTION_NOTIFY";
case XCB_ENTER_NOTIFY:
return "XCB_ENTER_NOTIFY";
case XCB_LEAVE_NOTIFY:
return "XCB_LEAVE_NOTIFY";
case XCB_FOCUS_IN:
return "XCB_FOCUS_IN";
case XCB_FOCUS_OUT:
return "XCB_FOCUS_OUT";
case XCB_KEYMAP_NOTIFY:
return "XCB_KEYMAP_NOTIFY";
case XCB_EXPOSE:
return "XCB_EXPOSE";
case XCB_GRAPHICS_EXPOSURE:
return "XCB_GRAPHICS_EXPOSURE";
case XCB_NO_EXPOSURE:
return "XCB_NO_EXPOSURE";
case XCB_VISIBILITY_NOTIFY:
return "XCB_VISIBILITY_NOTIFY";
case XCB_CREATE_NOTIFY:
return "XCB_CREATE_NOTIFY";
case XCB_DESTROY_NOTIFY:
return "XCB_DESTROY_NOTIFY";
case XCB_UNMAP_NOTIFY:
return "XCB_UNMAP_NOTIFY";
case XCB_MAP_NOTIFY:
return "XCB_MAP_NOTIFY";
case XCB_MAP_REQUEST:
return "XCB_MAP_REQUEST";
case XCB_REPARENT_NOTIFY:
return "XCB_REPARENT_NOTIFY";
case XCB_CONFIGURE_NOTIFY:
return "XCB_CONFIGURE_NOTIFY";
case XCB_CONFIGURE_REQUEST:
return "XCB_CONFIGURE_REQUEST";
case XCB_GRAVITY_NOTIFY:
return "XCB_GRAVITY_NOTIFY";
case XCB_RESIZE_REQUEST:
return "XCB_RESIZE_REQUEST";
case XCB_CIRCULATE_NOTIFY:
return "XCB_CIRCULATE_NOTIFY";
case XCB_CIRCULATE_REQUEST:
return "XCB_CIRCULATE_REQUEST";
case XCB_PROPERTY_NOTIFY:
return "XCB_PROPERTY_NOTIFY";
case XCB_SELECTION_CLEAR:
return "XCB_SELECTION_CLEAR";
case XCB_SELECTION_REQUEST:
return "XCB_SELECTION_REQUEST";
case XCB_SELECTION_NOTIFY:
return "XCB_SELECTION_NOTIFY";
case XCB_COLORMAP_NOTIFY:
return "XCB_COLORMAP_NOTIFY";
case XCB_CLIENT_MESSAGE:
return "XCB_CLIENT_MESSAGE";
case XCB_MAPPING_NOTIFY:
return "XCB_MAPPING_NOTIFY";
case XCB_GE_GENERIC:
return "XCB_GE_GENERIC";
default:
return "UNKNOWN_EVENT";
}
}
4 changes: 3 additions & 1 deletion src/utilities/XCBProps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ std::string getRoleName(int64_t window);
std::string getWindowName(uint64_t window);
uint8_t getWindowState(const int& win);

void removeAtom(const int& window, xcb_atom_t prop, xcb_atom_t atom);
void removeAtom(const int& window, xcb_atom_t prop, xcb_atom_t atom);

std::string eventCodeToString(const uint8_t& code);
Loading