mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Altered resize command to prevent resizing past min h/w
This commit is contained in:
		
							parent
							
								
									e067913fb8
								
							
						
					
					
						commit
						ad1ca31dd5
					
				
					 2 changed files with 117 additions and 32 deletions
				
			
		| 
						 | 
					@ -497,8 +497,49 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber);
 | 
							sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber);
 | 
				
			||||||
		//TODO: Ensure rounding is done in such a way that there are NO pixel leaks
 | 
							//TODO: Ensure rounding is done in such a way that there are NO pixel leaks
 | 
				
			||||||
		for (i = 0; i < parent->parent->children->length; i++) {
 | 
					 | 
				
			||||||
		bool valid = true;
 | 
							bool valid = true;
 | 
				
			||||||
 | 
							for (i = 0; i < parent->parent->children->length; i++) {
 | 
				
			||||||
 | 
								sibling = parent->parent->children->items[i];
 | 
				
			||||||
 | 
								if (sibling->x != focused->x) {
 | 
				
			||||||
 | 
									if (sibling->x < parent->x) {
 | 
				
			||||||
 | 
										double pixels = -1 * amount;
 | 
				
			||||||
 | 
										pixels /= lnumber;
 | 
				
			||||||
 | 
										if (rnumber) {
 | 
				
			||||||
 | 
											if ((sibling->width + pixels/2) < min_sane_w) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											if ((sibling->width + pixels) < min_sane_w) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									} else if (sibling->x > parent->x) {
 | 
				
			||||||
 | 
										double pixels = -1 * amount;
 | 
				
			||||||
 | 
										pixels /= rnumber;
 | 
				
			||||||
 | 
										if (lnumber) {
 | 
				
			||||||
 | 
											if ((sibling->width + pixels/2) < min_sane_w) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											if ((sibling->width + pixels) < min_sane_w) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									double pixels = amount;
 | 
				
			||||||
 | 
									if (parent->width + pixels < min_sane_w) {
 | 
				
			||||||
 | 
										valid = false;
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (valid) {
 | 
				
			||||||
 | 
								for (i = 0; i < parent->parent->children->length; i++) {
 | 
				
			||||||
				sibling = parent->parent->children->items[i];
 | 
									sibling = parent->parent->children->items[i];
 | 
				
			||||||
				if (sibling->x != focused->x) {
 | 
									if (sibling->x != focused->x) {
 | 
				
			||||||
					if (sibling->x < parent->x) {
 | 
										if (sibling->x < parent->x) {
 | 
				
			||||||
| 
						 | 
					@ -534,6 +575,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
			// Recursive resize does not handle positions, let arrange_windows
 | 
								// Recursive resize does not handle positions, let arrange_windows
 | 
				
			||||||
			// take care of that.
 | 
								// take care of that.
 | 
				
			||||||
			arrange_windows(swayc_active_workspace(), -1, -1);
 | 
								arrange_windows(swayc_active_workspace(), -1, -1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	} else if (strcmp(argv[1], "height") == 0) {
 | 
						} else if (strcmp(argv[1], "height") == 0) {
 | 
				
			||||||
		int tnumber = 0;
 | 
							int tnumber = 0;
 | 
				
			||||||
| 
						 | 
					@ -561,6 +603,48 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		sway_log(L_DEBUG, "Found the proper parent: %p. It has %d b conts, and %d t conts", parent->parent, bnumber, tnumber);
 | 
							sway_log(L_DEBUG, "Found the proper parent: %p. It has %d b conts, and %d t conts", parent->parent, bnumber, tnumber);
 | 
				
			||||||
		//TODO: Ensure rounding is done in such a way that there are NO pixel leaks
 | 
							//TODO: Ensure rounding is done in such a way that there are NO pixel leaks
 | 
				
			||||||
 | 
							bool valid = true;
 | 
				
			||||||
 | 
							for (i = 0; i < parent->parent->children->length; i++) {
 | 
				
			||||||
 | 
								sibling = parent->parent->children->items[i];
 | 
				
			||||||
 | 
								if (sibling->y != focused->y) {
 | 
				
			||||||
 | 
									if (sibling->y < parent->y) {
 | 
				
			||||||
 | 
										double pixels = -1 * amount;
 | 
				
			||||||
 | 
										pixels /= bnumber;
 | 
				
			||||||
 | 
										if (tnumber) {
 | 
				
			||||||
 | 
											if ((sibling->height + pixels/2) < min_sane_h) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											if ((sibling->height + pixels) < min_sane_h) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									} else if (sibling->y > parent->y) {
 | 
				
			||||||
 | 
										double pixels = -1 * amount;
 | 
				
			||||||
 | 
										pixels /= tnumber;
 | 
				
			||||||
 | 
										if (bnumber) {
 | 
				
			||||||
 | 
											if ((sibling->height + pixels/2) < min_sane_h) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											if ((sibling->height + pixels) < min_sane_h) {
 | 
				
			||||||
 | 
												valid = false;
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									double pixels = amount;
 | 
				
			||||||
 | 
									if (parent->height + pixels < min_sane_h) {
 | 
				
			||||||
 | 
										valid = false;
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (valid) {
 | 
				
			||||||
			for (i = 0; i < parent->parent->children->length; i++) {
 | 
								for (i = 0; i < parent->parent->children->length; i++) {
 | 
				
			||||||
				sibling = parent->parent->children->items[i];
 | 
									sibling = parent->parent->children->items[i];
 | 
				
			||||||
				if (sibling->y != focused->y) {
 | 
									if (sibling->y != focused->y) {
 | 
				
			||||||
| 
						 | 
					@ -594,6 +678,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			arrange_windows(swayc_active_workspace(), -1, -1);
 | 
								arrange_windows(swayc_active_workspace(), -1, -1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -435,7 +435,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
 | 
				
			||||||
				} else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) {
 | 
									} else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) {
 | 
				
			||||||
					pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
 | 
										pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
 | 
				
			||||||
					pointer_state.lock.temp_up = true;
 | 
										pointer_state.lock.temp_up = true;
 | 
				
			||||||
				} else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) {
 | 
									} else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_DOWN) == view) {
 | 
				
			||||||
					pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
 | 
										pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
 | 
				
			||||||
					pointer_state.lock.temp_down = true;
 | 
										pointer_state.lock.temp_down = true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue