aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <ddevault@linode.com>2015-12-14 08:57:00 -0500
committerLibravatar Drew DeVault <ddevault@linode.com>2015-12-14 08:57:00 -0500
commit4d17aa99194ac8a1511df93a3ec5edf44bcf61e6 (patch)
treef622553c1457dfddce457123212b9c852e01bec6 /sway
parentMerge pull request #311 from mikkeloscar/bar-config-parser (diff)
downloadsway-4d17aa99194ac8a1511df93a3ec5edf44bcf61e6.tar.gz
sway-4d17aa99194ac8a1511df93a3ec5edf44bcf61e6.tar.zst
sway-4d17aa99194ac8a1511df93a3ec5edf44bcf61e6.zip
Revert "Make mouse key used for drag/resize configurable"
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c17
-rw-r--r--sway/config.c2
-rw-r--r--sway/input_state.c93
3 files changed, 21 insertions, 91 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 4e9d2796..ad43c4d5 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -379,14 +379,14 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
379 379
380static struct cmd_results *cmd_floating_mod(int argc, char **argv) { 380static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
381 struct cmd_results *error = NULL; 381 struct cmd_results *error = NULL;
382 if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { 382 if ((error = checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1))) {
383 return error; 383 return error;
384 } 384 }
385 int i, j; 385 int i, j;
386 list_t *split = split_string(argv[0], "+"); 386 list_t *split = split_string(argv[0], "+");
387 config->floating_mod = 0; 387 config->floating_mod = 0;
388 388
389 // set modifier keys 389 // set modifer keys
390 for (i = 0; i < split->length; ++i) { 390 for (i = 0; i < split->length; ++i) {
391 for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) { 391 for (j = 0; j < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++j) {
392 if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { 392 if (strcasecmp(modifiers[j].name, split->items[i]) == 0) {
@@ -399,19 +399,6 @@ static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
399 error = cmd_results_new(CMD_INVALID, "floating_modifier", "Unknown keys %s", argv[0]); 399 error = cmd_results_new(CMD_INVALID, "floating_modifier", "Unknown keys %s", argv[0]);
400 return error; 400 return error;
401 } 401 }
402
403 if (argc >= 2) {
404 if (strcasecmp("inverse", argv[1]) == 0) {
405 config->dragging_key = M_RIGHT_CLICK;
406 config->resizing_key = M_LEFT_CLICK;
407 } else if (strcasecmp("normal", argv[1]) == 0) {
408 config->dragging_key = M_LEFT_CLICK;
409 config->resizing_key = M_RIGHT_CLICK;
410 } else {
411 error = cmd_results_new(CMD_INVALID, "floating_modifier", "Invalid definition %s", argv[1]);
412 return error;
413 }
414 }
415 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 402 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
416} 403}
417 404
diff --git a/sway/config.c b/sway/config.c
index bb7ecf9e..966362cc 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -115,8 +115,6 @@ static void config_defaults(struct sway_config *config) {
115 list_add(config->modes, config->current_mode); 115 list_add(config->modes, config->current_mode);
116 116
117 config->floating_mod = 0; 117 config->floating_mod = 0;
118 config->dragging_key = M_LEFT_CLICK;
119 config->resizing_key = M_RIGHT_CLICK;
120 config->default_layout = L_NONE; 118 config->default_layout = L_NONE;
121 config->default_orientation = L_NONE; 119 config->default_orientation = L_NONE;
122 // Flags 120 // Flags
diff --git a/sway/input_state.c b/sway/input_state.c
index 24678f71..88506c92 100644
--- a/sway/input_state.c
+++ b/sway/input_state.c
@@ -194,16 +194,8 @@ void center_pointer_on(swayc_t *view) {
194 194
195// Mode set left/right click 195// Mode set left/right click
196 196
197static void pointer_mode_set_dragging(void) { 197static void pointer_mode_set_left(void) {
198 switch (config->dragging_key) { 198 set_initial_view(pointer_state.left.view);
199 case M_LEFT_CLICK:
200 set_initial_view(pointer_state.left.view);
201 break;
202 case M_RIGHT_CLICK:
203 set_initial_view(pointer_state.right.view);
204 break;
205 }
206
207 if (initial.ptr->is_floating) { 199 if (initial.ptr->is_floating) {
208 pointer_state.mode = M_DRAGGING | M_FLOATING; 200 pointer_state.mode = M_DRAGGING | M_FLOATING;
209 } else { 201 } else {
@@ -216,15 +208,8 @@ static void pointer_mode_set_dragging(void) {
216 } 208 }
217} 209}
218 210
219static void pointer_mode_set_resizing(void) { 211static void pointer_mode_set_right(void) {
220 switch (config->resizing_key) { 212 set_initial_view(pointer_state.right.view);
221 case M_LEFT_CLICK:
222 set_initial_view(pointer_state.left.view);
223 break;
224 case M_RIGHT_CLICK:
225 set_initial_view(pointer_state.right.view);
226 break;
227 }
228 // Setup locking information 213 // Setup locking information
229 int midway_x = initial.ptr->x + initial.ptr->width/2; 214 int midway_x = initial.ptr->x + initial.ptr->width/2;
230 int midway_y = initial.ptr->y + initial.ptr->height/2; 215 int midway_y = initial.ptr->y + initial.ptr->height/2;
@@ -248,19 +233,15 @@ void pointer_mode_set(uint32_t button, bool condition) {
248 // switch on drag/resize mode 233 // switch on drag/resize mode
249 switch (pointer_state.mode & (M_DRAGGING | M_RESIZING)) { 234 switch (pointer_state.mode & (M_DRAGGING | M_RESIZING)) {
250 case M_DRAGGING: 235 case M_DRAGGING:
251 // end drag mode when 'dragging' click is unpressed 236 // end drag mode when left click is unpressed
252 if (config->dragging_key == M_LEFT_CLICK && !pointer_state.left.held) { 237 if (!pointer_state.left.held) {
253 pointer_state.mode = 0;
254 } else if (config->dragging_key == M_RIGHT_CLICK && !pointer_state.right.held) {
255 pointer_state.mode = 0; 238 pointer_state.mode = 0;
256 } 239 }
257 break; 240 break;
258 241
259 case M_RESIZING: 242 case M_RESIZING:
260 // end resize mode when 'resizing' click is unpressed 243 // end resize mode when right click is unpressed
261 if (config->resizing_key == M_LEFT_CLICK && !pointer_state.left.held) { 244 if (!pointer_state.right.held) {
262 pointer_state.mode = 0;
263 } else if (config->resizing_key == M_RIGHT_CLICK && !pointer_state.right.held) {
264 pointer_state.mode = 0; 245 pointer_state.mode = 0;
265 } 246 }
266 break; 247 break;
@@ -274,27 +255,19 @@ void pointer_mode_set(uint32_t button, bool condition) {
274 255
275 // Set mode depending on current button press 256 // Set mode depending on current button press
276 switch (button) { 257 switch (button) {
277 // Start left-click mode 258 // Start dragging mode
278 case M_LEFT_CLICK: 259 case M_LEFT_CLICK:
279 // if button release dont do anything 260 // if button release dont do anything
280 if (pointer_state.left.held) { 261 if (pointer_state.left.held) {
281 if (config->dragging_key == M_LEFT_CLICK) { 262 pointer_mode_set_left();
282 pointer_mode_set_dragging();
283 } else if (config->resizing_key == M_LEFT_CLICK) {
284 pointer_mode_set_resizing();
285 }
286 } 263 }
287 break; 264 break;
288 265
289 // Start right-click mode 266 // Start resize mode
290 case M_RIGHT_CLICK: 267 case M_RIGHT_CLICK:
291 // if button release dont do anyhting 268 // if button release dont do anyhting
292 if (pointer_state.right.held) { 269 if (pointer_state.right.held) {
293 if (config->dragging_key == M_RIGHT_CLICK) { 270 pointer_mode_set_right();
294 pointer_mode_set_dragging();
295 } else if (config->resizing_key == M_RIGHT_CLICK) {
296 pointer_mode_set_resizing();
297 }
298 } 271 }
299 break; 272 break;
300 } 273 }
@@ -314,17 +287,8 @@ void pointer_mode_update(void) {
314 switch (pointer_state.mode) { 287 switch (pointer_state.mode) {
315 case M_FLOATING | M_DRAGGING: 288 case M_FLOATING | M_DRAGGING:
316 // Update position 289 // Update position
317 switch (config->resizing_key) { 290 dx -= pointer_state.left.x;
318 case M_LEFT_CLICK: 291 dy -= pointer_state.left.y;
319 dx -= pointer_state.left.x;
320 dy -= pointer_state.left.y;
321 break;
322 case M_RIGHT_CLICK:
323 dx -= pointer_state.right.x;
324 dy -= pointer_state.right.y;
325 break;
326 }
327
328 if (initial.x + dx != initial.ptr->x) { 292 if (initial.x + dx != initial.ptr->x) {
329 initial.ptr->x = initial.x + dx; 293 initial.ptr->x = initial.x + dx;
330 } 294 }
@@ -335,19 +299,9 @@ void pointer_mode_update(void) {
335 break; 299 break;
336 300
337 case M_FLOATING | M_RESIZING: 301 case M_FLOATING | M_RESIZING:
338 switch (config->resizing_key) { 302 dx -= pointer_state.right.x;
339 case M_LEFT_CLICK: 303 dy -= pointer_state.right.y;
340 dx -= pointer_state.left.x; 304 initial.ptr = pointer_state.right.view;
341 dy -= pointer_state.left.y;
342 initial.ptr = pointer_state.left.view;
343 break;
344 case M_RIGHT_CLICK:
345 dx -= pointer_state.right.x;
346 dy -= pointer_state.right.y;
347 initial.ptr = pointer_state.right.view;
348 break;
349 }
350
351 if (lock.left) { 305 if (lock.left) {
352 if (initial.w + dx > min_sane_w) { 306 if (initial.w + dx > min_sane_w) {
353 initial.ptr->width = initial.w + dx; 307 initial.ptr->width = initial.w + dx;
@@ -387,17 +341,8 @@ void pointer_mode_update(void) {
387 break; 341 break;
388 342
389 case M_TILING | M_RESIZING: 343 case M_TILING | M_RESIZING:
390 switch (config->resizing_key) { 344 dx -= pointer_state.right.x;
391 case M_LEFT_CLICK: 345 dy -= pointer_state.right.y;
392 dx -= pointer_state.left.x;
393 dy -= pointer_state.left.y;
394 break;
395 case M_RIGHT_CLICK:
396 dx -= pointer_state.right.x;
397 dy -= pointer_state.right.y;
398 break;
399 }
400
401 // resize if we can 346 // resize if we can
402 if (initial.horiz.ptr) { 347 if (initial.horiz.ptr) {
403 if (lock.left) { 348 if (lock.left) {