Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jessica Hawkwell
/
nitrogen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2bc74163
authored
Mar 13, 2018
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
did some stuffs
1 parent
293a9c20
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
117 additions
and
16 deletions
.geanyprj
nbproject/configurations.xml
src/NitroWin/NPosition.h
src/NitroWin/NUtils.cpp
src/NitroWin/NUtils.h
src/NitroWin/NWMAction.cpp
src/NitroWin/NWMAction.h
src/NitroWin/NWManager.cpp
src/NitroWin/NWManager.h
.geanyprj
0 → 100644
View file @
2bc7416
[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=0;C++;0;EUTF-8;1;1;0;%2Fusr%2Fhome%2Fjlhawkwell%2FProjects%2FNitrogen%2Fsrc%2FNitroWin%2FNUtils.cpp;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=
nbproject/configurations.xml
View file @
2bc7416
...
...
@@ -55,7 +55,7 @@
<confs>
<conf
name=
"Default"
type=
"0"
platformSpecific=
"true"
>
<toolsSet>
<compilerSet>
default
</compilerSet>
<compilerSet>
CLang|CLang
</compilerSet>
<platform>
5
</platform>
<dependencyChecking>
false
</dependencyChecking>
<rebuildPropChanged>
false
</rebuildPropChanged>
...
...
@@ -68,6 +68,12 @@
<buildCommand>
${MAKE} -f Makefile
</buildCommand>
<cleanCommand>
${MAKE} -f Makefile clean
</cleanCommand>
<executablePath></executablePath>
<cTool>
<standard>
10
</standard>
</cTool>
<ccTool>
<standard>
11
</standard>
</ccTool>
</makeTool>
<preBuild>
<preBuildCommandWorkingDir>
.
</preBuildCommandWorkingDir>
...
...
src/NitroWin/NPosition.h
View file @
2bc7416
src/NitroWin/NUtils.cpp
View file @
2bc7416
...
...
@@ -25,6 +25,7 @@
*/
#include "NUtils.h"
#include <X11/Xatom.h>
void
NUtils
::
frameWindow
(
Window
w
)
{
frameWindow
(
w
,
false
);
...
...
@@ -53,6 +54,10 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
XMapWindow
(
NWMAction
::
disp
,
frame
);
(
*
NWMAction
::
clients
)[
w
]
=
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
,
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
);
...
...
@@ -61,6 +66,7 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
void
NUtils
::
unFrameWindow
(
Window
w
)
{
if
(
!
NWMAction
::
clients
->
count
(
w
))
{
return
;
}
Window
frame
=
(
*
NWMAction
::
clients
)[
w
];
XUnmapWindow
(
NWMAction
::
disp
,
frame
);
...
...
@@ -111,3 +117,13 @@ std::string NUtils::getEventName(int event) {
default
:
return
"Unknown"
;
break
;
}
}
char
*
NUtils
::
getName
(
Display
*
disp
,
Window
w
)
{
Atom
prop
=
XInternAtom
(
disp
,
"WM_NAME"
,
False
),
type
;
int
form
;
unsigned
long
remain
,
len
;
unsigned
char
*
list
;
XGetWindowProperty
(
disp
,
w
,
prop
,
0
,
1024
,
False
,
AnyPropertyType
,
&
type
,
&
form
,
&
len
,
&
remain
,
&
list
);
return
(
char
*
)
list
;
}
src/NitroWin/NUtils.h
View file @
2bc7416
...
...
@@ -30,6 +30,9 @@
#define NUTILS_H
#include "NWMAction.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/X.h>
#include <iostream>
class
NUtils
{
...
...
@@ -38,6 +41,7 @@ public:
static
void
frameWindow
(
Window
w
,
bool
pre_exist
);
static
void
unFrameWindow
(
Window
w
);
static
std
::
string
getEventName
(
int
event
);
static
char
*
getName
(
Display
*
disp
,
Window
w
);
};
#endif // NUTILS_H
src/NitroWin/NWMAction.cpp
View file @
2bc7416
...
...
@@ -34,7 +34,7 @@
#include "NWMAction.h"
#include "NUtils.h"
#include <iostream>
#include <vector>
//
#include <vector>
// MOVING WINDOWS
NPosition
<
int
>
*
NWMAction
::
drag_start_cursor
;
...
...
@@ -94,7 +94,7 @@ void NWMAction::onButtonRelease(XButtonReleasedEvent e) {
void
NWMAction
::
onMotionNotify
(
XMotionEvent
e
)
{
if
(
!
clients
->
count
(
e
.
window
))
{
return
;
}
std
::
cout
<<
"XMotionEvent: "
<<
e
.
window
;
/*
std::cout << "XMotionEvent: " << e.window;
std::cout << " (" << e.x << ", " << e.y << "), (";
std::cout << e.x_root << ", " << e.y_root << ") ";
std::cout << e.state;
...
...
@@ -112,14 +112,13 @@ void NWMAction::onMotionNotify(XMotionEvent e) {
if (e.state & Mod3Mask) { std::cout << " Mod3Mask"; }
if (e.state & Mod4Mask) { std::cout << " Mod4Mask"; }
if (e.state & Mod5Mask) { std::cout << " Mod5Mask"; }
std
::
cout
<<
std
::
endl
;
std::cout << std::endl;
// */
Window
frame
=
(
*
clients
)[
e
.
window
];
NPosition
<
int
>
drag_pos
(
e
.
x_root
,
e
.
y_root
);
NPosition
<
int
>
delta
=
drag_pos
-
*
drag_start_cursor
;
if
(
e
.
state
&
Button1Mask
)
{
// move window
std
::
cout
<<
"
\t
Delta: "
<<
delta
.
toString
()
<<
std
::
endl
;
NPosition
<
int
>
dest
=
delta
+
*
drag_start_window
;
dest
.
setZeroIfNegative
();
XMoveWindow
(
disp
,
frame
,
dest
.
getX
(),
dest
.
getY
());
...
...
@@ -168,7 +167,8 @@ void NWMAction::onCreateNotify(XCreateWindowEvent e) {
}
void
NWMAction
::
onDestroyNotify
(
XDestroyWindowEvent
e
)
{
if
(
clients
->
count
(
e
.
window
))
{
NUtils
::
unFrameWindow
(
e
.
window
);
}
if
(
clients
->
count
(
e
.
event
))
{
NUtils
::
unFrameWindow
(
e
.
event
);
}
}
void
NWMAction
::
onUnmapNotify
(
XUnmapEvent
e
)
{
...
...
@@ -267,11 +267,15 @@ void NWMAction::onGenericEvent(XGenericEvent e) {
}
void
NWMAction
::
onLASTEvent
(
XAnyEvent
e
)
{
onDefaultEvent
(
e
);
}
void
NWMAction
::
onDefaultEvent
(
XAnyEvent
e
)
{
std
::
cout
<<
"Event ["
<<
NUtils
::
getEventName
(
e
.
type
)
<<
"] on "
;
std
::
cout
<<
e
.
window
<<
" @ "
<<
e
.
display
<<
std
::
endl
;
std
::
cout
<<
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
;
}
src/NitroWin/NWMAction.h
View file @
2bc7416
...
...
@@ -38,8 +38,8 @@
#include <vector>
#include <unordered_map>
#
include "NPosition.h"
#
include "NSize.h"
#include "NPosition.h"
#include "NSize.h"
class
NWMAction
{
protected
:
...
...
src/NitroWin/NWManager.cpp
View file @
2bc7416
...
...
@@ -29,6 +29,8 @@
#include "NUtils.h"
#include <iostream>
#include <iterator>
#include <unordered_map>
void
printEventData
(
XEvent
e
);
...
...
@@ -53,6 +55,9 @@ NWManager::NWManager() {
}
NWManager
::~
NWManager
()
{
for
(
auto
it
:
(
NWMAction
::
clients
))
{
NUtils
::
unFrameWindow
(
it
.
first
);
}
XCloseDisplay
(
disp
);
}
...
...
@@ -70,9 +75,18 @@ int NWManager::OnXError(Display *display, XErrorEvent *e) {
XGetErrorText
(
display
,
e
->
error_code
,
error_text
,
sizeof
(
error_text
));
std
::
cerr
<<
"Received X error:"
<<
std
::
endl
<<
" Request: "
<<
int
(
e
->
request_code
)
<<
std
::
endl
<<
" Error code: "
<<
int
(
e
->
error_code
)
<<
" Error code: "
<<
int
(
e
->
error_code
)
<<
"."
<<
int
(
e
->
minor_code
)
<<
" - "
<<
error_text
<<
std
::
endl
<<
" Resource ID: "
<<
e
->
resourceid
<<
std
::
endl
;
for
(
auto
it
:
(
*
NWMAction
::
clients
))
{
std
::
cout
<<
"
\t
"
<<
it
.
first
<<
" - "
<<
it
.
second
<<
std
::
endl
;
}
/*NWMAction::clients->begin();
while (!NWMAction::clients->empty()) {
NWMAction::clients->
std::cout << "\t" << (*NWMAction::clients){} << std::endl;
} // */
return
0
;
}
...
...
@@ -115,6 +129,13 @@ void NWManager::run() {
while
(
keepGoing
)
{
XNextEvent
(
disp
,
&
e
);
onLoop
(
e
);
}
}
void
NWManager
::
stop
()
{
keepGoing
=
false
;
}
void
NWManager
::
onLoop
(
XEvent
e
)
{
switch
(
e
.
type
)
{
//case KeyPress: break;
//case KeyRelease: break;
...
...
@@ -131,12 +152,12 @@ void NWManager::run() {
//case NoExpose: break;
//case VisibilityNotify: break;
//case CreateNotify: break; /* ignore this */
//case DestroyNotify:
break; /* ignore this */
case
DestroyNotify
:
NWMAction
::
onDestroyNotify
(
e
.
xdestroywindow
);
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
ConfigureNotify
:
break
;
/* ignore this */
case
ConfigureRequest
:
NWMAction
::
onConfigureRequest
(
e
.
xconfigurerequest
);
break
;
//case GravityNotify: break;
//case ResizeRequest: break;
...
...
@@ -153,7 +174,4 @@ void NWManager::run() {
//case LASTEvent: break;
default:
NWMAction
::
onDefaultEvent
(
e
.
xany
);
break
;
}
}
}
void
NWManager
::
stop
()
{
keepGoing
=
false
;
}
src/NitroWin/NWManager.h
View file @
2bc7416
...
...
@@ -47,6 +47,8 @@ private:
bool
keepGoing
;
Display
*
disp
;
Window
*
root
;
static
void
onLoop
(
XEvent
e
);
};
#endif
/* NWMANAGER_H */
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment