Przeglądaj źródła

added a prototype legacy mode

naelstrof 7 lat temu
rodzic
commit
d9ac7ad9ae
10 zmienionych plików z 466 dodań i 26 usunięć
  1. 39
    19
      CMakeLists.txt
  2. 1
    1
      src/glslop.cpp
  3. 1
    1
      src/glslop.hpp
  4. 10
    2
      src/main.cpp
  5. 1
    1
      src/options.hpp
  6. 8
    2
      src/slopstates.hpp
  7. 141
    0
      src/xshaperectangle.cpp
  8. 58
    0
      src/xshaperectangle.hpp
  9. 127
    0
      src/xslop.cpp
  10. 80
    0
      src/xslop.hpp

+ 39
- 19
CMakeLists.txt Wyświetl plik

@@ -1,4 +1,3 @@
1
-#Change this if you need to target a specific CMake version
2 1
 cmake_minimum_required(VERSION 2.6)
3 2
 
4 3
 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)")
@@ -6,8 +5,16 @@ if ( NOT CMAKE_INSTALL_PREFIX )
6 5
     set(CMAKE_INSTALL_PREFIX "/usr")
7 6
 endif()
8 7
 
8
+if ( NOT SLOP_LEGACY_MODE )
9
+    set(SLOP_LEGACY_MODE FALSE CACHE BOOL "Legacy mode requires the XShape extension, is laggy, isn't guaranteed to be invisible on shutdown, isn't guaranteed to support opacity, and doesn't support custom shaders. Though it still might be desired since it doesn't require OpenGL to use.")
10
+endif()
11
+
9 12
 project(slop)
13
+
10 14
 add_definitions(-DSLOP_VERSION="v5.3.21")
15
+if ( SLOP_LEGACY_MODE )
16
+    add_definitions(-DSLOP_LEGACY_MODE=true)
17
+endif()
11 18
 
12 19
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
13 20
 
@@ -17,40 +24,53 @@ include_directories("${PROJECT_BINARY_DIR}")
17 24
 set(EXECUTABLE_NAME "slop")
18 25
 
19 26
 set( source src/x.cpp
20
-            src/window.cpp
21 27
             src/windowhelper.cpp
22 28
             src/mouse.cpp
23 29
             src/keyboard.cpp
24
-            src/framebuffer.cpp
25 30
             src/resource.cpp
26 31
             src/options.cpp
27
-            src/gl_core_3_3.c
28
-            src/shader.cpp
29 32
             src/slopstates.cpp
30
-            src/slop.cpp
31
-            src/rectangle.cpp
32 33
             src/main.cpp )
33 34
 
34
-add_executable(${EXECUTABLE_NAME} ${source})
35
+if ( SLOP_LEGACY_MODE )
36
+    set ( source ${source}
37
+                 src/xslop.cpp
38
+                 src/xshaperectangle.cpp )
39
+else()
40
+    set ( source ${source}
41
+                 src/window.cpp
42
+                 src/glslop.cpp
43
+                 src/rectangle.cpp
44
+                 src/framebuffer.cpp
45
+                 src/gl_core_3_3.c
46
+                 src/shader.cpp )
47
+endif()
35 48
 
49
+add_executable(${EXECUTABLE_NAME} ${source})
36 50
 
37
-# Detect and add SFML
51
+# Detect and add cmake modules
38 52
 set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules" )
39
-#Find any version 2.X of SFML
40
-#See the FindSFML.cmake file for additional details and instructions
41
-find_package(OpenGL REQUIRED)
42 53
 find_package(GLM REQUIRED)
43
-find_package(GLX REQUIRED)
44 54
 find_package(X11 REQUIRED)
45 55
 
46 56
 include_directories(${X11_INCLUDE_DIR}
47
-                    ${GLM_INCLUDE_DIR}
48
-                    ${GLX_INCLUDE_DIR}
49
-                    ${OPENGL_INCLUDE_DIR})
50
-
57
+                    ${GLM_INCLUDE_DIR})
51 58
 target_link_libraries(${EXECUTABLE_NAME} ${X11_LIBRARIES}
52
-                                         ${GLX_LIBRARIES}
53
-                                         ${OPENGL_LIBRARIES})
59
+                                         ${GLM_LIBRARIES})
60
+
61
+# Either we require OpenGL, or we require the XShape extension.
62
+if ( SLOP_LEGACY_MODE )
63
+    find_package(XExt REQUIRED)
64
+    include_directories(${XEXT_INCLUDE_DIR})
65
+    target_link_libraries(${EXECUTABLE_NAME} ${XEXT_LIBRARIES})
66
+else()
67
+    find_package(GLX REQUIRED)
68
+    find_package(OpenGL REQUIRED)
69
+    include_directories(${GLX_INCLUDE_DIR}
70
+                        ${OPENGL_INCLUDE_DIR})
71
+    target_link_libraries(${EXECUTABLE_NAME} ${OPENGL_LIBRARIES}
72
+                                             ${GLX_LIBRARY})
73
+endif()
54 74
 
55 75
 # Install targets
56 76
 install( TARGETS ${EXECUTABLE_NAME} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )

src/slop.cpp → src/glslop.cpp Wyświetl plik

@@ -1,4 +1,4 @@
1
-#include "slop.hpp"
1
+#include "glslop.hpp"
2 2
 
3 3
 X11* x11;
4 4
 Mouse* mouse;

src/slop.hpp → src/glslop.hpp Wyświetl plik

@@ -1,4 +1,4 @@
1
-/* slop.hpp: exposes a selection interface
1
+/* glslop.hpp: exposes an opengl selection interface
2 2
  *
3 3
  * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
4 4
  *

+ 10
- 2
src/main.cpp Wyświetl plik

@@ -20,7 +20,11 @@
20 20
 
21 21
 #include <iostream>
22 22
 #include <sstream>
23
-#include "slop.hpp"
23
+#ifdef SLOP_LEGACY_MODE
24
+#include "xslop.hpp"
25
+#else
26
+#include "glslop.hpp"
27
+#endif
24 28
 #include "options.hpp"
25 29
 
26 30
 SlopOptions* getOptions( Options& options ) {
@@ -31,12 +35,14 @@ SlopOptions* getOptions( Options& options ) {
31 35
     glm::vec4 color = glm::vec4( foo->r, foo->g, foo->b, foo->a );
32 36
     options.getColor("color", 'c', color);
33 37
     options.getString( "xdisplay", 'x', foo->xdisplay );
38
+#ifndef SLOP_LEGACY_MODE
34 39
     options.getString( "shader", 's', foo->shader );
40
+#endif
35 41
     foo->r = color.r;
36 42
     foo->g = color.g;
37 43
     foo->b = color.b;
38 44
     foo->a = color.a;
39
-    options.getBool("highlight", 'h', foo->highlight);
45
+    options.getBool("highlight", 'l', foo->highlight);
40 46
     options.getBool("nodecorations", 'n', foo->nodecorations);
41 47
     return foo;
42 48
 }
@@ -111,8 +117,10 @@ void printHelp() {
111 117
 	std::cout << "                                  highlights it. This is only useful when\n";
112 118
 	std::cout << "                                  --color is set to a transparent color.\n";
113 119
 	std::cout << "                                  (default=off)\n";
120
+#ifndef SLOP_LEGACY_MODE
114 121
 	std::cout << "      --shader=STRING           Sets the shader to load and use from\n";
115 122
 	std::cout << "                                  ~/.config/slop/\n";
123
+#endif
116 124
 	std::cout << "                                  (default=`simple')\n";
117 125
 	std::cout << "  -f, --format=STRING           Set the output format string. Format specifiers\n";
118 126
 	std::cout << "                                  are %x, %y, %w, %h, %i, %g, and %c.\n";

+ 1
- 1
src/options.hpp Wyświetl plik

@@ -29,7 +29,7 @@
29 29
 #include <glm/glm.hpp>
30 30
 
31 31
 static std::string validStringArguments[] = { "bordersize", "padding", "color", "shader", "highlight", "format", "tolerance", "nodecorations", "nokeyboard", "help", "xdisplay", "version" };
32
-static char validCharArguments[] = { 'b', 'p', 'c', 's', 'h', 'f', 't', 'n', 'k', 'h', 'x', 'v' };
32
+static char validCharArguments[] = { 'b', 'p', 'c', 's', 'l', 'f', 't', 'n', 'k', 'h', 'x', 'v' };
33 33
 static unsigned int isFlagArgument[] = { false, false, false, false, true, false, false, true, true, true, false, true };
34 34
 static unsigned int validArgumentCount = 12;
35 35
 static unsigned int maxFloatingValues = 0;

+ 8
- 2
src/slopstates.hpp Wyświetl plik

@@ -22,9 +22,15 @@
22 22
 #define N_SLOPSTATES_H_
23 23
 
24 24
 #include "mouse.hpp"
25
-#include "rectangle.hpp"
26 25
 #include "windowhelper.hpp"
27
-#include "slop.hpp"
26
+
27
+#ifdef SLOP_LEGACY_MODE
28
+#include "xslop.hpp"
29
+#include "xshaperectangle.hpp"
30
+#else
31
+#include "glslop.hpp"
32
+#include "rectangle.hpp"
33
+#endif
28 34
 
29 35
 class SlopMemory;
30 36
 

+ 141
- 0
src/xshaperectangle.cpp Wyświetl plik

@@ -0,0 +1,141 @@
1
+#include "xshaperectangle.hpp"
2
+
3
+Rectangle::Rectangle( glm::vec2 p1, glm::vec2 p2, float border, float padding, glm::vec4 color, bool highlight ) {
4
+    this->color = convertColor( color );
5
+    this->border = border;
6
+    this->padding = padding;
7
+    this->highlight = highlight;
8
+    this->alpha = color.a;
9
+    // Find each corner of the rectangle
10
+    ul = glm::vec2( glm::min( p1.x, p2.x ), glm::max( p1.y, p2.y ) ) ;
11
+    bl = glm::vec2( glm::min( p1.x, p2.x ), glm::min( p1.y, p2.y ) ) ;
12
+    ur = glm::vec2( glm::max( p1.x, p2.x ), glm::max( p1.y, p2.y ) ) ;
13
+    br = glm::vec2( glm::max( p1.x, p2.x ), glm::min( p1.y, p2.y ) ) ;
14
+    // Offset the inner corners by the padding.
15
+    ul = ul + glm::vec2(-padding,padding);
16
+    bl = bl + glm::vec2(-padding,-padding);
17
+    ur = ur + glm::vec2(padding,padding);
18
+    br = br + glm::vec2(padding,-padding);
19
+    // Create the outer corners by offsetting the inner by the bordersize
20
+    oul = ul + glm::vec2(-border,border);
21
+    obl = bl + glm::vec2(-border,-border);
22
+    our = ur + glm::vec2(border,border);
23
+    obr = br + glm::vec2(border,-border);
24
+
25
+    XSetWindowAttributes attributes;
26
+    // Set up the window so it's our color 
27
+    attributes.background_pixel = this->color.pixel;
28
+    // Disable window decorations.
29
+    attributes.override_redirect = True;
30
+    // Make sure we know when we've been successfully destroyed later!
31
+    attributes.event_mask = StructureNotifyMask;
32
+    unsigned long valueMask = CWBackPixel | CWOverrideRedirect | CWEventMask;
33
+    // Create the window
34
+    window = XCreateWindow( x11->display, x11->root, 0, 0, WidthOfScreen( x11->screen ), HeightOfScreen( x11->screen ),
35
+                              0, CopyFromParent, InputOutput,
36
+                              CopyFromParent, valueMask, &attributes );
37
+    if ( alpha < 1 ) {
38
+        // Change the window opacity
39
+        unsigned int cardinal_alpha = (unsigned int) (alpha * (unsigned int)-1) ;
40
+        XChangeProperty( x11->display, window, XInternAtom( x11->display, "_NET_WM_WINDOW_OPACITY", 0),
41
+                         XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&cardinal_alpha, 1 );
42
+    }
43
+    // Set the class hint, and title to "slop"
44
+    XClassHint classhints;
45
+    char name[] = "slop";
46
+    classhints.res_name = name;
47
+    classhints.res_class = name;
48
+    XSetClassHint( x11->display, window, &classhints );
49
+    // Now punch a hole into it so it looks like a selection rectangle, but only if we're not highlighting.
50
+    generateHoles();
51
+    createdWindow = false;
52
+}
53
+
54
+void Rectangle::createWindow() {
55
+    if ( createdWindow ) {
56
+        return;
57
+    }
58
+	XMapWindow( x11->display, window );
59
+    createdWindow = true;
60
+}
61
+
62
+void Rectangle::generateHoles() {
63
+    if ( !highlight ) {
64
+        XRectangle rects[4];
65
+        // Left
66
+        rects[0].x = oul.x;
67
+        rects[0].y = obl.y;
68
+        rects[0].width = border;
69
+        rects[0].height = oul.y-obl.y;
70
+        // Top
71
+        rects[1].x = ul.x;
72
+        rects[1].y = obl.y;
73
+        rects[1].width = ur.x-ul.x;
74
+        rects[1].height = border;
75
+        // Right
76
+        rects[2].x = ur.x;
77
+        rects[2].y = obr.y;
78
+        rects[2].width = border;
79
+        rects[2].height = our.y - obr.y;
80
+        // Bottom
81
+        rects[3].x = bl.x;
82
+        rects[3].y = ul.y;
83
+        rects[3].width = br.x-bl.x;
84
+        rects[3].height = border;
85
+        XShapeCombineRectangles( x11->display, window, ShapeBounding, 0, 0, rects, 4, ShapeSet, 0);
86
+        return;
87
+    }
88
+    XRectangle rect;
89
+    rect.x = oul.x;
90
+    rect.y = obl.y;
91
+    rect.width = our.x-oul.x;
92
+    rect.height = oul.y-obl.y;
93
+    XShapeCombineRectangles( x11->display, window, ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0);
94
+}
95
+
96
+void Rectangle::setPoints( glm::vec2 p1, glm::vec2 p2 ) {
97
+    // Find each corner of the rectangle
98
+    ul = glm::vec2( glm::min( p1.x, p2.x ), glm::max( p1.y, p2.y ) ) ;
99
+    bl = glm::vec2( glm::min( p1.x, p2.x ), glm::min( p1.y, p2.y ) ) ;
100
+    ur = glm::vec2( glm::max( p1.x, p2.x ), glm::max( p1.y, p2.y ) ) ;
101
+    br = glm::vec2( glm::max( p1.x, p2.x ), glm::min( p1.y, p2.y ) ) ;
102
+    // Offset the inner corners by the padding.
103
+    ul = ul + glm::vec2(-padding,padding);
104
+    bl = bl + glm::vec2(-padding,-padding);
105
+    ur = ur + glm::vec2(padding,padding);
106
+    br = br + glm::vec2(padding,-padding);
107
+    // Create the outer corners by offsetting the inner by the bordersize
108
+    oul = ul + glm::vec2(-border,border);
109
+    obl = bl + glm::vec2(-border,-border);
110
+    our = ur + glm::vec2(border,border);
111
+    obr = br + glm::vec2(border,-border);
112
+    generateHoles();
113
+}
114
+
115
+Rectangle::~Rectangle() {
116
+}
117
+
118
+void Rectangle::draw( glm::mat4& matrix ) {
119
+    // We don't want to be visible until we're asked to draw.
120
+    createWindow();
121
+}
122
+
123
+glm::vec4 Rectangle::getRect() {
124
+    return glm::vec4( bl.x, bl.y, ur.x-ul.x, ul.y-bl.y );
125
+}
126
+
127
+XColor Rectangle::convertColor( glm::vec4 color ) {
128
+    // Convert float colors to shorts.
129
+    short red   = short( floor( color.r * 65535.f ) );
130
+    short green = short( floor( color.g * 65535.f ) );
131
+    short blue  = short( floor( color.b * 65535.f ) );
132
+    XColor xc;
133
+    xc.red = red;
134
+    xc.green = green;
135
+    xc.blue = blue;
136
+    int err = XAllocColor( x11->display, DefaultColormap( x11->display, XScreenNumberOfScreen( x11->screen ) ), &xc );
137
+    if ( err == BadColor ) {
138
+        throw new std::runtime_error(std::string("Couldn't allocate a color"));
139
+    }
140
+    return xc;
141
+}

+ 58
- 0
src/xshaperectangle.hpp Wyświetl plik

@@ -0,0 +1,58 @@
1
+/* xshaperectangle.hpp: A rectangle that doesn't use OpenGL to function.
2
+ *
3
+ * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
4
+ *
5
+ * This file is part of Slop.
6
+ *
7
+ * Slop is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * Slop is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with Slop.  If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+#ifndef N_XSHAPERECTANGLE_H_
22
+#define N_XSHAPERECTANGLE_H_
23
+
24
+#include <iostream>
25
+#include <glm/glm.hpp>
26
+#include <vector>
27
+#include <X11/Xlib.h>
28
+#include <X11/Xatom.h>
29
+#include <X11/Xutil.h>
30
+#include <X11/extensions/shape.h>
31
+
32
+#include "x.hpp"
33
+
34
+class Rectangle {
35
+private:
36
+    glm::vec2 ul, oul;
37
+    glm::vec2 bl, obl;
38
+    glm::vec2 ur, our;
39
+    glm::vec2 br, obr;
40
+    bool createdWindow;
41
+    bool highlight;
42
+    float border;
43
+    float padding;
44
+    XColor color;
45
+    float alpha;
46
+    XColor convertColor( glm::vec4 color );
47
+    void generateHoles();
48
+    void createWindow();
49
+public:
50
+    Window window;
51
+    glm::vec4 getRect();
52
+    Rectangle(glm::vec2 p1, glm::vec2 p2, float border = 1, float padding = 0, glm::vec4 color = glm::vec4(1,1,1,1), bool highlight = false );
53
+    ~Rectangle();
54
+    void setPoints( glm::vec2 p1, glm::vec2 p2 );
55
+    void draw(glm::mat4& matrix);
56
+};
57
+
58
+#endif // N_XSHAPERECTANGLE_H_

+ 127
- 0
src/xslop.cpp Wyświetl plik

@@ -0,0 +1,127 @@
1
+#include "xslop.hpp"
2
+
3
+X11* x11;
4
+Mouse* mouse;
5
+Keyboard* keyboard;
6
+Resource* resource;
7
+
8
+// Defaults!
9
+SlopOptions::SlopOptions() {
10
+    borderSize = 1;
11
+    nodecorations = false;
12
+    tolerance = 2;
13
+    padding = 0;
14
+    highlight = false;
15
+    xdisplay = ":0";
16
+    r = 0.5;
17
+    g = 0.5;
18
+    b = 0.5;
19
+    a = 1;
20
+}
21
+
22
+SlopSelection::SlopSelection( float x, float y, float w, float h, Window id ) {
23
+    this->x = x;
24
+    this->y = y;
25
+    this->w = w;
26
+    this->h = h;
27
+    this->id = id;
28
+}
29
+
30
+SlopMemory::SlopMemory( SlopOptions* options ) {
31
+    running = true;
32
+    state = (SlopState*)new SlopStart();
33
+    nextState = NULL;
34
+    tolerance = options->tolerance;
35
+    nodecorations = options->nodecorations;
36
+    rectangle = new Rectangle(glm::vec2(0,0), glm::vec2(0,0), options->borderSize, options->padding, glm::vec4( options->r, options->g, options->b, options->a ), options->highlight);
37
+    selectedWindow = x11->root;
38
+    state->onEnter( *this );
39
+}
40
+
41
+SlopMemory::~SlopMemory() {
42
+    delete state;
43
+    if ( nextState ) {
44
+        delete nextState;
45
+    }
46
+    delete rectangle;
47
+}
48
+
49
+void SlopMemory::update( double dt ) {
50
+    state->update( *this, dt );
51
+    if ( nextState ) {
52
+        state->onExit( *this );
53
+        delete state;
54
+        state = nextState;
55
+        state->onEnter( *this );
56
+        nextState = NULL;
57
+    }
58
+}
59
+
60
+void SlopMemory::setState( SlopState* state ) {
61
+    if ( nextState ) {
62
+        delete nextState;
63
+    }
64
+    nextState = state;
65
+}
66
+
67
+void SlopMemory::draw( glm::mat4& matrix ) {
68
+    state->draw( *this, matrix );
69
+}
70
+
71
+SlopSelection SlopSelect( SlopOptions* options, bool* cancelled ) {
72
+    bool deleteOptions = false;
73
+    if ( !options ) {
74
+        deleteOptions = true;
75
+        options = new SlopOptions();
76
+    }
77
+    resource = new Resource();
78
+    // Set up x11 temporarily
79
+    x11 = new X11(options->xdisplay);
80
+    keyboard = new Keyboard( x11 );
81
+
82
+    // Init our little state machine, memory is a tad of a misnomer
83
+    SlopMemory memory( options );
84
+    mouse = new Mouse( x11, options->nodecorations, memory.rectangle->window );
85
+
86
+    glm::mat4 fake;
87
+    // This is where we'll run through all of our stuffs
88
+    while( memory.running ) {
89
+        mouse->update();
90
+        keyboard->update();
91
+        // We move our statemachine forward.
92
+        memory.update( 1 );
93
+
94
+        // We don't actually draw anything, but the state machine uses
95
+        // this to know when to spawn the window.
96
+        memory.draw( fake );
97
+
98
+        // X11 explodes if we update as fast as possible, here's a tiny sleep.
99
+        //std::this_thread::sleep_for(std::chrono::milliseconds(10));
100
+        XFlush(x11->display);
101
+
102
+        // Then we draw the framebuffer to the screen
103
+        if ( keyboard->anyKeyDown() || mouse->getButton( 3 ) ) {
104
+            memory.running = false;
105
+            if ( cancelled ) {
106
+                *cancelled = true;
107
+            }
108
+        } else {
109
+            *cancelled = false;
110
+        }
111
+    }
112
+
113
+    // Now we should have a selection! We parse everything we know about it here.
114
+    glm::vec4 output = memory.rectangle->getRect();
115
+
116
+    // Lets now clear both front and back buffers before closing.
117
+    // hopefully it'll be completely transparent while closing!
118
+    // Then we clean up.
119
+    delete mouse;
120
+    delete x11;
121
+    delete resource;
122
+    if ( deleteOptions ) {
123
+        delete options;
124
+    }
125
+    // Finally return the data.
126
+    return SlopSelection( output.x, output.y, output.z, output.w, memory.selectedWindow );
127
+}

+ 80
- 0
src/xslop.hpp Wyświetl plik

@@ -0,0 +1,80 @@
1
+/* slop.hpp: exposes a selection interface
2
+ *
3
+ * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
4
+ *
5
+ * This file is part of Slop.
6
+ *
7
+ * Slop is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * Slop is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with Slop.  If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+
21
+#ifndef N_SLOP_H_
22
+#define N_SLOP_H_
23
+
24
+#include <string>
25
+#include <chrono>
26
+#include <thread>
27
+
28
+#include "xshaperectangle.hpp"
29
+#include "slopstates.hpp"
30
+#include "keyboard.hpp"
31
+#include "mouse.hpp"
32
+#include "resource.hpp"
33
+
34
+class SlopState;
35
+
36
+class SlopOptions {
37
+public:
38
+    SlopOptions();
39
+    float borderSize;
40
+    float padding;
41
+    float tolerance;
42
+    bool highlight;
43
+    bool nodecorations;
44
+    float r;
45
+    float g;
46
+    float b;
47
+    float a;
48
+    std::string xdisplay;
49
+};
50
+
51
+class SlopSelection {
52
+public:
53
+    SlopSelection( float x, float y, float w, float h, Window id );
54
+    float x;
55
+    float y;
56
+    float w;
57
+    float h;
58
+    Window id;
59
+};
60
+
61
+class SlopMemory {
62
+private:
63
+    SlopState* state;
64
+    SlopState* nextState;
65
+public:
66
+    SlopMemory( SlopOptions* options );
67
+    ~SlopMemory();
68
+    Window selectedWindow;
69
+    bool running;
70
+    float tolerance;
71
+    bool nodecorations;
72
+    Rectangle* rectangle;
73
+    void setState( SlopState* state );
74
+    void update( double dt );
75
+    void draw( glm::mat4& matrix );
76
+};
77
+
78
+SlopSelection SlopSelect( SlopOptions* options = NULL, bool* cancelled = NULL );
79
+
80
+#endif // N_SLOP_H_