Skip to content

Commit

Permalink
Merge branch 'master' of github.com:swaywm/sway into swaywm-master
Browse files Browse the repository at this point in the history
  • Loading branch information
SoumyaRanjanPatnaik committed Jan 10, 2023
2 parents 1046042 + 3061999 commit 74d82ea
Show file tree
Hide file tree
Showing 72 changed files with 990 additions and 505 deletions.
2 changes: 1 addition & 1 deletion .builds/alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packages:
- wayland-protocols
- xcb-util-image-dev
- xcb-util-wm-dev
- xwayland
- xwayland-dev
- hwdata
sources:
- https://github.com/swaywm/sway
Expand Down
1 change: 1 addition & 0 deletions .builds/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ packages:
- x11/libX11
- x11/pixman
- x11/xcb-util-wm
- x11-servers/xwayland-devel
- misc/hwdata
sources:
- https://github.com/swaywm/sway
Expand Down
95 changes: 95 additions & 0 deletions README.cs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# sway

[English][en] - **[Česky][cs]** - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [Svenska][sv] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]

sway je s [i3] kompatibilní [Wayland] kompozitor. Přečtěte si [FAQ]. Připojte se na
[IRC kanál][IRC channel] \(#sway na irc.libera.chat).

## Podpisy vydání

Vydání jsou podepsána [E88F5E48] a publikována [na GitHubu][GitHub releases].

## Instalace

### Z balíčků

Sway je dostupný ve spoustě distribucí. Zkuste nainstalovat balíček "sway" ve vaší
distribuci.

### Kompilace ze zdrojových kódů

Podívejte se na [tuto stránku wiki][Development setup], pokud chcete sestavit HEAD
sway a wlroots pro testování nebo vývoj.

Nainstalujte závislosti:

* meson \*
* [wlroots]
* wayland
* wayland-protocols \*
* pcre2
* json-c
* pango
* cairo
* gdk-pixbuf2 (volitelné: oznamovací oblast)
* [scdoc] (volitelné: manuálové stránky) \*
* git (volitelné: informace o verzi) \*

_\* Závislost pouze pro sestavení_

Spusťte tyto příkazy:

meson build/
ninja -C build/
sudo ninja -C build/ install

Na systémech bez logind či seatd musíte binární soubor sway nastavit jako suid:

sudo chmod a+s /usr/local/bin/sway

Sway svá root oprávnění zruší krátce po spuštění.

## Konfigurace

Pokud již používáte i3, zkopírujte svou konfiguraci i3 do `~/.config/sway/config`
a ta bude ihned fungovat. Jinak zkopírujte do `~/.config/sway/config` ukázkový
konfigurační soubor. Ten se obvykle nachází v `/etc/sway/config`.
Pro více informací o konfiguraci spusťte `man 5 sway`.

## Spuštění

Spusťte `sway` z TTY. Některé správce zobrazení mohou fungovat, ale nejsou
podporovány sway (je známo, že gdm funguje docela dobře).

[en]: https://github.com/swaywm/sway#readme
[cs]: README.cs.md
[de]: README.de.md
[dk]: README.dk.md
[es]: README.es.md
[fr]: README.fr.md
[sv]: README.sv.md
[gr]: README.gr.md
[hi]: README.hi.md
[hu]: README.hu.md
[ir]: README.ir.md
[it]: README.it.md
[ja]: README.ja.md
[ko]: README.ko.md
[nl]: README.nl.md
[pl]: README.pl.md
[pt]: README.pt.md
[ro]: README.ro.md
[ru]: README.ru.md
[tr]: README.tr.md
[uk]: README.uk.md
[zh-CN]: README.zh-CN.md
[zh-TW]: README.zh-TW.md
[i3]: https://i3wm.org/
[Wayland]: http://wayland.freedesktop.org/
[FAQ]: https://github.com/swaywm/sway/wiki
[IRC channel]: https://web.libera.chat/gamja/?channels=#sway
[E88F5E48]: https://keys.openpgp.org/search?q=34FF9526CFEF0E97A340E2E40FDE7BE0E88F5E48
[GitHub releases]: https://github.com/swaywm/sway/releases
[Development setup]: https://github.com/swaywm/sway/wiki/Development-Setup
[wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots
[scdoc]: https://git.sr.ht/~sircmpwn/scdoc
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sway

**[English][en]** - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [Svenska][sv] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]
**[English][en]** - [Česky][cs] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [Svenska][sv] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]

sway is an [i3]-compatible [Wayland] compositor. Read the [FAQ]. Join the
[IRC channel] \(#sway on irc.libera.chat).
Expand Down Expand Up @@ -62,6 +62,7 @@ Run `sway` from a TTY. Some display managers may work but are not supported by
sway (gdm is known to work fairly well).

[en]: https://github.com/swaywm/sway#readme
[cs]: README.cs.md
[de]: README.de.md
[dk]: README.dk.md
[es]: README.es.md
Expand Down
66 changes: 31 additions & 35 deletions client/pool-buffer.c
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
#define _POSIX_C_SOURCE 200809
#include <assert.h>
#include <cairo.h>
#include <errno.h>
#include <fcntl.h>
#include <pango/pangocairo.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
#include <wayland-client.h>
#include "config.h"
#include "pool-buffer.h"
#include "util.h"

static int create_pool_file(size_t size, char **name) {
static const char template[] = "sway-client-XXXXXX";
const char *path = getenv("XDG_RUNTIME_DIR");
if (path == NULL) {
fprintf(stderr, "XDG_RUNTIME_DIR is not set\n");
return -1;
}

size_t name_size = strlen(template) + 1 + strlen(path) + 1;
*name = malloc(name_size);
if (*name == NULL) {
fprintf(stderr, "allocation failed\n");
return -1;
}
snprintf(*name, name_size, "%s/%s", path, template);

int fd = mkstemp(*name);
if (fd < 0) {
return -1;
}

if (!sway_set_cloexec(fd, true)) {
close(fd);
return -1;
}
static int anonymous_shm_open(void) {
int retries = 100;

do {
// try a probably-unique name
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
pid_t pid = getpid();
char name[50];
snprintf(name, sizeof(name), "/sway-%x-%x",
(unsigned int)pid, (unsigned int)ts.tv_nsec);

// shm_open guarantees that O_CLOEXEC is set
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (fd >= 0) {
shm_unlink(name);
return fd;
}

if (ftruncate(fd, size) < 0) {
close(fd);
return -1;
}
--retries;
} while (retries > 0 && errno == EEXIST);

return fd;
return -1;
}

static void buffer_release(void *data, struct wl_buffer *wl_buffer) {
Expand All @@ -62,17 +55,20 @@ static struct pool_buffer *create_buffer(struct wl_shm *shm,
uint32_t stride = width * 4;
size_t size = stride * height;

char *name;
int fd = create_pool_file(size, &name);
assert(fd != -1);
int fd = anonymous_shm_open();
if (fd == -1) {
return NULL;
}
if (ftruncate(fd, size) < 0) {
close(fd);
return NULL;
}
void *data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
struct wl_shm_pool *pool = wl_shm_create_pool(shm, fd, size);
buf->buffer = wl_shm_pool_create_buffer(pool, 0,
width, height, stride, format);
wl_shm_pool_destroy(pool);
close(fd);
unlink(name);
free(name);

buf->size = size;
buf->width = width;
Expand Down
57 changes: 57 additions & 0 deletions completions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
if get_option('zsh-completions')
zsh_files = files(
'zsh/_sway',
'zsh/_swaymsg',
)
zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')

install_data(zsh_files, install_dir: zsh_install_dir)
endif

if get_option('bash-completions')
bash_comp = dependency('bash-completion', required: false)

bash_files = files(
'bash/sway',
'bash/swaymsg',
)

if get_option('swaybar')
bash_files += files('bash/swaybar')
endif

if bash_comp.found()
bash_install_dir = bash_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
endif

install_data(bash_files, install_dir: bash_install_dir)
endif

if get_option('fish-completions')
fish_comp = dependency('fish', required: false)

fish_files = files(
'fish/sway.fish',
'fish/swaymsg.fish',
)

if get_option('swaynag')
fish_files += files('fish/swaynag.fish')
endif

if fish_comp.found()
fish_install_dir = fish_comp.get_variable(
pkgconfig: 'completionsdir',
pkgconfig_define: ['datadir', datadir]
)
else
fish_install_dir = join_paths(datadir, 'fish', 'vendor_completions.d')
endif

install_data(fish_files, install_dir: fish_install_dir)
endif
8 changes: 4 additions & 4 deletions include/sway/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct sway_container;
typedef struct cmd_results *sway_cmd(int argc, char **argv);

struct cmd_handler {
char *command;
const char *command;
sway_cmd *handle;
};

Expand Down Expand Up @@ -46,7 +46,7 @@ enum expected_args {
struct cmd_results *checkarg(int argc, const char *name,
enum expected_args type, int val);

const struct cmd_handler *find_handler(char *line,
const struct cmd_handler *find_handler(const char *line,
const struct cmd_handler *cmd_handlers, size_t handlers_size);

/**
Expand Down Expand Up @@ -159,12 +159,11 @@ sway_cmd cmd_new_float;
sway_cmd cmd_new_window;
sway_cmd cmd_nop;
sway_cmd cmd_opacity;
sway_cmd cmd_new_float;
sway_cmd cmd_new_window;
sway_cmd cmd_no_focus;
sway_cmd cmd_output;
sway_cmd cmd_permit;
sway_cmd cmd_popup_during_fullscreen;
sway_cmd cmd_primary_selection;
sway_cmd cmd_reject;
sway_cmd cmd_reload;
sway_cmd cmd_rename;
Expand Down Expand Up @@ -262,6 +261,7 @@ sway_cmd input_cmd_map_to_region;
sway_cmd input_cmd_middle_emulation;
sway_cmd input_cmd_natural_scroll;
sway_cmd input_cmd_pointer_accel;
sway_cmd input_cmd_rotation_angle;
sway_cmd input_cmd_scroll_factor;
sway_cmd input_cmd_repeat_delay;
sway_cmd input_cmd_repeat_rate;
Expand Down
4 changes: 3 additions & 1 deletion include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct input_config {
int middle_emulation;
int natural_scroll;
float pointer_accel;
float rotation_angle;
float scroll_factor;
int repeat_delay;
int repeat_rate;
Expand Down Expand Up @@ -530,6 +531,7 @@ struct sway_config {
bool auto_back_and_forth;
bool show_marks;
enum alignment title_align;
bool primary_selection;

bool tiling_drag;
int tiling_drag_threshold;
Expand Down Expand Up @@ -719,7 +721,7 @@ void free_workspace_config(struct workspace_config *wsc);
/**
* Updates the value of config->font_height based on the metrics for title's
* font as reported by pango.
*
*
* If the height has changed, all containers will be rearranged to take on the
* new size.
*/
Expand Down
33 changes: 33 additions & 0 deletions include/sway/desktop/launcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef _SWAY_LAUNCHER_H
#define _SWAY_LAUNCHER_H

#include <stdlib.h>
#include <wayland-server-core.h>

struct launcher_ctx {
pid_t pid;
char *name;
struct wlr_xdg_activation_token_v1 *token;
struct wl_listener token_destroy;

bool activated;

struct sway_node *node;
struct wl_listener node_destroy;

struct wl_list link; // sway_server::pending_launcher_ctxs
};

struct launcher_ctx *launcher_ctx_find_pid(pid_t pid);

struct sway_workspace *launcher_ctx_get_workspace(struct launcher_ctx *ctx);

void launcher_ctx_consume(struct launcher_ctx *ctx);

void launcher_ctx_destroy(struct launcher_ctx *ctx);

struct launcher_ctx *launcher_ctx_create(void);

const char *launcher_ctx_get_token_name(struct launcher_ctx *ctx);

#endif
1 change: 1 addition & 0 deletions include/sway/input/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct sway_cursor {
struct wl_listener tool_proximity;
struct wl_listener tool_button;
bool simulating_pointer_from_tool_tip;
bool simulating_pointer_from_tool_button;
uint32_t tool_buttons;

struct wl_listener request_set_cursor;
Expand Down
Loading

0 comments on commit 74d82ea

Please sign in to comment.