naelstrof пре 11 година
родитељ
комит
38d3a46149
3 измењених фајлова са 19 додато и 9 уклоњено
  1. 8
    7
      main.cpp
  2. 9
    2
      x.cpp
  3. 2
    0
      x.hpp

+ 8
- 7
main.cpp Прегледај датотеку

28
                 arg.at( find ) = ' ';
28
                 arg.at( find ) = ' ';
29
             }
29
             }
30
             int num = sscanf( arg.c_str(), "%*s %i", &borderSize );
30
             int num = sscanf( arg.c_str(), "%*s %i", &borderSize );
31
+            if ( borderSize < 0 ) {
32
+                borderSize = 0;
33
+            }
31
             if ( num != 1 ) {
34
             if ( num != 1 ) {
32
                 printf( "Error parsing command arguments near %s\n", argv[i] );
35
                 printf( "Error parsing command arguments near %s\n", argv[i] );
33
                 printf( "Usage: -b=INT or --bordersize=INT\n" );
36
                 printf( "Usage: -b=INT or --bordersize=INT\n" );
135
             }
138
             }
136
             case 1: {
139
             case 1: {
137
                 selection = new is::Rectangle( xengine->m_mousex, xengine->m_mousey, 0, 0, borderSize, padding );
140
                 selection = new is::Rectangle( xengine->m_mousex, xengine->m_mousey, 0, 0, borderSize, padding );
138
-                selection->setPos( xengine->m_mousex, xengine->m_mousey );
139
                 xengine->addRect( selection );
141
                 xengine->addRect( selection );
140
                 state++;
142
                 state++;
141
                 break;
143
                 break;
146
                     break;
148
                     break;
147
                 }
149
                 }
148
                 selection->setDim( xengine->m_mousex - selection->m_x, xengine->m_mousey - selection->m_y );
150
                 selection->setDim( xengine->m_mousex - selection->m_x, xengine->m_mousey - selection->m_y );
149
-                // x and y offsets can indicate if the selection is inside-out, which lets us know which kind of cursor we need.
150
-                int x = selection->m_xoffset;
151
-                int y = selection->m_yoffset;
152
-                if ( x == 0 && y == 0) {
151
+                bool x = selection->m_flippedx;
152
+                bool y = selection->m_flippedy;
153
+                if ( !x && !y ) {
153
                     xengine->setCursor( is::LowerRightCorner );
154
                     xengine->setCursor( is::LowerRightCorner );
154
-                } else if ( x && y == 0 ) {
155
+                } else if ( x && !y ) {
155
                     xengine->setCursor( is::LowerLeftCorner );
156
                     xengine->setCursor( is::LowerLeftCorner );
156
-                } else if ( x == 0 && y ) {
157
+                } else if ( !x && y ) {
157
                     xengine->setCursor( is::UpperRightCorner );
158
                     xengine->setCursor( is::UpperRightCorner );
158
                 } else {
159
                 } else {
159
                     xengine->setCursor( is::UpperLeftCorner );
160
                     xengine->setCursor( is::UpperLeftCorner );

+ 9
- 2
x.cpp Прегледај датотеку

85
     unsigned int mask;
85
     unsigned int mask;
86
     XQueryPointer( m_display, m_root, &root, &child, &mx, &my, &wx, &wy, &mask );
86
     XQueryPointer( m_display, m_root, &root, &child, &mx, &my, &wx, &wy, &mask );
87
     m_mousex = mx;
87
     m_mousex = mx;
88
-    m_mousex = my;
88
+    m_mousey = my;
89
     updateHoverWindow( child );
89
     updateHoverWindow( child );
90
     return 0;
90
     return 0;
91
 }
91
 }
102
     if ( !m_good ) {
102
     if ( !m_good ) {
103
         return;
103
         return;
104
     }
104
     }
105
-    XSync( m_display, false );
105
+    XFlush( m_display );
106
     XEvent event;
106
     XEvent event;
107
     while ( XPending( m_display ) ) {
107
     while ( XPending( m_display ) ) {
108
         XNextEvent( m_display, &event );
108
         XNextEvent( m_display, &event );
239
     }
239
     }
240
 
240
 
241
     constrain( w, h );
241
     constrain( w, h );
242
+    if ( m_border == 0 ) {
243
+        return;
244
+    }
242
 
245
 
243
     XResizeWindow( xengine->m_display, m_window, m_width+m_border*2, m_height+m_border*2 );
246
     XResizeWindow( xengine->m_display, m_window, m_width+m_border*2, m_height+m_border*2 );
244
     XMoveWindow( xengine->m_display, m_window, m_x+m_xoffset, m_y+m_yoffset );
247
     XMoveWindow( xengine->m_display, m_window, m_x+m_xoffset, m_y+m_yoffset );
308
         pad = 0;
311
         pad = 0;
309
     }
312
     }
310
     if ( w < 0 ) {
313
     if ( w < 0 ) {
314
+        m_flippedx = true;
311
         m_xoffset = w - pad - m_border;
315
         m_xoffset = w - pad - m_border;
312
         m_width = -w + pad*2;
316
         m_width = -w + pad*2;
313
     } else {
317
     } else {
318
+        m_flippedx = false;
314
         m_xoffset = -pad - m_border;
319
         m_xoffset = -pad - m_border;
315
         m_width = w + pad*2;
320
         m_width = w + pad*2;
316
     }
321
     }
320
         pad = 0;
325
         pad = 0;
321
     }
326
     }
322
     if ( h < 0 ) {
327
     if ( h < 0 ) {
328
+        m_flippedy = true;
323
         m_yoffset = h - pad - m_border;
329
         m_yoffset = h - pad - m_border;
324
         m_height = -h + pad*2;
330
         m_height = -h + pad*2;
325
     } else {
331
     } else {
332
+        m_flippedy = false;
326
         m_yoffset = -pad - m_border;
333
         m_yoffset = -pad - m_border;
327
         m_height = h + pad*2;
334
         m_height = h + pad*2;
328
     }
335
     }

+ 2
- 0
x.hpp Прегледај датотеку

52
     int     m_padding;
52
     int     m_padding;
53
     XColor  m_forground, m_forgroundExact;
53
     XColor  m_forground, m_forgroundExact;
54
     XColor  m_background, m_backgroundExact;
54
     XColor  m_background, m_backgroundExact;
55
+    bool    m_flippedx;
56
+    bool    m_flippedy;
55
 private:
57
 private:
56
     void    constrain( int w, int h );
58
     void    constrain( int w, int h );
57
 };
59
 };