Commit daa95d5e by Jessica Hawkwell

fixing breaks from 89302031 and adding to #1

1 parent 89302031
......@@ -40,9 +40,9 @@
//#include <vector>
// MOVING WINDOWS
NPosition<int> *NWMAction::drag_start_cursor;
NPosition<int> *NWMAction::drag_start_window;
NSize<unsigned int> *NWMAction::drag_start_resize;
nitrogen::NPosition<int> *NWMAction::drag_start_cursor;
nitrogen::NPosition<int> *NWMAction::drag_start_window;
nitrogen::NSize<unsigned int> *NWMAction::drag_start_resize;
// XLIB
Display *NWMAction::disp;
......@@ -63,35 +63,39 @@ void NWMAction::onKeyRelease(XKeyReleasedEvent e) {
}
void NWMAction::onButtonPress(XButtonPressedEvent e) {
if (!NUtils::isNitroWin(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);
if (frame == 0) { return; }
if (frame == 0) {
return;
}
std::cout << "[ButtonPress] " << frame << " (" << NUtils::isNitroWin(e.window) << ", " << e.window << ")" << std::endl;
if (drag_start_cursor == nullptr) {
drag_start_cursor = new NPosition<int>(e.x_root, e.y_root);
drag_start_cursor = new nitrogen::NPosition<int>(e.x_root, e.y_root);
}
else {
*drag_start_cursor = NPosition<int>(e.x_root, e.y_root);
*drag_start_cursor = nitrogen::NPosition<int>(e.x_root, e.y_root);
}
Window rroot;
XGetGeometry(disp, frame, &rroot, &x, &y, &w, &h, &bw, &depth);
if (drag_start_window == nullptr) {
drag_start_window = new NPosition<int>(x, y);
drag_start_window = new nitrogen::NPosition<int>(x, y);
}
else {
*drag_start_window = NPosition<int>(x, y);
*drag_start_window = nitrogen::NPosition<int>(x, y);
}
if (drag_start_resize == nullptr) {
drag_start_resize = new NSize<unsigned int>(w, h);
drag_start_resize = new nitrogen::NSize<unsigned int>(w, h);
}
else {
*drag_start_resize = NSize<unsigned int>(w, h);
*drag_start_resize = nitrogen::NSize<unsigned int>(w, h);
}
XRaiseWindow(disp, frame);
......@@ -103,7 +107,9 @@ void NWMAction::onButtonRelease(XButtonReleasedEvent e) {
}
void NWMAction::onMotionNotify(XMotionEvent e) {
if (!NUtils::isNitroWin(e.window)) { return; }
if (!NUtils::isNitroWin(e.window)) {
return;
}
/*std::cout << "XMotionEvent: " << e.window;
std::cout << " (" << e.x << ", " << e.y << "), (";
......@@ -126,13 +132,15 @@ void NWMAction::onMotionNotify(XMotionEvent e) {
std::cout << std::endl; // */
Window frame = NUtils::checkNitroWin(e.window);
if (frame == 0) { return; }
if (frame == 0) {
return;
}
NPosition<int> drag_pos(e.x_root, e.y_root);
NPosition<int> delta = drag_pos - *drag_start_cursor;
nitrogen::NPosition<int> drag_pos(e.x_root, e.y_root);
nitrogen::NPosition<int> delta = drag_pos - *drag_start_cursor;
if (e.state & Button1Mask) { // move window
NPosition<int> dest = delta + *drag_start_window;
nitrogen::NPosition<int> dest = delta + *drag_start_window;
dest.setZeroIfNegative();
XMoveWindow(disp, frame, dest.getX(), dest.getY());
}
......@@ -185,9 +193,13 @@ void NWMAction::onDestroyNotify(XDestroyWindowEvent e) {
}
void NWMAction::onUnmapNotify(XUnmapEvent e) {
if (!clients->count(e.window)) { return; }
if (!clients->count(e.window)) {
return;
}
if (e.event == *root) { return; }
if (e.event == *root) {
return;
}
NUtils::unFrameWindow(e.window);
}
......@@ -282,14 +294,20 @@ void NWMAction::onLASTEvent(XAnyEvent e) {
}
void NWMAction::onDefaultEvent(XAnyEvent e) {
if (e.window == *root) { return; } // don't log root window events
if (e.window == *root) {
return;
} // don't log root window events
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 (name != nullptr) {
std::cout << " (" << name << ")";
}
}
if (clients->count(e.window)) {
std::cout << " (NitroWin)";
}
if (clients->count(e.window)) { std::cout << " (NitroWin)"; }
std::cout << std::endl;
NUtils::listWindows();
}
......
......@@ -42,15 +42,15 @@
#include <unordered_map>
#include <vector>
template <class T> class NSize;
template <typename T> class NPosition;
//template <class T> class NSize;
//template <typename T> class NPosition;
class NWMAction {
protected:
// MOVING WINDOWS
static NPosition<int> *drag_start_cursor;
static NPosition<int> *drag_start_window;
static NSize<unsigned int> *drag_start_resize;
static nitrogen::NPosition<int> *drag_start_cursor;
static nitrogen::NPosition<int> *drag_start_window;
static nitrogen::NSize<unsigned int> *drag_start_resize;
public:
// XLIB
......
......@@ -40,12 +40,6 @@ namespace nitrogen {
NObject::NObject() {
}
/*NObject::NObject(const NObject& orig) {
} // */
NObject::~NObject() {
}
std::string* NObject::toString() const {
std::string* str;
str->append(getTypeName(this));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!