mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Fixed move scratchpad and added in scratchpad show
This commit is contained in:
		
							parent
							
								
									7eefecf479
								
							
						
					
					
						commit
						167409702f
					
				
					 2 changed files with 58 additions and 21 deletions
				
			
		| 
						 | 
					@ -382,27 +382,23 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		move_container_to(view, get_focused_container(ws));
 | 
							move_container_to(view, get_focused_container(ws));
 | 
				
			||||||
	} else if (strcasecmp(argv[0], "scratchpad") == 0) {
 | 
						} else if (strcasecmp(argv[0], "scratchpad") == 0) {
 | 
				
			||||||
		int i;
 | 
							if (view->type != C_CONTAINER && view->type != C_VIEW) {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		swayc_t *view = get_focused_container(&root_container);
 | 
							swayc_t *view = get_focused_container(&root_container);
 | 
				
			||||||
		list_add(scratchpad, view);
 | 
							list_add(scratchpad, view);
 | 
				
			||||||
		if (view->is_floating) {
 | 
							if (!view->is_floating) {
 | 
				
			||||||
			for (i = 0; i < view->parent->floating; i++) {
 | 
								destroy_container(remove_child(view));
 | 
				
			||||||
				if (view->parent->floating->items[i] == view) {
 | 
					 | 
				
			||||||
					list_del(view->parent->floating, i);
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			wlc_view_set_mask(view->handle, 0);
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			for (i = 0; i < view->parent->children) {
 | 
								remove_child(view);
 | 
				
			||||||
				if (view->parent->children->items[i] == view) {
 | 
					 | 
				
			||||||
					list_del(view->parent->children, i);
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		wlc_view_set_mask(view->handle, 0);
 | 
							wlc_view_set_mask(view->handle, 0);
 | 
				
			||||||
 | 
							arrange_windows(swayc_active_workspace(), -1, -1);
 | 
				
			||||||
 | 
							swayc_t *focused = container_under_pointer();
 | 
				
			||||||
 | 
							if (focused == NULL) {
 | 
				
			||||||
 | 
								focused = swayc_active_workspace();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		arrange_windows(&root_container, -1, -1);
 | 
							set_focused_container(focused);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -594,6 +590,37 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool cmd_scratchpad(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
 | 
						if (!checkarg(argc, "scratchpad", EXPECTED_EQUAL_TO, 1)) {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (strcasecmp(argv[0], "show") == 0) {
 | 
				
			||||||
 | 
							if (scratchpad->length > 0) {
 | 
				
			||||||
 | 
								swayc_t *view = scratchpad->items[0];
 | 
				
			||||||
 | 
								list_del(scratchpad, 0);
 | 
				
			||||||
 | 
								add_floating(swayc_active_workspace(), view);
 | 
				
			||||||
 | 
								view->x = (swayc_active_workspace()->width - view->width)/2;
 | 
				
			||||||
 | 
								view->y = (swayc_active_workspace()->height - view->height)/2;
 | 
				
			||||||
 | 
								if (view->desired_width != -1) {
 | 
				
			||||||
 | 
									view->width = view->desired_width;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if (view->desired_height != -1) {
 | 
				
			||||||
 | 
									view->height = view->desired_height;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								wlc_view_set_mask(view->handle, VISIBLE);
 | 
				
			||||||
 | 
								arrange_windows(swayc_active_workspace(), -1, -1);
 | 
				
			||||||
 | 
								swayc_t *focused = container_under_pointer();
 | 
				
			||||||
 | 
								if (focused == NULL) {
 | 
				
			||||||
 | 
									focused = swayc_active_workspace();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								set_focused_container(focused);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool cmd_set(struct sway_config *config, int argc, char **argv) {
 | 
					static bool cmd_set(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
	if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) {
 | 
						if (!checkarg(argc, "set", EXPECTED_EQUAL_TO, 2)) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,12 +26,22 @@ void init_layout(void) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int index_child(const swayc_t *child) {
 | 
					int index_child(const swayc_t *child) {
 | 
				
			||||||
	swayc_t *parent = child->parent;
 | 
						swayc_t *parent = child->parent;
 | 
				
			||||||
	int i, len = parent->children->length;
 | 
						int i, len;
 | 
				
			||||||
 | 
						if (!child->is_floating) {
 | 
				
			||||||
 | 
							len = parent->children->length;
 | 
				
			||||||
		for (i = 0; i < len; ++i) {
 | 
							for (i = 0; i < len; ++i) {
 | 
				
			||||||
			if (parent->children->items[i] == child) {
 | 
								if (parent->children->items[i] == child) {
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							len = parent->floating->length;
 | 
				
			||||||
 | 
							for (i = 0; i < len; ++i) {
 | 
				
			||||||
 | 
								if (parent->floating->items[i] == child) {
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (!sway_assert(i < len, "Stray container")) {
 | 
						if (!sway_assert(i < len, "Stray container")) {
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue