Commit e680e4f0 by Jessica Hawkwell

initial import

0 parents
# Created by https://www.gitignore.io/api/git,c++,cmake,netbeans,kdevelop4
### C++ ###
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
### CMake ###
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
build
### Git ###
*.orig
### KDevelop4 ###
*.kdev4
.kdev4/
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
nbactions.xml
# End of https://www.gitignore.io/api/git,c++,cmake,netbeans,kdevelop4
cmake_minimum_required (VERSION 3.10)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build/lib)
add_subdirectory(src/NitroWin)
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="100">
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
<df root="." name="0">
<df name="CMakeFiles">
<df name="3.10.2">
<df name="CompilerIdC">
<in>CMakeCCompilerId.c</in>
</df>
<df name="CompilerIdCXX">
<in>CMakeCXXCompilerId.cpp</in>
</df>
</df>
<in>feature_tests.c</in>
<in>feature_tests.cxx</in>
</df>
<df name="src">
<df name="NitroWin">
<df name="CMakeFiles">
<df name="3.10.2">
<df name="CompilerIdC">
<in>CMakeCCompilerId.c</in>
</df>
<df name="CompilerIdCXX">
<in>CMakeCXXCompilerId.cpp</in>
</df>
</df>
<in>feature_tests.c</in>
<in>feature_tests.cxx</in>
</df>
<in>NConfigure.cpp</in>
<in>NConfigure.h</in>
<in>NWMAction.cpp</in>
<in>NWMAction.h</in>
<in>NWManager.cpp</in>
<in>NWManager.h</in>
<in>main.cpp</in>
</df>
</df>
</df>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false"
kind="IMPORTANT_FILES_FOLDER">
<itemPath>CMakeLists.txt</itemPath>
<itemPath>Makefile</itemPath>
<itemPath>nbproject/private/launcher.properties</itemPath>
</logicalFolder>
</logicalFolder>
<sourceFolderFilter>^(nbproject)$</sourceFolderFilter>
<sourceRootList>
<Elem>.</Elem>
</sourceRootList>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="Default" type="0" platformSpecific="true">
<toolsSet>
<compilerSet>default</compilerSet>
<platform>5</platform>
<dependencyChecking>false</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<codeAssistance>
</codeAssistance>
<makefileType>
<makeTool>
<buildCommandWorkingDir>.</buildCommandWorkingDir>
<buildCommand>${MAKE} -f Makefile</buildCommand>
<cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
<executablePath></executablePath>
</makeTool>
<preBuild>
<preBuildCommandWorkingDir>.</preBuildCommandWorkingDir>
<preBuildCommand>${CMAKE} -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${IDE_CC} -DCMAKE_CXX_COMPILER=${IDE_CXX} -DCMAKE_C_FLAGS_DEBUG="-g3 -gdwarf-2" -DCMAKE_CXX_FLAGS_DEBUG="-g3 -gdwarf-2" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .</preBuildCommand>
<preBuildFirst>true</preBuildFirst>
</preBuild>
</makefileType>
<item path="CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c"
ex="false"
tool="0"
flavor2="0">
</item>
<item path="CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="CMakeFiles/feature_tests.c" ex="false" tool="0" flavor2="0">
</item>
<item path="CMakeFiles/feature_tests.cxx" ex="false" tool="1" flavor2="0">
</item>
<item path="src/NitroWin/CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c"
ex="false"
tool="0"
flavor2="0">
</item>
<item path="src/NitroWin/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="src/NitroWin/CMakeFiles/feature_tests.c"
ex="false"
tool="0"
flavor2="0">
</item>
<item path="src/NitroWin/CMakeFiles/feature_tests.cxx"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="src/NitroWin/NConfigure.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="src/NitroWin/NConfigure.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NWMAction.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="src/NitroWin/NWMAction.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NWManager.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="src/NitroWin/NWManager.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/main.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
</confs>
</configurationDescriptor>
#Sat Mar 10 11:33:39 EST 2018
project.license=bsd
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.cnd.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>Nitrogen</name>
<c-extensions>c</c-extensions>
<cpp-extensions>cpp,cxx</cpp-extensions>
<header-extensions>h</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/>
<sourceRootList>
<sourceRootElem>.</sourceRootElem>
</sourceRootList>
<confList>
<confElem>
<name>Default</name>
<type>0</type>
</confElem>
</confList>
<formatting>
<project-formatting-style>false</project-formatting-style>
</formatting>
</data>
</configuration>
</project>
cmake_minimum_required (VERSION 3.10)
project (NitroWin)
find_package(X11)
include_directories("/usr/local/include")
link_libraries(${X11_LIBRARIES})
file(GLOB nwin "*.cpp")
add_executable(NitroWin ${nwin})
/*
* 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.
*/
/*
* File: NWMAction.cpp
* Author: jlhawkwell
*
* Created on March 10, 2018, 10:39 PM
*/
#include "NWMAction.h"
NWMAction::NWMAction() {
}
NWMAction::NWMAction(const NWMAction& orig) {
}
NWMAction::~NWMAction() {
}
Display *NWMAction::disp;
Window *NWMAction::root;
std::unordered_map<Window, Window> *NWMAction::clients;
/*
* 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.
*/
/*
* File: NWMAction.h
* Author: jlhawkwell
*
* Created on March 10, 2018, 10:39 PM
*/
#ifndef NWMACTION_H
#define NWMACTION_H
#include <X11/Xlib.h>
#include <unordered_map>
class NWMAction {
public:
NWMAction();
NWMAction(const NWMAction& orig);
virtual ~NWMAction();
static Display *disp;
static Window *root;
static std::unordered_map<Window, Window> *clients;
private:
};
#endif /* NWMACTION_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 "NWManager.h"
#include "NWMAction.h"
#include "NConfigure.h"
#include "NMapping.h"
#include <iostream>
bool NWManager::wm_detected = false;
NWManager::NWManager() {
wm_detected = false;
disp = XOpenDisplay(nullptr);
if (disp == nullptr) {
std::cout << "[ERR] nullptr disp -> " << XDisplayName(nullptr) << std::endl;
return;
}
root = &DefaultRootWindow(disp);
if (root == nullptr) {
std::cout << "[ERR] nullptr root -> " << XDisplayName(nullptr) << std::endl;
return;
}
clients = new std::unordered_map<Window, Window>();
}
NWManager::NWManager(const NWManager& orig) {
}
NWManager::~NWManager() {
XCloseDisplay(disp);
}
int NWManager::OnWMDetected(Display* display, XErrorEvent* e) {
if (e->error_code == BadAccess) {
NWManager::wm_detected = true;
}
return 0;
}
int NWManager::OnXError(Display* display, XErrorEvent* e) {
return 0;
}
void NWManager::run() {
// init
wm_detected = false;
XSetErrorHandler(&NWManager::OnWMDetected);
XSelectInput(disp, *root, SubstructureNotifyMask | SubstructureRedirectMask);
XSync(disp, false);
if (wm_detected) {
std::cout << "Another window manager was already running on " << XDisplayString(disp) << std::endl;
return;
}
XSetErrorHandler(&NWManager::OnXError);
// init->main transition
NWMAction::disp = disp;
NWMAction::root = root;
NWMAction::clients = clients;
// main loop
XEvent e;
keepGoing = true;
while (keepGoing) {
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;
}
}
}
void NWManager::stop() { keepGoing = false; }
/*
* 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 NWMANAGER_H
#define NWMANAGER_H
#include <X11/Xlib.h>
#include <unordered_map>
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 bool wm_detected;
private:
std::unordered_map<Window, Window> *clients;
bool keepGoing;
Display *disp;
Window *root;
};
#endif /* NWMANAGER_H */
#include <iostream>
#include "NWManager.h"
int main(int argc, char** argv) {
NWManager *nwm = new NWManager();
nwm->run();
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!