Implement scratchpad

Implements the following commands:

* move scratchpad
* scratchpad show
* [criteria] scratchpad show

Also fixes these:

* Fix memory leak when executing command with criteria
(use `list_free(views)` instead of `free(views)`)
* Fix crash when running `move to` with no further arguments
This commit is contained in:
Ryan Dwyer 2018-07-22 14:10:40 +10:00
parent 89dc047ca9
commit 81e8f31cc6
13 changed files with 290 additions and 5 deletions

26
include/sway/scratchpad.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef _SWAY_SCRATCHPAD_H
#define _SWAY_SCRATCHPAD_H
#include "tree/container.h"
/**
* Move a container to the scratchpad.
*/
void scratchpad_add_container(struct sway_container *con);
/**
* Remove a container from the scratchpad.
*/
void scratchpad_remove_container(struct sway_container *con);
/**
* Show or hide the next container on the scratchpad.
*/
void scratchpad_toggle_auto(void);
/**
* Show or hide a specific container on the scratchpad.
*/
void scratchpad_toggle_container(struct sway_container *con);
#endif

View file

@ -48,6 +48,8 @@ struct sway_server {
list_t *transactions;
list_t *dirty_containers;
list_t *scratchpad; // struct sway_container
};
struct sway_server server;

View file

@ -135,6 +135,11 @@ struct sway_container {
struct sway_container *parent;
// Indicates that the container is a scratchpad container.
// Both hidden and visible scratchpad containers have scratchpad=true.
// Hidden scratchpad containers have a NULL parent.
bool scratchpad;
float alpha;
struct wlr_texture *title_focused;