Commit ab7acabc by Jessica Hawkwell

added referencing for titlebars

1 parent 24a539b3
[project]
name=Nitrogen
description=
base_path=./
run_cmd=
regenerate=true
type=C/C++
file_patterns=
[editor]
line_wrapping=false
line_break_column=120
auto_continue_multiline=true
[file_prefs]
final_new_line=true
ensure_convert_new_lines=true
strip_trailing_spaces=true
replace_tabs=false
[indentation]
indent_width=4
indent_type=1
indent_hard_tab_width=4
detect_indent=false
detect_indent_width=false
indent_mode=3
[long line marker]
long_line_behaviour=1
long_line_column=120
[files]
current_page=0
FILE_NAME_0=2377;C++;0;EUTF-8;1;1;0;%2Fusr%2Fhome%2Fjlhawkwell%2FProjects%2FNitrogen%2Fsrc%2FNitroWin%2FNWMAction.cpp;0;4
FILE_NAME_1=2016;C++;0;EUTF-8;1;1;0;%2Fusr%2Fhome%2Fjlhawkwell%2FProjects%2FNitrogen%2Fsrc%2FNitroWin%2FNWManager.cpp;0;4
FILE_NAME_2=117;CMake;0;EUTF-8;1;1;0;%2Fusr%2Fhome%2Fjlhawkwell%2FProjects%2FNitrogen%2FCMakeLists.txt;0;4
[VTE]
last_dir=/usr/home/jlhawkwell
[prjorg]
source_patterns=*.c;*.C;*.cpp;*.cxx;*.c++;*.cc;*.m;
header_patterns=*.h;*.H;*.hpp;*.hxx;*.h++;*.hh;
ignored_dirs_patterns=.*;CVS;
ignored_file_patterns=*.o;*.obj;*.a;*.lib;*.so;*.dll;*.lo;*.la;*.class;*.jar;*.pyc;*.mo;*.gmo;
generate_tag_prefs=0
external_dirs=
[build-menu]
EX_00_LB=_Execute
EX_00_CM="./test_NitroWin.sh"
EX_00_WD=
...@@ -65,3 +65,5 @@ nbactions.xml ...@@ -65,3 +65,5 @@ nbactions.xml
# End of https://www.gitignore.io/api/git,c++,cmake,netbeans,kdevelop4 # End of https://www.gitignore.io/api/git,c++,cmake,netbeans,kdevelop4
*.core
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<buildCommandWorkingDir>.</buildCommandWorkingDir> <buildCommandWorkingDir>.</buildCommandWorkingDir>
<buildCommand>${MAKE} -f Makefile</buildCommand> <buildCommand>${MAKE} -f Makefile</buildCommand>
<cleanCommand>${MAKE} -f Makefile clean</cleanCommand> <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
<executablePath></executablePath> <executablePath>test_NitroWin.sh</executablePath>
<cTool> <cTool>
<standard>10</standard> <standard>10</standard>
</cTool> </cTool>
......
...@@ -65,15 +65,17 @@ void NUtils::frameWindow (Window w, bool pre_exist) { ...@@ -65,15 +65,17 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
XReparentWindow(NWMAction::disp, w, frame, 25, 0); XReparentWindow(NWMAction::disp, w, frame, 25, 0);
XMapWindow(NWMAction::disp, frame); XMapWindow(NWMAction::disp, frame);
(*NWMAction::clients)[w] = frame; (*NWMAction::clients)[w] = frame;
(*NWMAction::rclients)[frame] = w;
(*NWMAction::frames)[titlebar] = frame; (*NWMAction::frames)[titlebar] = frame;
(*NWMAction::rframes)[frame] = titlebar;
std::cout << "NitroWin window " << frame; std::cout << "NitroWin window " << frame;
char *name = getName(NWMAction::disp, w); char *name = getName(NWMAction::disp, w);
if (name != nullptr) { std::cout << " (" << name << ")"; } if (name != nullptr) { std::cout << " (" << name << ")"; }
std::cout << std::endl; std::cout << std::endl;
XGrabButton(NWMAction::disp, Button1, 0, titlebar, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(NWMAction::disp, Button1, 0, titlebar, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, titlebar, None);
XGrabButton(NWMAction::disp, Button1, Mod2Mask, titlebar, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None); XGrabButton(NWMAction::disp, Button1, Mod2Mask, titlebar, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, titlebar, None);
XGrabButton(NWMAction::disp, Button1, Mod1Mask, w, 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, Button1, Mod1Mask | Mod2Mask, w, false, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, GrabModeAsync, None, None);
...@@ -88,14 +90,25 @@ void NUtils::frameWindow (Window w, bool pre_exist) { ...@@ -88,14 +90,25 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
void NUtils::unFrameWindow (Window w) { void NUtils::unFrameWindow (Window w) {
if (!NWMAction::clients->count(w)) { return; } if (!NWMAction::clients->count(w)) { return; }
Window frame = (*NWMAction::clients)[w]; Window frame = (*NWMAction::clients)[w];
Window titlebar = (*NWMAction::rframes)[frame];
XUnmapWindow(NWMAction::disp, frame); XUnmapWindow(NWMAction::disp, frame);
XUnmapWindow(NWMAction::disp, titlebar);
XReparentWindow(NWMAction::disp, w, *NWMAction::root, 0, 0); XReparentWindow(NWMAction::disp, w, *NWMAction::root, 0, 0);
XRemoveFromSaveSet(NWMAction::disp, w); XRemoveFromSaveSet(NWMAction::disp, w);
XDestroyWindow(NWMAction::disp, titlebar);
XDestroyWindow(NWMAction::disp, frame); XDestroyWindow(NWMAction::disp, frame);
NWMAction::clients->erase(w); NWMAction::clients->erase(w);
NWMAction::clients->erase(frame); NWMAction::rclients->erase(frame);
NWMAction::frames->erase(titlebar);
NWMAction::rframes->erase(frame);
XFlush(NWMAction::disp);
XFree(&titlebar);
XFree(&frame);
} }
std::string NUtils::getEventName(int event) { std::string NUtils::getEventName(int event) {
...@@ -141,7 +154,11 @@ std::string NUtils::getEventName(int event) { ...@@ -141,7 +154,11 @@ std::string NUtils::getEventName(int event) {
void NUtils::listWindows() { void NUtils::listWindows() {
std::cout << "NitroWin list:" << std::endl; std::cout << "NitroWin list:" << std::endl;
for (auto it : (*NWMAction::clients)) { for (auto it : (*NWMAction::clients)) {
std::cout << "\t" << it.first << " - " << it.second << std::endl; std::cout << "\t" << it.first << " - " << it.second;
if (NWMAction::rframes->count(it.second)) {
std::cout << " titlebar " << (*NWMAction::rframes)[it.second];
}
std::cout << std::endl;
} }
} }
...@@ -164,8 +181,8 @@ char * NUtils::getName(Display *disp, Window w) { ...@@ -164,8 +181,8 @@ char * NUtils::getName(Display *disp, Window w) {
} // */ } // */
bool NUtils::isNitroWin(Window w) { bool NUtils::isNitroWin(Window w) {
if (NWMAction::clients->count(w)) { return true; } if (NWMAction::clients->count(w) != 0) { return true; }
else if (NWMAction::frames->count(w)) { return true; } else if (NWMAction::frames->count(w) != 0) { return true; }
else { return false; } else { return false; }
} }
......
...@@ -48,6 +48,8 @@ Window *NWMAction::root; ...@@ -48,6 +48,8 @@ Window *NWMAction::root;
// WINDOWS // WINDOWS
std::unordered_map<Window, Window> *NWMAction::clients; std::unordered_map<Window, Window> *NWMAction::clients;
std::unordered_map<Window, Window> *NWMAction::frames; std::unordered_map<Window, Window> *NWMAction::frames;
std::unordered_map<Window, Window> *NWMAction::rclients;
std::unordered_map<Window, Window> *NWMAction::rframes;
void NWMAction::onKeyPress(XKeyPressedEvent e) { void NWMAction::onKeyPress(XKeyPressedEvent e) {
...@@ -64,8 +66,9 @@ void NWMAction::onButtonPress(XButtonPressedEvent e) { ...@@ -64,8 +66,9 @@ void NWMAction::onButtonPress(XButtonPressedEvent e) {
unsigned int w = 0, h = 0; unsigned int w = 0, h = 0;
unsigned int bw = 0, depth = 0; unsigned int bw = 0, depth = 0;
Window frame = NUtils::checkNitroWin(e.window); Window frame = NUtils::checkNitroWin(e.window);
if (frame == 0) { return; }
std::cout << "[ButtonPress] " << frame << std::endl; std::cout << "[ButtonPress] " << frame << " (" << NUtils::isNitroWin(e.window) << ", " << e.window << ")" << std::endl;
if (drag_start_cursor == nullptr) { if (drag_start_cursor == nullptr) {
drag_start_cursor = new NPosition<int>(e.x_root, e.y_root); drag_start_cursor = new NPosition<int>(e.x_root, e.y_root);
} }
...@@ -119,6 +122,7 @@ void NWMAction::onMotionNotify(XMotionEvent e) { ...@@ -119,6 +122,7 @@ void NWMAction::onMotionNotify(XMotionEvent e) {
std::cout << std::endl; // */ std::cout << std::endl; // */
Window frame = NUtils::checkNitroWin(e.window); Window frame = NUtils::checkNitroWin(e.window);
if (frame == 0) { return; }
NPosition<int> drag_pos(e.x_root, e.y_root); NPosition<int> drag_pos(e.x_root, e.y_root);
NPosition<int> delta = drag_pos - *drag_start_cursor; NPosition<int> delta = drag_pos - *drag_start_cursor;
...@@ -282,5 +286,6 @@ void NWMAction::onDefaultEvent(XAnyEvent e) { ...@@ -282,5 +286,6 @@ void NWMAction::onDefaultEvent(XAnyEvent e) {
} }
if (clients->count(e.window)) { std::cout << " (NitroWin)"; } if (clients->count(e.window)) { std::cout << " (NitroWin)"; }
std::cout << std::endl; std::cout << std::endl;
NUtils::listWindows();
} }
...@@ -54,8 +54,14 @@ public: ...@@ -54,8 +54,14 @@ public:
static Window *root; static Window *root;
// WINDOWS // WINDOWS
/* Maps clients to frames [client]=frame */
static std::unordered_map<Window, Window> *clients; static std::unordered_map<Window, Window> *clients;
/* Maps titlebars to frames [titlebar]=frame */
static std::unordered_map<Window, Window> *frames; static std::unordered_map<Window, Window> *frames;
/* Maps frames to clients [frame]=client */
static std::unordered_map<Window, Window> *rclients;
/* Maps frames to titlebars [frame]=titlebar */
static std::unordered_map<Window, Window> *rframes;
// EVENT METHODS // EVENT METHODS
static void onKeyPress(XKeyPressedEvent e); static void onKeyPress(XKeyPressedEvent e);
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include <iterator> #include <iterator>
#include <unordered_map> #include <unordered_map>
void printEventData(XEvent e);
bool NWManager::wm_detected = false; bool NWManager::wm_detected = false;
NWManager::NWManager() { NWManager::NWManager() {
...@@ -53,6 +51,8 @@ NWManager::NWManager() { ...@@ -53,6 +51,8 @@ NWManager::NWManager() {
clients = new std::unordered_map<Window, Window>(); clients = new std::unordered_map<Window, Window>();
frames = new std::unordered_map<Window, Window>(); frames = new std::unordered_map<Window, Window>();
rclients = new std::unordered_map<Window, Window>();
rframes = new std::unordered_map<Window, Window>();
} }
NWManager::~NWManager() { NWManager::~NWManager() {
...@@ -123,6 +123,8 @@ void NWManager::run() { ...@@ -123,6 +123,8 @@ void NWManager::run() {
NWMAction::root = root; NWMAction::root = root;
NWMAction::clients = clients; NWMAction::clients = clients;
NWMAction::frames = frames; NWMAction::frames = frames;
NWMAction::rclients = rclients;
NWMAction::rframes = rframes;
// main loop // main loop
XEvent e; XEvent e;
......
...@@ -45,6 +45,8 @@ public: ...@@ -45,6 +45,8 @@ public:
private: private:
std::unordered_map<Window, Window> *clients; std::unordered_map<Window, Window> *clients;
std::unordered_map<Window, Window> *frames; std::unordered_map<Window, Window> *frames;
std::unordered_map<Window, Window> *rclients;
std::unordered_map<Window, Window> *rframes;
bool keepGoing; bool keepGoing;
Display *disp; Display *disp;
Window *root; Window *root;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!