Commit 24a539b3 by Jessica Hawkwell

fixed error, started title bars

1 parent 21f05b1f
......@@ -28,8 +28,10 @@
<in>feature_tests.c</in>
<in>feature_tests.cxx</in>
</df>
<in>NConfigure.cpp</in>
<in>NConfigure.h</in>
<in>NPosition.h</in>
<in>NSize.h</in>
<in>NUtils.cpp</in>
<in>NUtils.h</in>
<in>NWMAction.cpp</in>
<in>NWMAction.h</in>
<in>NWManager.cpp</in>
......@@ -115,9 +117,13 @@
tool="1"
flavor2="0">
</item>
<item path="src/NitroWin/NConfigure.cpp" ex="false" tool="1" flavor2="0">
<item path="src/NitroWin/NPosition.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NConfigure.h" ex="false" tool="3" flavor2="0">
<item path="src/NitroWin/NSize.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NUtils.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="src/NitroWin/NUtils.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NWMAction.cpp" ex="false" tool="1" flavor2="0">
</item>
......
......@@ -41,6 +41,7 @@ void NUtils::frameWindow (Window w) {
void NUtils::frameWindow (Window w, bool pre_exist) {
if (NWMAction::frames->count(w)) { return; }
std::cout << "frameWindow " << w << std::endl;
const unsigned int BORDER_WIDTH = 3;
const unsigned long BORDER_COLOR = 0xff0000;
const unsigned long BG_COLOR = 0x0000ff;
......@@ -54,29 +55,32 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
}
Window frame = XCreateSimpleWindow(NWMAction::disp, *NWMAction::root, attrs.x, attrs.y, attrs.width + 25, attrs.height, BORDER_WIDTH, BORDER_COLOR, BG_COLOR);
Window titlebar = XCreateSimpleWindow(NWMAction::disp, *NWMAction::root, attrs.x, attrs.y, 25, attrs.height, 0, BORDER_COLOR, 0x7f7f7f);
XSelectInput(NWMAction::disp, frame, SubstructureRedirectMask | SubstructureNotifyMask);
XAddToSaveSet(NWMAction::disp, w);
XReparentWindow(NWMAction::disp, titlebar, frame, 0, 0);
XReparentWindow(NWMAction::disp, w, frame, 25, 0);
XMapWindow(NWMAction::disp, frame);
(*NWMAction::clients)[w] = frame;
(*NWMAction::frames)[frame] = w;
(*NWMAction::frames)[titlebar] = frame;
std::cout << "NitroWin window " << frame;
char *name = getName(NWMAction::disp, w);
if (name != nullptr) { std::cout << " (" << name << ")"; }
std::cout << std::endl;
XGrabButton(NWMAction::disp, Button1, 0, frame, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod2Mask, frame, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, 0, titlebar, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod2Mask, titlebar, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod1Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod1Mask | Mod2Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button3, Mod1Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button3, Mod1Mask | Mod2Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XMapWindow(NWMAction::disp, titlebar);
XMapWindow(NWMAction::disp, w);
}
......@@ -134,6 +138,12 @@ std::string NUtils::getEventName(int event) {
default: return "Unknown"; break;
}
}
void NUtils::listWindows() {
std::cout << "NitroWin list:" << std::endl;
for (auto it : (*NWMAction::clients)) {
std::cout << "\t" << it.first << " - " << it.second << std::endl;
}
}
char * NUtils::getName(Display *disp, Window w) {
Atom prop = XInternAtom(disp, "WM_NAME", False), type;
......@@ -144,12 +154,23 @@ char * NUtils::getName(Display *disp, Window w) {
XGetWindowProperty(disp, w, prop, 0, 1024, False, AnyPropertyType, &type, &form, &len, &remain, &list);
return (char*)list;
}
void NUtils::getName(Display *disp, Window w, char * name) {
/*void NUtils::getName(Display *disp, Window w, char * name) {
Atom prop = XInternAtom(disp, "WM_NAME", False), type;
int form;
unsigned long remain, len;
XSetWindowProperty
XGetWindowProperty(disp, w, prop, 0, 1024, False, AnyPropertyType, &type, &form, &len, &remain, &list);
return (char*)list;
//XGetWindowProperty(disp, w, prop, 0, 1024, False, AnyPropertyType, &type, &form, &len, &remain, &list);
} // */
bool NUtils::isNitroWin(Window w) {
if (NWMAction::clients->count(w)) { return true; }
else if (NWMAction::frames->count(w)) { return true; }
else { return false; }
}
Window NUtils::checkNitroWin(Window w) {
if (NWMAction::clients->count(w)) { return (*NWMAction::clients)[w]; }
else if (NWMAction::frames->count(w)) { return (*NWMAction::frames)[w]; }
else { return 0; }
}
......@@ -48,7 +48,10 @@ public:
static void frameWindow(Window w, bool pre_exist);
static void unFrameWindow(Window w);
static std::string getEventName(int event);
static void listWindows();
static char* getName(Display *disp, Window w);
static bool isNitroWin(Window w);
static Window checkNitroWin(Window w);
};
#endif // NUTILS_H
......@@ -58,7 +58,14 @@ void NWMAction::onKeyRelease(XKeyReleasedEvent e) {
}
void NWMAction::onButtonPress(XButtonPressedEvent e) {
if (!clients->count(e.window) && !frames->count(e.window)) { return; }
if (!NUtils::isNitroWin(e.window)) { return; }
int x = 0, y = 0;
unsigned int w = 0, h = 0;
unsigned int bw = 0, depth = 0;
Window frame = NUtils::checkNitroWin(e.window);
std::cout << "[ButtonPress] " << frame << std::endl;
if (drag_start_cursor == nullptr) {
drag_start_cursor = new NPosition<int>(e.x_root, e.y_root);
}
......@@ -66,10 +73,6 @@ void NWMAction::onButtonPress(XButtonPressedEvent e) {
*drag_start_cursor = NPosition<int>(e.x_root, e.y_root);
}
int x = 0, y = 0;
unsigned int w = 0, h = 0;
unsigned int bw = 0, depth = 0;
Window frame = (*clients)[e.window];
Window rroot;
XGetGeometry(disp, frame, &rroot, &x, &y, &w, &h, &bw, &depth);
if (drag_start_window == nullptr) {
......@@ -93,8 +96,7 @@ void NWMAction::onButtonRelease(XButtonReleasedEvent e) {
}
void NWMAction::onMotionNotify(XMotionEvent e) {
if (!clients->count(e.window) && !frames->count(e.window)) { return; }
std::cout << "DEBUG NWMAction:97" << std::endl;
if (!NUtils::isNitroWin(e.window)) { return; }
/*std::cout << "XMotionEvent: " << e.window;
std::cout << " (" << e.x << ", " << e.y << "), (";
......@@ -116,12 +118,7 @@ void NWMAction::onMotionNotify(XMotionEvent e) {
if (e.state & Mod5Mask) { std::cout << " Mod5Mask"; }
std::cout << std::endl; // */
Window frame;
if (NWMAction::clients->count(e.window)) { frame = (*clients)[e.window]; }
else if (NWMAction::frames->count(e.window)) { frame = e.window; }
else { return; }
std::cout << "DEBUG NWMAction:124" << std::endl;
Window frame = NUtils::checkNitroWin(e.window);
NPosition<int> drag_pos(e.x_root, e.y_root);
NPosition<int> delta = drag_pos - *drag_start_cursor;
......@@ -279,8 +276,10 @@ void NWMAction::onLASTEvent(XAnyEvent e) {
void NWMAction::onDefaultEvent(XAnyEvent e) {
std::cout << "Event [" << NUtils::getEventName(e.type) << "] on ";
std::cout << e.window;
if (!frames->count(e.window)) {
char* name = NUtils::getName(disp, e.window);
if (name != nullptr) { std::cout << " (" << name << ")"; }
}
if (clients->count(e.window)) { std::cout << " (NitroWin)"; }
std::cout << std::endl;
}
......
......@@ -81,9 +81,7 @@ int NWManager::OnXError(Display *display, XErrorEvent *e) {
<< " - " << error_text << std::endl
<< " Resource ID: " << e->resourceid << std::endl;
for (auto it : (*NWMAction::clients)) {
std::cout << "\t" << it.first << " - " << it.second << std::endl;
}
NUtils::listWindows();
/*NWMAction::clients->begin();
while (!NWMAction::clients->empty()) {
NWMAction::clients->
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!