Merge branch 'master' of git://github.com/SirCmpwn/sway into swaylock

This commit is contained in:
Aaron Ouellette 2016-03-18 17:09:11 -04:00
commit 8af6a419ec
15 changed files with 168 additions and 23 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2015 Drew DeVault
Copyright (c) 2016 Drew DeVault
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

4
config
View File

@ -106,9 +106,9 @@ output * bg /usr/share/sway/wallpaper.jpg fill
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+h or $mod+v, for horizontal and vertical splits
# $mod+s or $mod+v, for horizontal and vertical splits
# respectively.
bindsym $mod+h splith
bindsym $mod+s splith
bindsym $mod+v splitv
# Switch the current container between different layout styles

View File

@ -28,7 +28,6 @@ struct desktop_shell_state {
list_t *panels;
list_t *lock_surfaces;
bool is_locked;
struct wlc_size panel_size;
};
struct swaylock_state {

View File

@ -7,7 +7,7 @@
extern char *prev_workspace_name;
char *workspace_next_name(void);
char *workspace_next_name(const char *output_name);
swayc_t *workspace_create(const char*);
swayc_t *workspace_by_name(const char*);
swayc_t *workspace_by_number(const char*);

View File

@ -57,3 +57,4 @@ install(
add_manpage(sway 1)
add_manpage(sway 5)
add_manpage(sway-input 5)
add_manpage(sway-bar 5)

View File

@ -362,10 +362,8 @@ static struct cmd_results *cmd_exec_always(int argc, char **argv) {
return error;
}
add_quotes(argv + 1, argc - 1);
tmp = join_args(argv + 1, argc - 1);
} else {
add_quotes(argv, argc);
tmp = join_args(argv, argc);
}
@ -2869,10 +2867,12 @@ struct cmd_results *handle_command(char *_exec) {
//TODO better handling of argv
int argc;
char **argv = split_args(cmd, &argc);
int i;
for (i = 1; i < argc; ++i) {
if (*argv[i] == '\"' || *argv[i] == '\'') {
strip_quotes(argv[i]);
if (strcmp(argv[0], "exec") != 0) {
int i;
for (i = 1; i < argc; ++i) {
if (*argv[i] == '\"' || *argv[i] == '\'') {
strip_quotes(argv[i]);
}
}
}
struct cmd_handler *handler = find_handler(argv[0], CMD_BLOCK_END);

View File

@ -143,7 +143,7 @@ swayc_t *new_output(wlc_handle handle) {
}
}
if (!ws_name) {
ws_name = workspace_next_name();
ws_name = workspace_next_name(output->name);
}
// create and initilize default workspace

View File

@ -1,10 +1,12 @@
#include <stdlib.h>
#include <wlc/wlc.h>
#include <wlc/wlc-wayland.h>
#include <wlc/wlc-render.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "wayland-swaylock-server-protocol.h"
#include "layout.h"
#include "log.h"
#include "input_state.h"
#include "extensions.h"
struct desktop_shell_state desktop_shell;
@ -76,6 +78,7 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc
config->wl_surface_res = surface;
list_add(desktop_shell.backgrounds, config);
wl_resource_set_destructor(surface, background_surface_destructor);
wlc_output_schedule_render(config->output);
}
static void set_panel(struct wl_client *client, struct wl_resource *resource,
@ -90,8 +93,8 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource,
config->surface = wlc_resource_from_wl_surface_resource(surface);
config->wl_surface_res = surface;
wl_resource_set_destructor(surface, panel_surface_destructor);
desktop_shell.panel_size = *wlc_surface_get_size(config->surface);
arrange_windows(&root_container, -1, -1);
wlc_output_schedule_render(config->output);
}
static void desktop_set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {
@ -123,7 +126,14 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou
wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
workspace->fullscreen = view;
desktop_shell.is_locked = true;
set_focused_container(view);
// reset input state
input_init();
// set focus if the lockscreen is spawned on the currently
// active output
swayc_t *focus_output = swayc_active_output();
if (focus_output == output) {
set_focused_container(view);
}
arrange_windows(workspace, -1, -1);
list_add(desktop_shell.lock_surfaces, surface);
wl_resource_set_destructor(surface, lock_surface_destructor);

View File

@ -139,6 +139,11 @@ bool set_focused_container(swayc_t *c) {
wlc_view_focus(p->handle);
}
}
} else if (p->type == C_WORKSPACE) {
// remove previous focus if view_focus is unlocked
if (!locked_view_focus) {
wlc_view_focus(0);
}
}
if (active_ws != workspace) {

View File

@ -141,10 +141,6 @@ static void handle_output_pre_render(wlc_handle output) {
break;
}
wlc_surface_render(config->surface, &geo);
if (size.w != desktop_shell.panel_size.w || size.h != desktop_shell.panel_size.h) {
desktop_shell.panel_size = size;
arrange_windows(&root_container, -1, -1);
}
break;
}
}

View File

@ -364,7 +364,7 @@ void move_workspace_to(swayc_t* workspace, swayc_t* destination) {
// make sure source output has a workspace
if (src_op->children->length == 0) {
char *ws_name = workspace_next_name();
char *ws_name = workspace_next_name(src_op->name);
swayc_t *ws = new_workspace(src_op, ws_name);
ws->is_focused = true;
free(ws_name);

112
sway/sway-bar.5.txt Normal file
View File

@ -0,0 +1,112 @@
/////
vim:set ts=4 sw=4 tw=82 noet:
/////
sway-bar (5)
============
Name
----
sway-bar - bar configuration file and commands
Description
-----------
Sway allows for configuration of swaybar within the sway configuation file.
Swaybar commands must be used inside a _bar { }_ block in the config.
Commands
--------
**status_command** <status command>::
Executes the bar _status command_ with _sh -c_.
**id** <bar_id>::
Sets the ID of the bar.
**position** <top|bottom|left|right>::
Sets position of the bar. Default is _bottom_.
**output** <output>::
Restrict the bar to a certain output, can be specified multiple times. If the
output command is omitted, the bar will be displayed on all outputs.
**swaybar_command** <command>::
Executes custom bar command, default is _swaybar_.
**font** <font>::
Specifies the font to be used in the bar.
**separator_symbol** <symbol>::
Specifies the separator symbol to separate blocks on the bar.
**workspace_buttons** <yes|no>::
Enables or disables workspace buttons on the bar. Default is to enable
buttons.
**strip_workspace_numbers** <yes|no>::
If set to _yes_, then workspace numbers will be omitted from the workspace
button and only the custom name will be shown.
**binding_mode_indicator** <yes|no>::
Enable or disable binding mode indicator. It's enabled by default.
**height** <height>::
Sets the height of the bar. Default height will match the font size.
Colors
------
Colors are defined within a _colors { }_ block inside a _bar { }_ block. Colors
must be defined in hex. E.g. _#fff000_ or _#fff000ff_ when including the alpha
channel.
**background** <color>::
Background color of the bar.
**statusline** <color>::
Text color to be used for the statusline.
**separator** <color>::
Text color to be used for the separator.
**focused_background** <color>::
Background color of the bar on the currently focused monitor output. If not
used, the color will be taken from _background_.
**focused_statusline** <color>::
Text color to be used for the statusline on the currently focused monitor
output. If not used, the color will be taken from _statusline_.
**focused_separator** <color>::
Text color to be used for the separator on the currently focused monitor
output. If not used, the color will be taken from _separator_.
**focused_workspace** <border> <background> <text>::
Border, background and text color for a workspace button when the workspace
has focus.
**active_workspace** <border> <background> <text>::
Border, background and text color for a workspace button when the workspace is
active (visible) on some output, but the focus is on another one. You can only
tell this apart from the focused workspace when you are using multiple
monitors.
**inactive_workspace** <border> <background> <text>::
Border, background and text color for a workspace button when the workspace
does not have focus and is not active (visible) on any output. This will be
the case for most workspaces.
**urgent_workspace** <border> <background> <text>::
Border, background and text color for a workspace button when the workspace
contains a window with the urgency hint set.
**binding_mode** <border> <background> <text>::
Border, background and text color for the binding mode indicator. If not used,
the colors will be taken from _urgent_workspace_.
See Also
--------
**sway**(5) **sway-input**(5)

View File

@ -48,4 +48,4 @@ Commands
See Also
--------
**sway**(5)
**sway**(5) **sway-bar**(5)

View File

@ -242,4 +242,4 @@ Currently supported attributes:
See Also
--------
**sway**(1) **sway-input**(5)
**sway**(1) **sway-input**(5) **sway-bar**(5)

View File

@ -25,8 +25,22 @@ struct workspace_by_number_data {
const char *name;
};
char *workspace_next_name(void) {
sway_log(L_DEBUG, "Workspace: Generating new name");
static bool workspace_valid_on_output(const char *output_name, const char *ws_name) {
int i;
for (i = 0; i < config->workspace_outputs->length; ++i) {
struct workspace_output *wso = config->workspace_outputs->items[i];
if (strcasecmp(wso->workspace, ws_name) == 0) {
if (strcasecmp(wso->output, output_name) != 0) {
return false;
}
}
}
return true;
}
char *workspace_next_name(const char *output_name) {
sway_log(L_DEBUG, "Workspace: Generating new workspace name for output %s", output_name);
int i;
int l = 1;
// Scan all workspace bindings to find the next available workspace name,
@ -73,6 +87,14 @@ char *workspace_next_name(void) {
free(_target);
continue;
}
// make sure that the workspace can appear on the given
// output
if (!workspace_valid_on_output(output_name, _target)) {
free(_target);
continue;
}
if (binding->order < order) {
order = binding->order;
target = _target;