@ -5,6 +5,7 @@
# include <wlr/types/wlr_output_layout.h>
# include "sway/desktop/transaction.h"
# include "sway/input/seat.h"
# include "sway/ipc-server.h"
# include "sway/output.h"
# include "sway/tree/arrange.h"
# include "sway/tree/container.h"
@ -75,6 +76,8 @@ void root_scratchpad_add_container(struct sway_container *con) {
arrange_workspace ( workspace ) ;
seat_set_focus ( seat , seat_get_focus_inactive ( seat , & workspace - > node ) ) ;
}
ipc_event_window ( con , " move " ) ;
}
void root_scratchpad_remove_container ( struct sway_container * con ) {
@ -85,45 +88,51 @@ void root_scratchpad_remove_container(struct sway_container *con) {
int index = list_find ( root - > scratchpad , con ) ;
if ( index ! = - 1 ) {
list_del ( root - > scratchpad , index ) ;
ipc_event_window ( con , " move " ) ;
}
}
void root_scratchpad_show ( struct sway_container * con ) {
struct sway_seat * seat = input_manager_current_seat ( ) ;
struct sway_workspace * ws = seat_get_focused_workspace ( seat ) ;
struct sway_workspace * new_ws = seat_get_focused_workspace ( seat ) ;
struct sway_workspace * old_ws = con - > workspace ;
// If the current con or any of its parents are in fullscreen mode, we
// first need to disable it before showing the scratchpad con.
if ( ws- > fullscreen ) {
container_set_fullscreen ( ws- > fullscreen , false ) ;
// If the current con or any of its parents are in fullscreen mode, we
// first need to disable it before showing the scratchpad con.
if ( new_ ws- > fullscreen ) {
container_set_fullscreen ( new_ ws- > fullscreen , false ) ;
}
// Show the container
if ( con- > workspace ) {
if ( old_ws ) {
container_detach ( con ) ;
}
workspace_add_floating ( ws, con ) ;
workspace_add_floating ( new_ ws, con ) ;
// Make sure the container's center point overlaps this workspace
double center_lx = con - > x + con - > width / 2 ;
double center_ly = con - > y + con - > height / 2 ;
struct wlr_box workspace_box ;
workspace_get_box ( ws, & workspace_box ) ;
workspace_get_box ( new_ ws, & workspace_box ) ;
if ( ! wlr_box_contains_point ( & workspace_box , center_lx , center_ly ) ) {
// Maybe resize it
if ( con - > width > ws- > width | | con - > height > ws- > height ) {
if ( con - > width > new_ ws- > width | | con - > height > new_ ws- > height ) {
container_init_floating ( con ) ;
}
// Center it
double new_lx = ws- > x + ( ws- > width - con - > width ) / 2 ;
double new_ly = ws- > y + ( ws- > height - con - > height ) / 2 ;
double new_lx = new_ ws- > x + ( new_ ws- > width - con - > width ) / 2 ;
double new_ly = new_ ws- > y + ( new_ ws- > height - con - > height ) / 2 ;
container_floating_move_to ( con , new_lx , new_ly ) ;
}
arrange_workspace ( ws) ;
arrange_workspace ( new_ ws) ;
seat_set_focus ( seat , seat_get_focus_inactive ( seat , & con - > node ) ) ;
if ( new_ws ! = old_ws ) {
ipc_event_window ( con , " move " ) ;
}
}
void root_scratchpad_hide ( struct sway_container * con ) {
@ -137,6 +146,8 @@ void root_scratchpad_hide(struct sway_container *con) {
seat_set_focus ( seat , seat_get_focus_inactive ( seat , & ws - > node ) ) ;
}
list_move_to_end ( root - > scratchpad , con ) ;
ipc_event_window ( con , " move " ) ;
}
struct pid_workspace {