@@ -50,42 +50,31 @@ static void handleButtonPress(xcb_generic_event_t * ev) {
50
50
XCB_GRAB_MODE_ASYNC , XCB_GRAB_MODE_ASYNC , scre -> root , XCB_NONE , XCB_CURRENT_TIME );
51
51
}
52
52
53
- static void moveWindow (xcb_query_pointer_reply_t * poin ) {
54
- xcb_get_geometry_cookie_t geom_now = xcb_get_geometry (dpy , win );
55
- xcb_get_geometry_reply_t * geom = xcb_get_geometry_reply (dpy , geom_now , NULL );
56
- values [0 ] = ((poin -> root_x + geom -> width ) > scre -> width_in_pixels ) ?
57
- (scre -> width_in_pixels - geom -> width ) : poin -> root_x ;
58
- values [1 ] = ((poin -> root_y + geom -> height ) > scre -> height_in_pixels ) ?
59
- (scre -> height_in_pixels - geom -> height ) : poin -> root_y ;
60
- xcb_configure_window (dpy , win , XCB_CONFIG_WINDOW_X
61
- | XCB_CONFIG_WINDOW_Y , values );
62
- }
63
-
64
- static void resizeWindow (xcb_query_pointer_reply_t * poin ) {
65
- xcb_get_geometry_cookie_t geom_now = xcb_get_geometry (dpy , win );
66
- xcb_get_geometry_reply_t * geom = xcb_get_geometry_reply (dpy , geom_now , NULL );
67
- if (!((poin -> root_x <= geom -> x ) || (poin -> root_y <= geom -> y ))) {
68
- values [0 ] = poin -> root_x - geom -> x ;
69
- values [1 ] = poin -> root_y - geom -> y ;
70
- uint32_t min_x = WINDOW_MIN_WIDTH ;
71
- uint32_t min_y = WINDOW_MIN_HEIGHT ;
72
- if ((values [0 ] >= min_x ) && (values [1 ] >= min_y )) {
73
- xcb_configure_window (dpy , win , XCB_CONFIG_WINDOW_WIDTH
74
- | XCB_CONFIG_WINDOW_HEIGHT , values );
75
- }
76
- }
77
- }
78
-
79
53
static void handleMotionNotify (xcb_generic_event_t * ev ) {
80
54
xcb_query_pointer_cookie_t coord = xcb_query_pointer (dpy , scre -> root );
81
55
xcb_query_pointer_reply_t * poin = xcb_query_pointer_reply (dpy , coord , 0 );
82
56
uint32_t val [2 ] = {1 , 3 };
83
57
if ((values [2 ] == val [0 ]) && (win != 0 )) {
84
- moveWindow (poin );
85
- }
86
- if ((values [2 ] == val [1 ]) && (win != 0 )) {
87
- resizeWindow (poin );
88
- }
58
+ xcb_get_geometry_cookie_t geom_now = xcb_get_geometry (dpy , win );
59
+ xcb_get_geometry_reply_t * geom = xcb_get_geometry_reply (dpy , geom_now , NULL );
60
+ values [0 ] = ((poin -> root_x + geom -> width + 2 * BORDER_WIDTH ) > scre -> width_in_pixels ) ?
61
+ (scre -> width_in_pixels - geom -> width - 2 * BORDER_WIDTH ) : poin -> root_x ;
62
+ values [1 ] = ((poin -> root_y + geom -> height + 2 * BORDER_WIDTH ) > scre -> height_in_pixels ) ?
63
+ (scre -> height_in_pixels - geom -> height - 2 * BORDER_WIDTH ) : poin -> root_y ;
64
+ xcb_configure_window (dpy , win , XCB_CONFIG_WINDOW_X
65
+ | XCB_CONFIG_WINDOW_Y , values );
66
+ } else if ((values [2 ] == val [1 ]) && (win != 0 )) {
67
+ xcb_get_geometry_cookie_t geom_now = xcb_get_geometry (dpy , win );
68
+ xcb_get_geometry_reply_t * geom = xcb_get_geometry_reply (dpy , geom_now , NULL );
69
+ if (!((poin -> root_x <= geom -> x ) || (poin -> root_y <= geom -> y ))) {
70
+ values [0 ] = poin -> root_x - geom -> x - BORDER_WIDTH ;
71
+ values [1 ] = poin -> root_y - geom -> y - BORDER_WIDTH ;
72
+ if ((values [0 ] >= WINDOW_MIN_X ) && (values [1 ] >= WINDOW_MIN_Y )) {
73
+ xcb_configure_window (dpy , win , XCB_CONFIG_WINDOW_WIDTH
74
+ | XCB_CONFIG_WINDOW_HEIGHT , values );
75
+ }
76
+ }
77
+ } else {}
89
78
}
90
79
91
80
static xcb_keycode_t * xcb_get_keycodes (xcb_keysym_t keysym ) {
@@ -132,8 +121,8 @@ static void setBorderWidth(xcb_window_t window) {
132
121
static void setWindowDimensions (xcb_window_t window ) {
133
122
if ((scre -> root != window ) && (0 != window )) {
134
123
uint32_t vals [2 ];
135
- vals [0 ] = WINDOW_WIDTH ;
136
- vals [1 ] = WINDOW_HEIGHT ;
124
+ vals [0 ] = WINDOW_X ;
125
+ vals [1 ] = WINDOW_Y ;
137
126
xcb_configure_window (dpy , window , XCB_CONFIG_WINDOW_WIDTH |
138
127
XCB_CONFIG_WINDOW_HEIGHT , vals );
139
128
xcb_flush (dpy );
@@ -259,7 +248,7 @@ static int strcmp_c(char * str1, char * str2) {
259
248
int main (int argc , char * argv []) {
260
249
int ret = 0 ;
261
250
if ((argc == 2 ) && (strcmp_c ("-v" , argv [1 ]) == 0 )) {
262
- ret = die ("xwm-0.0.8 , © 2020 Michael Czigler, see LICENSE for details\n" );
251
+ ret = die ("xwm-0.0.9 , © 2020 Michael Czigler, see LICENSE for details\n" );
263
252
}
264
253
if ((ret == 0 ) && (argc != 1 )) {
265
254
ret = die ("usage: xwm [-v]\n" );
0 commit comments