Browse Source

name change, slrn was taken by some guy from 1994

naelstrof 11 years ago
parent
commit
09205e1be1
7 changed files with 66 additions and 66 deletions
  1. 11
    11
      README.md
  2. 11
    11
      main.cpp
  3. 2
    2
      makefile
  4. 11
    11
      options.cpp
  5. 2
    2
      options.hpp
  6. 24
    24
      x.cpp
  7. 5
    5
      x.hpp

+ 11
- 11
README.md View File

1
-slrn
1
+slop
2
 ====
2
 ====
3
 
3
 
4
-slrn (Select Region) is an application that querys for a selection from the user and prints the region to stdout. It grabs the mouse and turns it into a crosshair, lets the user click and drag to make a selection (or click on a window) while drawing a pretty box around it, then finally prints the selection's dimensions to stdout.
4
+slop (Select Operation) is an application that querys for a selection from the user and prints the region to stdout. It grabs the mouse and turns it into a crosshair, lets the user click and drag to make a selection (or click on a window) while drawing a pretty box around it, then finally prints the selection's dimensions to stdout.
5
 
5
 
6
 features
6
 features
7
 --------
7
 --------
8
 * Hovering over a window will cause a selection rectangle to appear over it.
8
 * Hovering over a window will cause a selection rectangle to appear over it.
9
-* Clicking on a window makes slrn return the dimensions of the window.
9
+* Clicking on a window makes slop return the dimensions of the window.
10
 * Clicking and dragging causes a selection rectangle to appear, renders pretty well (compared to scrot). And will return the dimensions of that rectangle in absolute screen coords.
10
 * Clicking and dragging causes a selection rectangle to appear, renders pretty well (compared to scrot). And will return the dimensions of that rectangle in absolute screen coords.
11
 * On startup it turns your cursor into a crosshair, then adjusts the cursor into angles as you drag the selection rectangle.
11
 * On startup it turns your cursor into a crosshair, then adjusts the cursor into angles as you drag the selection rectangle.
12
 * Supports simple arguments:
12
 * Supports simple arguments:
18
 
18
 
19
 practical applications
19
 practical applications
20
 ----------------------
20
 ----------------------
21
-slrn can be used to create a video recording script in only two lines of code.
21
+slop can be used to create a video recording script in only two lines of code.
22
 ```bash
22
 ```bash
23
 #!/bin/bash
23
 #!/bin/bash
24
-eval `slrn`
24
+eval `slop`
25
 ffmpeg -f x11grab -s "$W"x"$H" -i :0.0+$X,$Y -f alsa -i pulse ~/myfile.webm
25
 ffmpeg -f x11grab -s "$W"x"$H" -i :0.0+$X,$Y -f alsa -i pulse ~/myfile.webm
26
 ```
26
 ```
27
-slrn lets you select a region or window and ffmpeg will record it in the format of your choice!
27
+slop lets you select a region or window and ffmpeg will record it in the format of your choice!
28
 Combined with keybinds and a server on your filesystem you can make a really neat and unobtrusive screenshooter.
28
 Combined with keybinds and a server on your filesystem you can make a really neat and unobtrusive screenshooter.
29
 
29
 
30
 You can also take images using imagemagick like so:
30
 You can also take images using imagemagick like so:
31
 ```bash
31
 ```bash
32
 #!/bin/bash
32
 #!/bin/bash
33
-eval `slrn`
33
+eval `slop`
34
 import -window root -crop "$W"x"$H"+$X+$Y ~/myimage.png
34
 import -window root -crop "$W"x"$H"+$X+$Y ~/myimage.png
35
 ```
35
 ```
36
 
36
 
37
 lets see some action
37
 lets see some action
38
 --------------------
38
 --------------------
39
-Ok. Here's a comparison between 'scrot -s's selection and slrn's:
40
-![scrot](http://farmpolice.com/content/images/scrot_bad.png)
41
-![slrn](http://farmpolice.com/content/images/slrn_good.png)
39
+Ok. Here's a comparison between 'scrot -s's selection and slop's:
40
+![scrotbad](http://farmpolice.com/content/images/scrot_bad.png)
41
+![slopgood](http://farmpolice.com/content/images/slrn_good.png)
42
 
42
 
43
 You can see scrot leaves garbage lines over the things you're trying to screenshot!
43
 You can see scrot leaves garbage lines over the things you're trying to screenshot!
44
-While slrn not only looks nicer, it's impossible for it to end up in screenshots or recordings because it shuts down before ffmpeg or imagemagick can take a picture.
44
+While slop not only looks nicer, it's impossible for it to end up in screenshots or recordings because it shuts down before ffmpeg or imagemagick can take a picture.

+ 11
- 11
main.cpp View File

10
     }
10
     }
11
     int state = 0;
11
     int state = 0;
12
     bool running = true;
12
     bool running = true;
13
-    slrn::Rectangle* selection;
14
-    slrn::Rectangle* windowselection = NULL;
13
+    slop::Rectangle* selection;
14
+    slop::Rectangle* windowselection = NULL;
15
     Window window = None;
15
     Window window = None;
16
     std::string xdisplay = options->m_xdisplay;
16
     std::string xdisplay = options->m_xdisplay;
17
     int padding = options->m_padding;
17
     int padding = options->m_padding;
27
     if ( err ) {
27
     if ( err ) {
28
         return err;
28
         return err;
29
     }
29
     }
30
-    err = xengine->grabCursor( slrn::Cross );
30
+    err = xengine->grabCursor( slop::Cross );
31
     if ( err ) {
31
     if ( err ) {
32
         return err;
32
         return err;
33
     }
33
     }
70
                     if ( windowselection ) {
70
                     if ( windowselection ) {
71
                         xengine->removeRect( windowselection ); // removeRect also dealloc's the rectangle for us.
71
                         xengine->removeRect( windowselection ); // removeRect also dealloc's the rectangle for us.
72
                     }
72
                     }
73
-                    slrn::WindowRectangle t = xengine->m_hoverWindow;
74
-                    windowselection = new slrn::Rectangle( t.m_x - t.m_border,
73
+                    slop::WindowRectangle t = xengine->m_hoverWindow;
74
+                    windowselection = new slop::Rectangle( t.m_x - t.m_border,
75
                                                          t.m_y - t.m_border,
75
                                                          t.m_y - t.m_border,
76
                                                          t.m_width + t.m_border,
76
                                                          t.m_width + t.m_border,
77
                                                          t.m_height + t.m_border,
77
                                                          t.m_height + t.m_border,
93
             case 1: {
93
             case 1: {
94
                 // Simply create a new rectangle at the mouse position and move on
94
                 // Simply create a new rectangle at the mouse position and move on
95
                 // to the next state.
95
                 // to the next state.
96
-                selection = new slrn::Rectangle( xengine->m_mousex, xengine->m_mousey, 0, 0, borderSize, padding, r, g, b );
96
+                selection = new slop::Rectangle( xengine->m_mousex, xengine->m_mousey, 0, 0, borderSize, padding, r, g, b );
97
                 xengine->addRect( selection );
97
                 xengine->addRect( selection );
98
                 state++;
98
                 state++;
99
                 break;
99
                 break;
113
                 bool x = selection->m_flippedx;
113
                 bool x = selection->m_flippedx;
114
                 bool y = selection->m_flippedy;
114
                 bool y = selection->m_flippedy;
115
                 if ( !x && !y ) {
115
                 if ( !x && !y ) {
116
-                    xengine->setCursor( slrn::LowerRightCorner );
116
+                    xengine->setCursor( slop::LowerRightCorner );
117
                 } else if ( x && !y ) {
117
                 } else if ( x && !y ) {
118
-                    xengine->setCursor( slrn::LowerLeftCorner );
118
+                    xengine->setCursor( slop::LowerLeftCorner );
119
                 } else if ( !x && y ) {
119
                 } else if ( !x && y ) {
120
-                    xengine->setCursor( slrn::UpperRightCorner );
120
+                    xengine->setCursor( slop::UpperRightCorner );
121
                 } else {
121
                 } else {
122
-                    xengine->setCursor( slrn::UpperLeftCorner );
122
+                    xengine->setCursor( slop::UpperLeftCorner );
123
                 }
123
                 }
124
 
124
 
125
                 break;
125
                 break;
147
                     break;
147
                     break;
148
                 }
148
                 }
149
                 // Otherwise lets grab the window's dimensions and use those (with padding).
149
                 // Otherwise lets grab the window's dimensions and use those (with padding).
150
-                slrn::WindowRectangle t = xengine->m_hoverWindow;
150
+                slop::WindowRectangle t = xengine->m_hoverWindow;
151
                 x = t.m_x - padding - t.m_border;
151
                 x = t.m_x - padding - t.m_border;
152
                 y = t.m_y - padding - t.m_border;
152
                 y = t.m_y - padding - t.m_border;
153
                 w = t.m_width + t.m_border + padding*2;
153
                 w = t.m_width + t.m_border + padding*2;

+ 2
- 2
makefile View File

3
 LDFLAGS=-lX11 -lXext
3
 LDFLAGS=-lX11 -lXext
4
 SOURCES=main.cpp x.cpp options.cpp
4
 SOURCES=main.cpp x.cpp options.cpp
5
 OBJECTS=$(SOURCES:.cpp=.o)
5
 OBJECTS=$(SOURCES:.cpp=.o)
6
-EXECUTABLE=slrn
6
+EXECUTABLE=slop
7
 BINDIR="usr/bin"
7
 BINDIR="usr/bin"
8
 
8
 
9
 all: $(SOURCES) $(EXECUTABLE)
9
 all: $(SOURCES) $(EXECUTABLE)
16
 
16
 
17
 install: all
17
 install: all
18
 	mkdir -p $(DESTDIR)/$(BINDIR)
18
 	mkdir -p $(DESTDIR)/$(BINDIR)
19
-	cp $(CURDIR)/slrn $(DESTDIR)/$(BINDIR)
19
+	cp $(CURDIR)/slop $(DESTDIR)/$(BINDIR)

+ 11
- 11
options.cpp View File

1
 #include "options.hpp"
1
 #include "options.hpp"
2
 
2
 
3
-slrn::Options* options = new slrn::Options();
3
+slop::Options* options = new slop::Options();
4
 
4
 
5
-slrn::Options::Options() {
5
+slop::Options::Options() {
6
     m_borderSize = 10;
6
     m_borderSize = 10;
7
     m_padding = 0;
7
     m_padding = 0;
8
     m_xdisplay = ":0";
8
     m_xdisplay = ":0";
12
     m_blue = 0;
12
     m_blue = 0;
13
 }
13
 }
14
 
14
 
15
-void slrn::Options::printHelp() {
16
-    printf( "Usage: slrn [options]\n" );
15
+void slop::Options::printHelp() {
16
+    printf( "Usage: slop [options]\n" );
17
     printf( "Print user selected region to stdout.\n" );
17
     printf( "Print user selected region to stdout.\n" );
18
     printf( "\n" );
18
     printf( "\n" );
19
     printf( "options\n" );
19
     printf( "options\n" );
20
     printf( "    -h, --help                     show this message.\n" );
20
     printf( "    -h, --help                     show this message.\n" );
21
     printf( "    -b=INT, --bordersize=INT       set selection rectangle border size.\n" );
21
     printf( "    -b=INT, --bordersize=INT       set selection rectangle border size.\n" );
22
     printf( "    -p=INT, --m_padding=INT        set m_padding size for selection.\n" );
22
     printf( "    -p=INT, --m_padding=INT        set m_padding size for selection.\n" );
23
-    printf( "    -t=INT, --tolerance=INT        if you have a shaky mouse, increasing this value will make slrn detect single clicks better. Rather than interpreting your shaky clicks as region selections.\n" );
23
+    printf( "    -t=INT, --tolerance=INT        if you have a shaky mouse, increasing this value will make slop detect single clicks better. Rather than interpreting your shaky clicks as region selections.\n" );
24
     printf( "    -x=STRING, --xdisplay=STRING   set x display (STRING must be hostname:number.screen_number format)\n" );
24
     printf( "    -x=STRING, --xdisplay=STRING   set x display (STRING must be hostname:number.screen_number format)\n" );
25
     printf( "    -c=COLOR, --color=COLOR        set selection rectangle color, COLOR is in format FLOAT,FLOAT,FLOAT\n" );
25
     printf( "    -c=COLOR, --color=COLOR        set selection rectangle color, COLOR is in format FLOAT,FLOAT,FLOAT\n" );
26
     printf( "examples\n" );
26
     printf( "examples\n" );
27
-    printf( "    slrn -b=10 -x=:0 -p=-30 -t=4 -c=0.5,0.5,0.5\n" );
27
+    printf( "    slop -b=10 -x=:0 -p=-30 -t=4 -c=0.5,0.5,0.5\n" );
28
 }
28
 }
29
 
29
 
30
-int slrn::Options::parseOptions( int argc, char** argv ) {
30
+int slop::Options::parseOptions( int argc, char** argv ) {
31
     // Simple command parsing. Just uses sscanf to read each argument.
31
     // Simple command parsing. Just uses sscanf to read each argument.
32
     // It looks complicated because you have to have spaces for delimiters for sscanf.
32
     // It looks complicated because you have to have spaces for delimiters for sscanf.
33
     for ( int i=0; i<argc; i++ ) {
33
     for ( int i=0; i<argc; i++ ) {
78
     return 0;
78
     return 0;
79
 }
79
 }
80
 
80
 
81
-int slrn::Options::parseInt( std::string arg, int* returnInt ) {
81
+int slop::Options::parseInt( std::string arg, int* returnInt ) {
82
     std::string copy = arg;
82
     std::string copy = arg;
83
     int find = copy.find( "=" );
83
     int find = copy.find( "=" );
84
     if ( find != copy.npos ) {
84
     if ( find != copy.npos ) {
99
     return 0;
99
     return 0;
100
 }
100
 }
101
 
101
 
102
-bool slrn::Options::matches( std::string arg, std::string shorthand, std::string longhand ) {
102
+bool slop::Options::matches( std::string arg, std::string shorthand, std::string longhand ) {
103
     if ( arg.substr( 0, shorthand.size() ) == shorthand ||
103
     if ( arg.substr( 0, shorthand.size() ) == shorthand ||
104
          arg.substr( 0, longhand.size() ) == longhand ) {
104
          arg.substr( 0, longhand.size() ) == longhand ) {
105
         return true;
105
         return true;
107
     return false;
107
     return false;
108
 }
108
 }
109
 
109
 
110
-int slrn::Options::parseString( std::string arg, std::string* returnString ) {
110
+int slop::Options::parseString( std::string arg, std::string* returnString ) {
111
     std::string copy = arg;
111
     std::string copy = arg;
112
     int find = copy.find( "=" );
112
     int find = copy.find( "=" );
113
     if ( find != copy.npos ) {
113
     if ( find != copy.npos ) {
132
     return 0;
132
     return 0;
133
 }
133
 }
134
 
134
 
135
-int slrn::Options::parseColor( std::string arg, float* r, float* g, float* b ) {
135
+int slop::Options::parseColor( std::string arg, float* r, float* g, float* b ) {
136
     std::string copy = arg;
136
     std::string copy = arg;
137
     int find = copy.find( "=" );
137
     int find = copy.find( "=" );
138
     while( find != copy.npos ) {
138
     while( find != copy.npos ) {

+ 2
- 2
options.hpp View File

3
 #include <string>
3
 #include <string>
4
 #include <cstdio>
4
 #include <cstdio>
5
 
5
 
6
-namespace slrn {
6
+namespace slop {
7
 
7
 
8
 class Options {
8
 class Options {
9
 public:
9
 public:
27
 
27
 
28
 }
28
 }
29
 
29
 
30
-extern slrn::Options* options;
30
+extern slop::Options* options;
31
 
31
 
32
 #endif // IS_OPTIONS_H_
32
 #endif // IS_OPTIONS_H_

+ 24
- 24
x.cpp View File

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

+ 5
- 5
x.hpp View File

14
 #include <string>
14
 #include <string>
15
 #include <vector>
15
 #include <vector>
16
 
16
 
17
-namespace slrn {
17
+namespace slop {
18
 
18
 
19
 enum CursorType {
19
 enum CursorType {
20
     Left,
20
     Left,
64
                         ~XEngine();
64
                         ~XEngine();
65
     int                 init( std::string display );
65
     int                 init( std::string display );
66
     void                tick();
66
     void                tick();
67
-    int                 grabCursor( slrn::CursorType type );
67
+    int                 grabCursor( slop::CursorType type );
68
     int                 grabKeyboard();
68
     int                 grabKeyboard();
69
     int                 releaseCursor();
69
     int                 releaseCursor();
70
     int                 releaseKeyboard();
70
     int                 releaseKeyboard();
71
-    void                setCursor( slrn::CursorType type );
71
+    void                setCursor( slop::CursorType type );
72
     void                drawRect( int x, int y, unsigned int w, unsigned int h );
72
     void                drawRect( int x, int y, unsigned int w, unsigned int h );
73
     void                addRect( Rectangle* rect );
73
     void                addRect( Rectangle* rect );
74
     void                removeRect( Rectangle* rect );
74
     void                removeRect( Rectangle* rect );
90
     bool                m_good;
90
     bool                m_good;
91
     std::vector<Cursor> m_cursors;
91
     std::vector<Cursor> m_cursors;
92
     std::vector<Rectangle*> m_rects;
92
     std::vector<Rectangle*> m_rects;
93
-    Cursor              getCursor( slrn::CursorType type );
93
+    Cursor              getCursor( slop::CursorType type );
94
 };
94
 };
95
 
95
 
96
 }
96
 }
97
 
97
 
98
-extern slrn::XEngine* xengine;
98
+extern slop::XEngine* xengine;
99
 
99
 
100
 #endif // IS_X_H_
100
 #endif // IS_X_H_