Add new command to set titlebar position

This commit is contained in:
Josip Janzic 2019-08-31 11:16:10 +02:00
parent 363c57984d
commit 69265ad34c
No known key found for this signature in database
GPG key ID: 210BC3C60D619EEE
6 changed files with 40 additions and 0 deletions

View file

@ -190,6 +190,7 @@ sway_cmd cmd_title_align;
sway_cmd cmd_title_format; sway_cmd cmd_title_format;
sway_cmd cmd_titlebar_border_thickness; sway_cmd cmd_titlebar_border_thickness;
sway_cmd cmd_titlebar_padding; sway_cmd cmd_titlebar_padding;
sway_cmd cmd_titlebar_position;
sway_cmd cmd_unbindcode; sway_cmd cmd_unbindcode;
sway_cmd cmd_unbindswitch; sway_cmd cmd_unbindswitch;
sway_cmd cmd_unbindgesture; sway_cmd cmd_unbindgesture;

View file

@ -473,6 +473,11 @@ enum xwayland_mode {
XWAYLAND_MODE_IMMEDIATE, XWAYLAND_MODE_IMMEDIATE,
}; };
enum titlebar_position {
TITLEBAR_TOP,
TITLEBAR_BOTTOM
};
/** /**
* The configuration struct. The result of loading a config file. * The configuration struct. The result of loading a config file.
*/ */
@ -534,6 +539,7 @@ struct sway_config {
bool show_marks; bool show_marks;
enum alignment title_align; enum alignment title_align;
bool primary_selection; bool primary_selection;
enum titlebar_position titlebar_position;
bool tiling_drag; bool tiling_drag;
int tiling_drag_threshold; int tiling_drag_threshold;

View file

@ -93,6 +93,7 @@ static const struct cmd_handler handlers[] = {
{ "title_align", cmd_title_align }, { "title_align", cmd_title_align },
{ "titlebar_border_thickness", cmd_titlebar_border_thickness }, { "titlebar_border_thickness", cmd_titlebar_border_thickness },
{ "titlebar_padding", cmd_titlebar_padding }, { "titlebar_padding", cmd_titlebar_padding },
{ "titlebar_position", cmd_titlebar_position },
{ "unbindcode", cmd_unbindcode }, { "unbindcode", cmd_unbindcode },
{ "unbindgesture", cmd_unbindgesture }, { "unbindgesture", cmd_unbindgesture },
{ "unbindswitch", cmd_unbindswitch }, { "unbindswitch", cmd_unbindswitch },

View file

@ -0,0 +1,30 @@
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/output.h"
#include "sway/tree/arrange.h"
#include "sway/tree/root.h"
struct cmd_results *cmd_titlebar_position(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "titlebar_position", EXPECTED_AT_LEAST, 1))) {
return error;
}
if (strcmp(argv[0], "top") == 0) {
config->titlebar_position = TITLEBAR_TOP;
} else if (strcmp(argv[0], "bottom") == 0) {
config->titlebar_position = TITLEBAR_BOTTOM;
} else {
return cmd_results_new(CMD_INVALID,
"Expected 'titlebar_position top|bottom'");
}
arrange_root();
for (int i = 0; i < root->outputs->length; ++i) {
struct sway_output *output = root->outputs->items[i];
output_damage_whole(output);
}
return cmd_results_new(CMD_SUCCESS, NULL);
}

View file

@ -271,6 +271,7 @@ static void config_defaults(struct sway_config *config) {
config->reading = false; config->reading = false;
config->show_marks = true; config->show_marks = true;
config->title_align = ALIGN_LEFT; config->title_align = ALIGN_LEFT;
config->titlebar_position = TITLEBAR_TOP;
config->tiling_drag = true; config->tiling_drag = true;
config->tiling_drag_threshold = 9; config->tiling_drag_threshold = 9;
config->primary_selection = true; config->primary_selection = true;

View file

@ -117,6 +117,7 @@ sway_sources = files(
'commands/title_format.c', 'commands/title_format.c',
'commands/titlebar_border_thickness.c', 'commands/titlebar_border_thickness.c',
'commands/titlebar_padding.c', 'commands/titlebar_padding.c',
'commands/titlebar_position.c',
'commands/unmark.c', 'commands/unmark.c',
'commands/urgent.c', 'commands/urgent.c',
'commands/workspace.c', 'commands/workspace.c',