Commit eb0befb4 by Jessica Hawkwell

minor refactor

1 parent e680e4f0
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "NConfigure.h"
void NConfigure::event(XConfigureRequestEvent *e) {
XWindowChanges changes;
changes.x = e->x;
changes.y = e->y;
changes.width = e->width;
changes.height = e->height;
changes.border_width = e->border_width;
changes.sibling = e->above;
changes.stack_mode = e->detail;
if (clients->count(e->window)) {
Window frame = (*clients)[e->window];
XConfigureWindow(disp, frame, e->value_mask, &changes);
}
XConfigureWindow(disp, e->window, e->value_mask, &changes);
}
NConfigure::NConfigure() {
}
NConfigure::NConfigure(const NConfigure& orig) {
}
NConfigure::~NConfigure() {
}
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NCONFIGURE_H
#define NCONFIGURE_H
#include <X11/Xlib.h>
#include "NWMAction.h"
class NConfigure : public NWMAction {
public:
static void event(XConfigureRequestEvent *e);
virtual ~NConfigure();
private:
NConfigure();
NConfigure(const NConfigure& orig);
};
#endif /* NCONFIGURE_H */
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "NMapping.h"
void NMapping::event(XMapEvent* e) {
}
void NMapping::event(XMappingEvent* e) {
}
void NMapping::event(XMapRequestEvent* e) {
const unsigned int BORDER_WIDTH = 3;
const unsigned long BORDER_COLOR = 0xff0000;
const unsigned long BG_COLOR = 0x0000ff;
XWindowAttributes attrs;
Status s = XGetWindowAttributes(disp, e->window, &attrs);
if (s == 0) { return; }
Window *f = &e->window;
Window frame = XCreateSimpleWindow(disp, *root, attrs.x, attrs.y, attrs.width, attrs.height, BORDER_WIDTH, BORDER_COLOR, BG_COLOR);
XSelectInput(disp, frame, SubstructureRedirectMask | SubstructureNotifyMask);
XAddToSaveSet(disp, *f);
XReparentWindow(disp, *f, frame, 0, 0);
XMapWindow(disp, frame);
(*clients)[*f] = frame;
}
NMapping::NMapping() {
}
NMapping::NMapping(const NMapping& orig) {
}
NMapping::~NMapping() {
}
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NMAPPING_H
#define NMAPPING_H
//#include <unordered_map>
#include "NWMAction.h"
class NMapping : public NWMAction {
public:
static void event(XMapEvent *e);
static void event(XMappingEvent *e);
static void event(XMapRequestEvent *e);
~NMapping();
private:
NMapping();
NMapping(const NMapping& orig);
};
#endif /* NMAPPING_H */
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "NUtils.h"
void NUtils::frameWindow (Window w) {
frameWindow(w, false);
}
void NUtils::frameWindow (Window w, bool pre_exist) {
const unsigned int BORDER_WIDTH = 3;
const unsigned long BORDER_COLOR = 0xff0000;
const unsigned long BG_COLOR = 0x0000ff;
XWindowAttributes attrs;
Status s = XGetWindowAttributes(NWMAction::disp, w, &attrs);
if (pre_exist) {
if (attrs.override_redirect || attrs.map_state != IsViewable) { return; }
}
Window frame = XCreateSimpleWindow(NWMAction::disp, *NWMAction::root, attrs.x, attrs.y, attrs.width, attrs.height, BORDER_WIDTH, BORDER_COLOR, BG_COLOR);
XSelectInput(NWMAction::disp, frame, SubstructureRedirectMask | SubstructureNotifyMask);
XAddToSaveSet(NWMAction::disp, w);
XReparentWindow(NWMAction::disp, w, frame, 0, 0);
XMapWindow(NWMAction::disp, frame);
(*NWMAction::clients)[w] = frame;
XGrabButton(NWMAction::disp, Button1, Mod1Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod2Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod3Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod4Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button1, Mod5Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(NWMAction::disp, Button2, Mod4Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
}
void NUtils::unFrameWindow (Window w) {
Window frame = (*NWMAction::clients)[w];
XUnmapWindow(NWMAction::disp, frame);
XReparentWindow(NWMAction::disp, w, *NWMAction::root, 0, 0);
XRemoveFromSaveSet(NWMAction::disp, w);
XDestroyWindow(NWMAction::disp, frame);
NWMAction::clients->erase(w);
}
std::string NUtils::getEventName(int event) {
switch (event) {
case KeyPress: return "KeyPress"; break;
case KeyRelease: return "KeyRelease"; break;
case ButtonPress: return "ButtonPress"; break;
case ButtonRelease: return "ButtonRelease"; break;
case MotionNotify: return "MotionNotify"; break;
case EnterNotify: return "EnterNotify"; break;
case LeaveNotify: return "LeaveNotify"; break;
case FocusIn: return "FocusIn"; break;
case FocusOut: return "FocusOut"; break;
case KeymapNotify: return "KeymapNotify"; break;
case Expose: return "Expose"; break;
case GraphicsExpose: return "GraphicsExpose"; break;
case NoExpose: return "NoExpose"; break;
case VisibilityNotify: return "VisibilityNotify"; break;
case CreateNotify: return "CreateNotify"; break;
case DestroyNotify: return "DestroyNotify"; break;
case UnmapNotify: return "UnmapNotify"; break;
case MapNotify: return "MapNotify"; break;
case MapRequest: return "MapRequest"; break;
case ReparentNotify: return "ReparentNotify"; break;
case ConfigureNotify: return "ConfigureNotify"; break;
case ConfigureRequest: return "ConfigureRequest"; break;
case GravityNotify: return "GravityNotify"; break;
case ResizeRequest: return "ResizeRequest"; break;
case CirculateNotify: return "CirculateNotify"; break;
case CirculateRequest: return "CirculateRequest"; break;
case PropertyNotify: return "PropertyNotify"; break;
case SelectionClear: return "SelectionClear"; break;
case SelectionRequest: return "SelectionRequest"; break;
case SelectionNotify: return "SelectionNotify"; break;
case ColormapNotify: return "ColormapNotify"; break;
case ClientMessage: return "ClientMessage"; break;
case MappingNotify: return "MappingNotify"; break;
case GenericEvent: return "GenericEvent"; break;
case LASTEvent: return "LASTEvent"; break;
default: return "Unknown"; break;
}
}
/*
* Copyright (c) 2018, <copyright holder> <email>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> <email> ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> <email> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef NUTILS_H
#define NUTILS_H
#include "NWMAction.h"
#include <iostream>
class NUtils {
public:
static void frameWindow(Window w);
static void frameWindow(Window w, bool pre_exist);
static void unFrameWindow(Window w);
static std::string getEventName(int event);
};
#endif // NUTILS_H
/*
* Copyright (c) 2018, jlhawkwell
* Copyright(c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -16,10 +16,10 @@
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
......@@ -32,16 +32,184 @@
*/
#include "NWMAction.h"
#include "NUtils.h"
#include <iostream>
Display *NWMAction::disp;
Window *NWMAction::root;
std::unordered_map<Window, Window> *NWMAction::clients;
void NWMAction::onKeyPress(XKeyPressedEvent e) {
NWMAction::NWMAction() {
}
NWMAction::NWMAction(const NWMAction& orig) {
void NWMAction::onKeyRelease(XKeyReleasedEvent e) {
}
NWMAction::~NWMAction() {
void NWMAction::onButtonPress(XButtonPressedEvent e) {
}
void NWMAction::onButtonRelease(XButtonReleasedEvent e) {
}
void NWMAction::onMotionNotify(XMotionEvent e) {
if (!(*clients).count(e.window)) { return; }
std::cout << "XMotionEvent: " << e.window;
std::cout << " (" << e.x << ", " << e.y << "), (";
std::cout << e.x_root << ", " << e.y_root << ")";
std::cout << std::endl;
}
void NWMAction::onEnterNotify(XEnterWindowEvent e) {
}
void NWMAction::onLeaveNotify(XLeaveWindowEvent e) {
}
void NWMAction::onFocusIn(XFocusInEvent e) {
}
void NWMAction::onFocusOut(XFocusOutEvent e) {
}
void NWMAction::onKeymapNotify(XKeymapEvent e) {
}
void NWMAction::onExpose(XExposeEvent e) {
}
void NWMAction::onGraphicsExpose(XGraphicsExposeEvent e) {
}
void NWMAction::onNoExpose(XNoExposeEvent e) {
}
void NWMAction::onVisibilityNotify(XVisibilityEvent e) {
}
void NWMAction::onCreateNotify(XCreateWindowEvent e) {
}
void NWMAction::onDestroyNotify(XDestroyWindowEvent e) {
}
void NWMAction::onUnmapNotify(XUnmapEvent e) {
if (!clients->count(e.window)) { return; }
if (e.event == *root) { return; }
NUtils::unFrameWindow(e.window);
}
void NWMAction::onMapNotify(XMapEvent e) {
}
void NWMAction::onMapRequest(XMapRequestEvent e) {
NUtils::frameWindow(e.window);
XMapWindow(disp, e.window);
}
void NWMAction::onReparentNotify(XReparentEvent e) {
}
void NWMAction::onConfigureNotify(XConfigureEvent e) {
}
void NWMAction::onConfigureRequest(XConfigureRequestEvent e) {
XWindowChanges changes;
changes.x = e.x;
changes.y = e.y;
changes.width = e.width;
changes.height = e.height;
changes.border_width = e.border_width;
changes.sibling = e.above;
changes.stack_mode = e.detail;
if (clients->count(e.window)) {
Window frame = (*clients)[e.window];
XConfigureWindow(disp, frame, e.value_mask, &changes);
}
XConfigureWindow(disp, e.window, e.value_mask, &changes);
}
void NWMAction::onGravityNotify(XGravityEvent e) {
}
void NWMAction::onResizeRequest(XResizeRequestEvent e) {
}
void NWMAction::onCirculateNotify(XCirculateEvent e) {
}
void NWMAction::onCirculateRequest(XCirculateRequestEvent e) {
}
void NWMAction::onPropertyNotify(XPropertyEvent e) {
}
void NWMAction::onSelectionClear(XSelectionClearEvent e) {
}
void NWMAction::onSelectionRequest(XSelectionRequestEvent e) {
}
void NWMAction::onSelectionNotify(XSelectionEvent e) {
}
void NWMAction::onColormapNotify(XColormapEvent e) {
}
void NWMAction::onClientMessage(XClientMessageEvent e) {
}
void NWMAction::onMappingNotify(XMappingEvent e) {
}
void NWMAction::onGenericEvent(XGenericEvent e) {
}
void NWMAction::onLASTEvent(XAnyEvent e) {
}
void NWMAction::onDefaultEvent(XAnyEvent e) {
std::cout << "Event [" << NUtils::getEventName(e.type) << "] on";
std::cout << e.window << " @ " << e.display << std::endl;
}
Display *NWMAction::disp;
Window *NWMAction::root;
std::unordered_map<Window, Window> *NWMAction::clients;
......@@ -39,15 +39,46 @@
class NWMAction {
public:
NWMAction();
NWMAction(const NWMAction& orig);
virtual ~NWMAction();
static Display *disp;
static Window *root;
static std::unordered_map<Window, Window> *clients;
private:
static void onKeyPress(XKeyPressedEvent e);
static void onKeyRelease(XKeyReleasedEvent e);
static void onButtonPress(XButtonPressedEvent e);
static void onButtonRelease(XButtonReleasedEvent e);
static void onMotionNotify(XMotionEvent e);
static void onEnterNotify(XEnterWindowEvent e);
static void onLeaveNotify(XLeaveWindowEvent e);
static void onFocusIn(XFocusInEvent e);
static void onFocusOut(XFocusOutEvent e);
static void onKeymapNotify(XKeymapEvent e);
static void onExpose(XExposeEvent e);
static void onGraphicsExpose(XGraphicsExposeEvent e);
static void onNoExpose(XNoExposeEvent e);
static void onVisibilityNotify(XVisibilityEvent e);
static void onCreateNotify(XCreateWindowEvent e);
static void onDestroyNotify(XDestroyWindowEvent e);
static void onUnmapNotify(XUnmapEvent e);
static void onMapNotify(XMapEvent e);
static void onMapRequest(XMapRequestEvent e);
static void onReparentNotify(XReparentEvent e);
static void onConfigureNotify(XConfigureEvent e);
static void onConfigureRequest(XConfigureRequestEvent e);
static void onGravityNotify(XGravityEvent e);
static void onResizeRequest(XResizeRequestEvent e);
static void onCirculateNotify(XCirculateEvent e);
static void onCirculateRequest(XCirculateRequestEvent e);
static void onPropertyNotify(XPropertyEvent e);
static void onSelectionClear(XSelectionClearEvent e);
static void onSelectionRequest(XSelectionRequestEvent e);
static void onSelectionNotify(XSelectionEvent e);
static void onColormapNotify(XColormapEvent e);
static void onClientMessage(XClientMessageEvent e);
static void onMappingNotify(XMappingEvent e);
static void onGenericEvent(XGenericEvent e);
static void onLASTEvent(XAnyEvent e);
static void onDefaultEvent(XAnyEvent e);
};
#endif /* NWMACTION_H */
......
......@@ -26,11 +26,12 @@
#include "NWManager.h"
#include "NWMAction.h"
#include "NConfigure.h"
#include "NMapping.h"
#include "NUtils.h"
#include <iostream>
void printEventData(XEvent e);
bool NWManager::wm_detected = false;
NWManager::NWManager() {
......@@ -51,14 +52,11 @@ NWManager::NWManager() {
clients = new std::unordered_map<Window, Window>();
}
NWManager::NWManager(const NWManager& orig) {
}
NWManager::~NWManager() {
XCloseDisplay(disp);
}
int NWManager::OnWMDetected(Display* display, XErrorEvent* e) {
int NWManager::OnWMDetected(Display *display, XErrorEvent *e) {
if (e->error_code == BadAccess) {
NWManager::wm_detected = true;
}
......@@ -66,7 +64,7 @@ int NWManager::OnWMDetected(Display* display, XErrorEvent* e) {
}
int NWManager::OnXError(Display* display, XErrorEvent* e) {
int NWManager::OnXError(Display *display, XErrorEvent *e) {
return 0;
}
......@@ -85,6 +83,19 @@ void NWManager::run() {
XSetErrorHandler(&NWManager::OnXError);
XGrabServer(disp);
Window r_root, r_parent;
Window *top_windows;
unsigned int top_levels = 0;
XQueryTree(disp, *root, &r_root, &r_parent, &top_windows, &top_levels);
for (unsigned int i = 0; i < top_levels; i++) {
NUtils::frameWindow(top_windows[i], true);
}
XFree(top_windows);
XUngrabServer(disp);
// init->main transition
NWMAction::disp = disp;
NWMAction::root = root;
......@@ -97,43 +108,42 @@ void NWManager::run() {
XNextEvent(disp, &e);
switch (e.type) {
case KeyPress: break;
case KeyRelease: break;
case ButtonPress: break;
case ButtonRelease: break;
case MotionNotify: break;
case EnterNotify: break;
case LeaveNotify: break;
case FocusIn: break;
case FocusOut: break;
case KeymapNotify: break;
case Expose: break;
case GraphicsExpose: break;
case NoExpose: break;
case VisibilityNotify: break;
case CreateNotify: break; /* ignore this */
case DestroyNotify: break;
case UnmapNotify: break;
case MapNotify: break; /* ignore this */
case MapRequest: NMapping::event(&e.xmaprequest); break;
case ReparentNotify: break; /* ignore this */
case ConfigureNotify: break; /* ignore this */
case ConfigureRequest: NConfigure::event(&e.xconfigurerequest); break;
case GravityNotify: break;
case ResizeRequest: break;
case CirculateNotify: break;
case CirculateRequest: break;
case PropertyNotify: break;
case SelectionClear: break;
case SelectionRequest: break;
case SelectionNotify: break;
case ColormapNotify: break;
case ClientMessage: break;
case MappingNotify: break;
case GenericEvent: break;
case LASTEvent: break;
default:
break;
//case KeyPress: break;
//case KeyRelease: break;
//case ButtonPress: break;
//case ButtonRelease: break;
case MotionNotify: NWMAction::onMotionNotify(e.xmotion); break;
//case EnterNotify: break;
//case LeaveNotify: break;
//case FocusIn: break;
//case FocusOut: break;
//case KeymapNotify: break;
//case Expose: break;
//case GraphicsExpose: break;
//case NoExpose: break;
//case VisibilityNotify: break;
//case CreateNotify: break; /* ignore this */
//case DestroyNotify: break; /* ignore this */
case UnmapNotify: NWMAction::onUnmapNotify(e.xunmap); break;
//case MapNotify: break; /* ignore this */
case MapRequest: NWMAction::onMapRequest(e.xmaprequest) ; break;
//case ReparentNotify: break; /* ignore this */
//case ConfigureNotify: break; /* ignore this */
case ConfigureRequest: NWMAction::onConfigureRequest(e.xconfigurerequest); break;
//case GravityNotify: break;
//case ResizeRequest: break;
//case CirculateNotify: break;
//case CirculateRequest: break;
//case PropertyNotify: break;
//case SelectionClear: break;
//case SelectionRequest: break;
//case SelectionNotify: break;
//case ColormapNotify: break;
//case ClientMessage: break;
//case MappingNotify: break;
//case GenericEvent: break;
//case LASTEvent: break;
default: NWMAction::onDefaultEvent(e.xany); break;
}
}
}
......
......@@ -33,13 +33,12 @@
class NWManager {
public:
NWManager();
NWManager(const NWManager& orig);
virtual ~NWManager();
void run();
void stop();
static int OnWMDetected(Display* display, XErrorEvent* e);
static int OnXError(Display* display, XErrorEvent* e);
static int OnWMDetected(Display *display, XErrorEvent *e);
static int OnXError(Display *display, XErrorEvent *e);
static bool wm_detected;
private:
......
#include <iostream>
#include "NWManager.h"
int main(int argc, char** argv) {
NWManager *nwm = new NWManager();
nwm->run();
int main ( int argc, char** argv )
{ NWManager *nwm = new NWManager();
nwm->run();
}
#!/bin/sh
XEPHYR=$(which Xephyr)
xinit ./xinitrc -- "$XEPHYR" :100 -screen 800x600 -host-cursor
xsetroot -solid grey &
xclock &
sleep 2 && xterm &
exec src/NitroWin/build/bin/NitroWin
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!