From 0c9396c9f2e14c61f6082916df81e4251fa1d3ec Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Tue, 23 Aug 2022 18:24:35 +1200 Subject: Fixed bug with negative width due to another bug in gaps calculation -_- --- main.cpp | 14 +++++++++----- makefile | 3 ++- util.h | 1 + util.h~ | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 util.h create mode 100644 util.h~ diff --git a/main.cpp b/main.cpp index 4633f5d..1efabe5 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,8 @@ #include #include "structs.h" +#include "util.h" + #include "config.h" using std::cout; @@ -91,7 +93,6 @@ void kill(const KeyArg arg) void keyPress(XKeyEvent e) { if(e.same_screen!=1) return; - //TODO: Make this into a for loop KeySym keysym = XLookupKeysym(&e, 1); for(int i = 0; i < sizeof(keyBinds)/sizeof(keyBinds[0]); i++) { @@ -226,6 +227,9 @@ void destroyNotify(XDestroyWindowEvent e) static int OnXError(Display* display, XErrorEvent* e) { cout << "XError " << e->type << ":\n"; + char buffer_return[100]; + XGetErrorText(dpy, e->type, buffer_return, sizeof(buffer_return)); + printf("\t%s\n", buffer_return); return 0; } @@ -249,8 +253,8 @@ void tile(int frameID, int x, int y, int w, int h) i++; if(i==subFrameIDs.size()) { - wW = (dir==horizontal) ? w - wX + outerGaps : w; - wH = (dir==vertical) ? h - wY + outerGaps : h; + wW = (dir==horizontal) ? w - (wX - x) : w; + wH = (dir==vertical) ? h - (wY - y) : h; } if(!f.isClient) { @@ -262,7 +266,7 @@ void tile(int frameID, int x, int y, int w, int h) wW -= gaps * 2; wH -= gaps * 2; Client c = clients.find(f.cID)->second; - printf("Arranging client with frame ID %i, client ID %i:\n\tx: %i, y: %i, w: %i, h: %i\n", fID, c.ID, wX, wY, wW, wH); + //printf("Arranging client with frame ID %i, client ID %i:\n\tx: %i, y: %i, w: %i, h: %i\n", fID, c.ID, wX, wY, wW, wH); XMoveWindow(dpy, c.w, wX, wY); XResizeWindow(dpy, c.w, @@ -332,7 +336,7 @@ int main(int argc, char** argv) XSetInputFocus(dpy, e.xcrossing.window, RevertToNone, CurrentTime); break; default: - //cout << "Unhandled event, code: " << e.type << "!\n"; + //cout << "Unhandled event, code: " << evNames[e.type] << "!\n"; break; } } diff --git a/makefile b/makefile index 63a8257..abd3e2b 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,8 @@ all: YATwm HEADERS = \ config.h \ - structs.h + structs.h \ + util.h SOURCES = \ main.cpp OBJECTS = $(SOURCES:.cpp=.o) diff --git a/util.h b/util.h new file mode 100644 index 0000000..2268432 --- /dev/null +++ b/util.h @@ -0,0 +1 @@ +const char* evNames[37] = {0, 0, "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", "GenericEvent", "LASTEvent"}; diff --git a/util.h~ b/util.h~ new file mode 100644 index 0000000..1e5cadb --- /dev/null +++ b/util.h~ @@ -0,0 +1,36 @@ +const char* evNames[37] = {0}; +evNames[2]="KeyPress"; +evNames[3]="KeyRelease"; +evNames[4]="ButtonPress"; +evNames[5]="ButtonRelease"; +evNames[6]="MotionNotify"; +evNames[7]="EnterNotify"; +evNames[8]="LeaveNotify"; +evNames[9]="FocusIn"; +evNames[10]="FocusOut"; +evNames[11]="KeymapNotify"; +evNames[12]="Expose"; +evNames[13]="GraphicsExpose"; +evNames[14]="NoExpose"; +evNames[15]="VisibilityNotify"; +evNames[16]="CreateNotify"; +evNames[17]="DestroyNotify"; +evNames[18]="UnmapNotify"; +evNames[19]="MapNotify"; +evNames[20]="MapRequest"; +evNames[21]="ReparentNotify"; +evNames[22]="ConfigureNotify"; +evNames[23]="ConfigureRequest"; +evNames[24]="GravityNotify"; +evNames[25]="ResizeRequest"; +evNames[26]="CirculateNotify"; +evNames[27]="CirculateRequest"; +evNames[28]="PropertyNotify"; +evNames[29]="SelectionClear"; +evNames[30]="SelectionRequest"; +evNames[31]="SelectionNotify"; +evNames[32]="ColormapNotify"; +evNames[33]="ClientMessage"; +evNames[34]="MappingNotify"; +evNames[35]="GenericEvent"; +evNames[36]="LASTEvent"; -- cgit v1.2.3