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 21f05b1f
authored
Mar 13, 2018
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding titlebar
1 parent
cccdfb03
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
7 deletions
src/NitroWin/NUtils.cpp
src/NitroWin/NUtils.h
src/NitroWin/NWMAction.cpp
src/NitroWin/NWMAction.h
src/NitroWin/NWManager.cpp
src/NitroWin/NWManager.h
src/NitroWin/NUtils.cpp
View file @
21f05b1
...
@@ -24,6 +24,13 @@
...
@@ -24,6 +24,13 @@
* POSSIBILITY OF SUCH DAMAGE.
* POSSIBILITY OF SUCH DAMAGE.
*/
*/
/*
* File: NUtils.cpp
* Author: jlhawkwell
*
* Created on March 10, 2018, 10:39 PM
*/
#include "NUtils.h"
#include "NUtils.h"
#include <X11/Xatom.h>
#include <X11/Xatom.h>
...
@@ -32,6 +39,8 @@ void NUtils::frameWindow (Window w) {
...
@@ -32,6 +39,8 @@ void NUtils::frameWindow (Window w) {
}
}
void
NUtils
::
frameWindow
(
Window
w
,
bool
pre_exist
)
{
void
NUtils
::
frameWindow
(
Window
w
,
bool
pre_exist
)
{
if
(
NWMAction
::
frames
->
count
(
w
))
{
return
;
}
const
unsigned
int
BORDER_WIDTH
=
3
;
const
unsigned
int
BORDER_WIDTH
=
3
;
const
unsigned
long
BORDER_COLOR
=
0xff0000
;
const
unsigned
long
BORDER_COLOR
=
0xff0000
;
const
unsigned
long
BG_COLOR
=
0x0000ff
;
const
unsigned
long
BG_COLOR
=
0x0000ff
;
...
@@ -44,24 +53,31 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
...
@@ -44,24 +53,31 @@ void NUtils::frameWindow (Window w, bool pre_exist) {
if
(
attrs
.
override_redirect
||
attrs
.
map_state
!=
IsViewable
)
{
return
;
}
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
);
Window
frame
=
XCreateSimpleWindow
(
NWMAction
::
disp
,
*
NWMAction
::
root
,
attrs
.
x
,
attrs
.
y
,
attrs
.
width
+
25
,
attrs
.
height
,
BORDER_WIDTH
,
BORDER_COLOR
,
BG_COLOR
);
XSelectInput
(
NWMAction
::
disp
,
frame
,
SubstructureRedirectMask
|
SubstructureNotifyMask
);
XSelectInput
(
NWMAction
::
disp
,
frame
,
SubstructureRedirectMask
|
SubstructureNotifyMask
);
XAddToSaveSet
(
NWMAction
::
disp
,
w
);
XAddToSaveSet
(
NWMAction
::
disp
,
w
);
XReparentWindow
(
NWMAction
::
disp
,
w
,
frame
,
0
,
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
::
frames
)[
frame
]
=
w
;
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
,
frame
,
false
,
ButtonPressMask
|
ButtonReleaseMask
|
ButtonMotionMask
,
GrabModeAsync
,
GrabModeAsync
,
None
,
None
);
XGrabButton
(
NWMAction
::
disp
,
Button1
,
Mod2Mask
,
frame
,
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
,
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
);
XGrabButton
(
NWMAction
::
disp
,
Button3
,
Mod1Mask
,
w
,
false
,
ButtonPressMask
|
ButtonReleaseMask
|
ButtonMotionMask
,
GrabModeAsync
,
GrabModeAsync
,
None
,
None
);
XGrabButton
(
NWMAction
::
disp
,
Button3
,
Mod1Mask
,
w
,
false
,
ButtonPressMask
|
ButtonReleaseMask
|
ButtonMotionMask
,
GrabModeAsync
,
GrabModeAsync
,
None
,
None
);
XGrabButton
(
NWMAction
::
disp
,
Button3
,
Mod1Mask
|
Mod2Mask
,
w
,
false
,
ButtonPressMask
|
ButtonReleaseMask
|
ButtonMotionMask
,
GrabModeAsync
,
GrabModeAsync
,
None
,
None
);
XGrabButton
(
NWMAction
::
disp
,
Button3
,
Mod1Mask
|
Mod2Mask
,
w
,
false
,
ButtonPressMask
|
ButtonReleaseMask
|
ButtonMotionMask
,
GrabModeAsync
,
GrabModeAsync
,
None
,
None
);
XMapWindow
(
NWMAction
::
disp
,
w
);
}
}
...
@@ -75,6 +91,7 @@ void NUtils::unFrameWindow (Window w) {
...
@@ -75,6 +91,7 @@ void NUtils::unFrameWindow (Window w) {
XRemoveFromSaveSet
(
NWMAction
::
disp
,
w
);
XRemoveFromSaveSet
(
NWMAction
::
disp
,
w
);
XDestroyWindow
(
NWMAction
::
disp
,
frame
);
XDestroyWindow
(
NWMAction
::
disp
,
frame
);
NWMAction
::
clients
->
erase
(
w
);
NWMAction
::
clients
->
erase
(
w
);
NWMAction
::
clients
->
erase
(
frame
);
}
}
std
::
string
NUtils
::
getEventName
(
int
event
)
{
std
::
string
NUtils
::
getEventName
(
int
event
)
{
...
@@ -127,3 +144,12 @@ char * NUtils::getName(Display *disp, Window w) {
...
@@ -127,3 +144,12 @@ char * NUtils::getName(Display *disp, Window w) {
XGetWindowProperty
(
disp
,
w
,
prop
,
0
,
1024
,
False
,
AnyPropertyType
,
&
type
,
&
form
,
&
len
,
&
remain
,
&
list
);
XGetWindowProperty
(
disp
,
w
,
prop
,
0
,
1024
,
False
,
AnyPropertyType
,
&
type
,
&
form
,
&
len
,
&
remain
,
&
list
);
return
(
char
*
)
list
;
return
(
char
*
)
list
;
}
}
void
NUtils
::
getName
(
Display
*
disp
,
Window
w
,
char
*
name
)
{
Atom
prop
=
XInternAtom
(
disp
,
"WM_NAME"
,
False
),
type
;
int
form
;
unsigned
long
remain
,
len
;
XSetWindowProperty
XGetWindowProperty
(
disp
,
w
,
prop
,
0
,
1024
,
False
,
AnyPropertyType
,
&
type
,
&
form
,
&
len
,
&
remain
,
&
list
);
return
(
char
*
)
list
;
}
src/NitroWin/NUtils.h
View file @
21f05b1
...
@@ -26,6 +26,13 @@
...
@@ -26,6 +26,13 @@
*
*
*/
*/
/*
* File: NUtils.h
* Author: jlhawkwell
*
* Created on March 10, 2018, 10:39 PM
*/
#ifndef NUTILS_H
#ifndef NUTILS_H
#define NUTILS_H
#define NUTILS_H
...
...
src/NitroWin/NWMAction.cpp
View file @
21f05b1
...
@@ -47,6 +47,7 @@ Window *NWMAction::root;
...
@@ -47,6 +47,7 @@ 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
;
void
NWMAction
::
onKeyPress
(
XKeyPressedEvent
e
)
{
void
NWMAction
::
onKeyPress
(
XKeyPressedEvent
e
)
{
...
@@ -57,7 +58,7 @@ void NWMAction::onKeyRelease(XKeyReleasedEvent e) {
...
@@ -57,7 +58,7 @@ void NWMAction::onKeyRelease(XKeyReleasedEvent e) {
}
}
void
NWMAction
::
onButtonPress
(
XButtonPressedEvent
e
)
{
void
NWMAction
::
onButtonPress
(
XButtonPressedEvent
e
)
{
if
(
!
clients
->
count
(
e
.
window
))
{
return
;
}
if
(
!
clients
->
count
(
e
.
window
)
&&
!
frames
->
count
(
e
.
window
)
)
{
return
;
}
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
);
}
}
...
@@ -92,7 +93,8 @@ void NWMAction::onButtonRelease(XButtonReleasedEvent e) {
...
@@ -92,7 +93,8 @@ void NWMAction::onButtonRelease(XButtonReleasedEvent e) {
}
}
void
NWMAction
::
onMotionNotify
(
XMotionEvent
e
)
{
void
NWMAction
::
onMotionNotify
(
XMotionEvent
e
)
{
if
(
!
clients
->
count
(
e
.
window
))
{
return
;
}
if
(
!
clients
->
count
(
e
.
window
)
&&
!
frames
->
count
(
e
.
window
))
{
return
;
}
std
::
cout
<<
"DEBUG NWMAction:97"
<<
std
::
endl
;
/*std::cout << "XMotionEvent: " << e.window;
/*std::cout << "XMotionEvent: " << e.window;
std::cout << " (" << e.x << ", " << e.y << "), (";
std::cout << " (" << e.x << ", " << e.y << "), (";
...
@@ -114,7 +116,13 @@ void NWMAction::onMotionNotify(XMotionEvent e) {
...
@@ -114,7 +116,13 @@ void NWMAction::onMotionNotify(XMotionEvent e) {
if (e.state & Mod5Mask) { std::cout << " Mod5Mask"; }
if (e.state & Mod5Mask) { std::cout << " Mod5Mask"; }
std::cout << std::endl; // */
std::cout << std::endl; // */
Window
frame
=
(
*
clients
)[
e
.
window
];
Window
frame
;
if
(
NWMAction
::
clients
->
count
(
e
.
window
))
{
frame
=
(
*
clients
)[
e
.
window
];
}
else
if
(
NWMAction
::
frames
->
count
(
e
.
window
))
{
frame
=
e
.
window
;
}
else
{
return
;
}
std
::
cout
<<
"DEBUG NWMAction:124"
<<
std
::
endl
;
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
;
...
@@ -185,8 +193,6 @@ void NWMAction::onMapNotify(XMapEvent e) {
...
@@ -185,8 +193,6 @@ void NWMAction::onMapNotify(XMapEvent e) {
void
NWMAction
::
onMapRequest
(
XMapRequestEvent
e
)
{
void
NWMAction
::
onMapRequest
(
XMapRequestEvent
e
)
{
NUtils
::
frameWindow
(
e
.
window
);
NUtils
::
frameWindow
(
e
.
window
);
XMapWindow
(
disp
,
e
.
window
);
}
}
void
NWMAction
::
onReparentNotify
(
XReparentEvent
e
)
{
void
NWMAction
::
onReparentNotify
(
XReparentEvent
e
)
{
...
...
src/NitroWin/NWMAction.h
View file @
21f05b1
...
@@ -55,6 +55,7 @@ public:
...
@@ -55,6 +55,7 @@ public:
// WINDOWS
// WINDOWS
static
std
::
unordered_map
<
Window
,
Window
>
*
clients
;
static
std
::
unordered_map
<
Window
,
Window
>
*
clients
;
static
std
::
unordered_map
<
Window
,
Window
>
*
frames
;
// EVENT METHODS
// EVENT METHODS
static
void
onKeyPress
(
XKeyPressedEvent
e
);
static
void
onKeyPress
(
XKeyPressedEvent
e
);
...
...
src/NitroWin/NWManager.cpp
View file @
21f05b1
...
@@ -52,6 +52,7 @@ NWManager::NWManager() {
...
@@ -52,6 +52,7 @@ NWManager::NWManager() {
}
}
clients
=
new
std
::
unordered_map
<
Window
,
Window
>
();
clients
=
new
std
::
unordered_map
<
Window
,
Window
>
();
frames
=
new
std
::
unordered_map
<
Window
,
Window
>
();
}
}
NWManager
::~
NWManager
()
{
NWManager
::~
NWManager
()
{
...
@@ -123,6 +124,7 @@ void NWManager::run() {
...
@@ -123,6 +124,7 @@ void NWManager::run() {
NWMAction
::
disp
=
disp
;
NWMAction
::
disp
=
disp
;
NWMAction
::
root
=
root
;
NWMAction
::
root
=
root
;
NWMAction
::
clients
=
clients
;
NWMAction
::
clients
=
clients
;
NWMAction
::
frames
=
frames
;
// main loop
// main loop
XEvent
e
;
XEvent
e
;
...
...
src/NitroWin/NWManager.h
View file @
21f05b1
...
@@ -44,6 +44,7 @@ public:
...
@@ -44,6 +44,7 @@ public:
private
:
private
:
std
::
unordered_map
<
Window
,
Window
>
*
clients
;
std
::
unordered_map
<
Window
,
Window
>
*
clients
;
std
::
unordered_map
<
Window
,
Window
>
*
frames
;
bool
keepGoing
;
bool
keepGoing
;
Display
*
disp
;
Display
*
disp
;
Window
*
root
;
Window
*
root
;
...
...
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