|
@@ -1,8 +1,8 @@
|
1
|
1
|
#include "x.hpp"
|
2
|
2
|
|
3
|
|
-slrn::XEngine* xengine = new slrn::XEngine();
|
|
3
|
+slop::XEngine* xengine = new slop::XEngine();
|
4
|
4
|
|
5
|
|
-slrn::XEngine::XEngine() {
|
|
5
|
+slop::XEngine::XEngine() {
|
6
|
6
|
m_keypressed = false;
|
7
|
7
|
m_display = NULL;
|
8
|
8
|
m_visual = NULL;
|
|
@@ -13,7 +13,7 @@ slrn::XEngine::XEngine() {
|
13
|
13
|
m_hoverXWindow = None;
|
14
|
14
|
}
|
15
|
15
|
|
16
|
|
-slrn::XEngine::~XEngine() {
|
|
16
|
+slop::XEngine::~XEngine() {
|
17
|
17
|
if ( !m_good ) {
|
18
|
18
|
return;
|
19
|
19
|
}
|
|
@@ -29,11 +29,11 @@ slrn::XEngine::~XEngine() {
|
29
|
29
|
}
|
30
|
30
|
|
31
|
31
|
// We need to keep track of the rectangle windows, so that they don't override our "focus"d windows.
|
32
|
|
-void slrn::XEngine::addRect( Rectangle* rect ) {
|
|
32
|
+void slop::XEngine::addRect( Rectangle* rect ) {
|
33
|
33
|
m_rects.push_back( rect );
|
34
|
34
|
}
|
35
|
35
|
|
36
|
|
-void slrn::XEngine::removeRect( Rectangle* rect ) {
|
|
36
|
+void slop::XEngine::removeRect( Rectangle* rect ) {
|
37
|
37
|
for ( unsigned int i=0; i<m_rects.size(); i++ ) {
|
38
|
38
|
if ( m_rects.at( i ) == rect ) {
|
39
|
39
|
m_rects.erase( m_rects.begin() + i );
|
|
@@ -44,14 +44,14 @@ void slrn::XEngine::removeRect( Rectangle* rect ) {
|
44
|
44
|
}
|
45
|
45
|
}
|
46
|
46
|
|
47
|
|
-bool slrn::XEngine::mouseDown( unsigned int button ) {
|
|
47
|
+bool slop::XEngine::mouseDown( unsigned int button ) {
|
48
|
48
|
if ( button >= m_mouse.size() ) {
|
49
|
49
|
return false;
|
50
|
50
|
}
|
51
|
51
|
return m_mouse.at( button );
|
52
|
52
|
}
|
53
|
53
|
|
54
|
|
-int slrn::XEngine::init( std::string display ) {
|
|
54
|
+int slop::XEngine::init( std::string display ) {
|
55
|
55
|
// Initialize display
|
56
|
56
|
m_display = XOpenDisplay( display.c_str() );
|
57
|
57
|
if ( !m_display ) {
|
|
@@ -67,7 +67,7 @@ int slrn::XEngine::init( std::string display ) {
|
67
|
67
|
return 0;
|
68
|
68
|
}
|
69
|
69
|
|
70
|
|
-int slrn::XEngine::grabKeyboard() {
|
|
70
|
+int slop::XEngine::grabKeyboard() {
|
71
|
71
|
if ( !m_good ) {
|
72
|
72
|
return 1;
|
73
|
73
|
}
|
|
@@ -75,13 +75,13 @@ int slrn::XEngine::grabKeyboard() {
|
75
|
75
|
GrabModeAsync, GrabModeAsync, CurrentTime );
|
76
|
76
|
if ( err != GrabSuccess ) {
|
77
|
77
|
fprintf( stderr, "Error: Failed to grab X keyboard.\n" );
|
78
|
|
- fprintf( stderr, "This can be caused by launching slrn incorrectly.\n" );
|
|
78
|
+ fprintf( stderr, "This can be caused by launching slop incorrectly.\n" );
|
79
|
79
|
fprintf( stderr, "gnome-session launches it fine from keyboard binds.\n" );
|
80
|
80
|
return 1;
|
81
|
81
|
}
|
82
|
82
|
}
|
83
|
83
|
|
84
|
|
-int slrn::XEngine::releaseKeyboard() {
|
|
84
|
+int slop::XEngine::releaseKeyboard() {
|
85
|
85
|
if ( !m_good ) {
|
86
|
86
|
return 1;
|
87
|
87
|
}
|
|
@@ -90,7 +90,7 @@ int slrn::XEngine::releaseKeyboard() {
|
90
|
90
|
}
|
91
|
91
|
|
92
|
92
|
// Grabs the cursor, be wary that setCursor changes the mouse masks.
|
93
|
|
-int slrn::XEngine::grabCursor( slrn::CursorType type ) {
|
|
93
|
+int slop::XEngine::grabCursor( slop::CursorType type ) {
|
94
|
94
|
if ( !m_good ) {
|
95
|
95
|
return 1;
|
96
|
96
|
}
|
|
@@ -100,7 +100,7 @@ int slrn::XEngine::grabCursor( slrn::CursorType type ) {
|
100
|
100
|
GrabModeAsync, GrabModeAsync, m_root, xfontcursor, CurrentTime );
|
101
|
101
|
if ( err != GrabSuccess ) {
|
102
|
102
|
fprintf( stderr, "Error: Failed to grab X cursor.\n" );
|
103
|
|
- fprintf( stderr, "This can be caused by launching slrn incorrectly.\n" );
|
|
103
|
+ fprintf( stderr, "This can be caused by launching slop incorrectly.\n" );
|
104
|
104
|
fprintf( stderr, "gnome-session launches it fine from keyboard binds.\n" );
|
105
|
105
|
return 1;
|
106
|
106
|
}
|
|
@@ -119,7 +119,7 @@ int slrn::XEngine::grabCursor( slrn::CursorType type ) {
|
119
|
119
|
return 0;
|
120
|
120
|
}
|
121
|
121
|
|
122
|
|
-int slrn::XEngine::releaseCursor() {
|
|
122
|
+int slop::XEngine::releaseCursor() {
|
123
|
123
|
if ( !m_good ) {
|
124
|
124
|
return 1;
|
125
|
125
|
}
|
|
@@ -127,7 +127,7 @@ int slrn::XEngine::releaseCursor() {
|
127
|
127
|
return 0;
|
128
|
128
|
}
|
129
|
129
|
|
130
|
|
-void slrn::XEngine::tick() {
|
|
130
|
+void slop::XEngine::tick() {
|
131
|
131
|
if ( !m_good ) {
|
132
|
132
|
return;
|
133
|
133
|
}
|
|
@@ -180,7 +180,7 @@ void slrn::XEngine::tick() {
|
180
|
180
|
}
|
181
|
181
|
|
182
|
182
|
// This converts an enum into a preallocated cursor, the cursor will automatically deallocate itself on ~XEngine
|
183
|
|
-Cursor slrn::XEngine::getCursor( slrn::CursorType type ) {
|
|
183
|
+Cursor slop::XEngine::getCursor( slop::CursorType type ) {
|
184
|
184
|
int xfontcursor;
|
185
|
185
|
switch ( type ) {
|
186
|
186
|
default:
|
|
@@ -205,7 +205,7 @@ Cursor slrn::XEngine::getCursor( slrn::CursorType type ) {
|
205
|
205
|
}
|
206
|
206
|
|
207
|
207
|
// Swaps out the current cursor, bewary that XChangeActivePointerGrab also resets masks, so if you change the mouse masks on grab you need to change them here too.
|
208
|
|
-void slrn::XEngine::setCursor( slrn::CursorType type ) {
|
|
208
|
+void slop::XEngine::setCursor( slop::CursorType type ) {
|
209
|
209
|
if ( !m_good ) {
|
210
|
210
|
return;
|
211
|
211
|
}
|
|
@@ -215,7 +215,7 @@ void slrn::XEngine::setCursor( slrn::CursorType type ) {
|
215
|
215
|
xfontcursor, CurrentTime );
|
216
|
216
|
}
|
217
|
217
|
|
218
|
|
-slrn::Rectangle::~Rectangle() {
|
|
218
|
+slop::Rectangle::~Rectangle() {
|
219
|
219
|
//XFreeGC( xengine->m_display, m_gc );
|
220
|
220
|
if ( m_window == None ) {
|
221
|
221
|
return;
|
|
@@ -225,7 +225,7 @@ slrn::Rectangle::~Rectangle() {
|
225
|
225
|
XDestroyWindow( xengine->m_display, m_window );
|
226
|
226
|
}
|
227
|
227
|
|
228
|
|
-slrn::Rectangle::Rectangle( int x, int y, int width, int height, int border, int padding, float r, float g, float b ) {
|
|
228
|
+slop::Rectangle::Rectangle( int x, int y, int width, int height, int border, int padding, float r, float g, float b ) {
|
229
|
229
|
m_xoffset = 0;
|
230
|
230
|
m_yoffset = 0;
|
231
|
231
|
m_x = x;
|
|
@@ -274,7 +274,7 @@ slrn::Rectangle::Rectangle( int x, int y, int width, int height, int border, int
|
274
|
274
|
XMapWindow( xengine->m_display, m_window );
|
275
|
275
|
}
|
276
|
276
|
|
277
|
|
-void slrn::Rectangle::setPos( int x, int y ) {
|
|
277
|
+void slop::Rectangle::setPos( int x, int y ) {
|
278
|
278
|
if ( m_x == x && m_y == y ) {
|
279
|
279
|
return;
|
280
|
280
|
}
|
|
@@ -287,7 +287,7 @@ void slrn::Rectangle::setPos( int x, int y ) {
|
287
|
287
|
XMoveWindow( xengine->m_display, m_window, m_x+m_xoffset, m_y+m_yoffset );
|
288
|
288
|
}
|
289
|
289
|
|
290
|
|
-void slrn::Rectangle::setDim( int w, int h ) {
|
|
290
|
+void slop::Rectangle::setDim( int w, int h ) {
|
291
|
291
|
if ( m_width == w && m_height == h ) {
|
292
|
292
|
return;
|
293
|
293
|
}
|
|
@@ -314,7 +314,7 @@ void slrn::Rectangle::setDim( int w, int h ) {
|
314
|
314
|
XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0);
|
315
|
315
|
}
|
316
|
316
|
|
317
|
|
-void slrn::XEngine::updateHoverWindow() {
|
|
317
|
+void slop::XEngine::updateHoverWindow() {
|
318
|
318
|
Window root, child;
|
319
|
319
|
int mx, my;
|
320
|
320
|
int wx, wy;
|
|
@@ -343,7 +343,7 @@ void slrn::XEngine::updateHoverWindow() {
|
343
|
343
|
&(m_hoverWindow.m_border), &depth );
|
344
|
344
|
}
|
345
|
345
|
|
346
|
|
-void slrn::XEngine::updateHoverWindow( Window child ) {
|
|
346
|
+void slop::XEngine::updateHoverWindow( Window child ) {
|
347
|
347
|
// Same thing as updateHoverWindow but it uses the specified child.
|
348
|
348
|
// It's used when we first grab the cursor so it's slightly more effecient
|
349
|
349
|
// than calling XQueryPointer twice.
|
|
@@ -369,7 +369,7 @@ void slrn::XEngine::updateHoverWindow( Window child ) {
|
369
|
369
|
|
370
|
370
|
// Keeps our rectangle's sizes all positive, so Xlib doesn't throw an exception.
|
371
|
371
|
// It also keeps our values in absolute coordinates which is nice.
|
372
|
|
-void slrn::Rectangle::constrain( int w, int h ) {
|
|
372
|
+void slop::Rectangle::constrain( int w, int h ) {
|
373
|
373
|
int pad = m_padding;
|
374
|
374
|
if ( pad < 0 && std::abs( w ) < std::abs( pad )*2 ) {
|
375
|
375
|
pad = 0;
|
|
@@ -399,7 +399,7 @@ void slrn::Rectangle::constrain( int w, int h ) {
|
399
|
399
|
}
|
400
|
400
|
}
|
401
|
401
|
|
402
|
|
-int slrn::Rectangle::convertColor( float r, float g, float b ) {
|
|
402
|
+int slop::Rectangle::convertColor( float r, float g, float b ) {
|
403
|
403
|
// Convert float colors to shorts.
|
404
|
404
|
short red = short( floor( r * 65535.f ) );
|
405
|
405
|
short green = short( floor( g * 65535.f ) );
|