aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.bg.md7
-rw-r--r--README.de.md9
-rw-r--r--README.el.md2
-rw-r--r--README.fr.md8
-rw-r--r--README.it.md9
-rw-r--r--README.ja.md3
-rw-r--r--README.md8
-rw-r--r--README.pt.md6
-rw-r--r--README.ru.md8
-rw-r--r--README.uk.md10
-rw-r--r--common/ipc-client.c11
-rw-r--r--common/meson.build1
-rw-r--r--common/readline.c72
-rw-r--r--common/stringop.c25
-rw-r--r--common/util.c4
-rw-r--r--include/readline.h10
-rw-r--r--include/stringop.h5
-rw-r--r--include/sway/input/cursor.h2
-rw-r--r--sway/commands.c6
-rw-r--r--sway/commands/seat/cursor.c49
-rw-r--r--sway/config.c124
-rw-r--r--sway/desktop/transaction.c4
-rw-r--r--sway/input/cursor.c35
-rw-r--r--sway/input/input-manager.c2
-rw-r--r--sway/input/seat.c4
-rw-r--r--sway/main.c68
-rw-r--r--sway/server.c2
-rw-r--r--sway/sway.5.scd13
-rw-r--r--sway/tree/view.c10
-rw-r--r--swaybar/status_line.c1
-rw-r--r--swayidle/main.c13
-rw-r--r--swaylock/main.c33
-rw-r--r--swaylock/password.c8
-rw-r--r--swaylock/seat.c6
-rw-r--r--swaymsg/main.c1
-rw-r--r--swaynag/config.c62
36 files changed, 288 insertions, 353 deletions
diff --git a/README.bg.md b/README.bg.md
index efc99f15..87a15bed 100644
--- a/README.bg.md
+++ b/README.bg.md
@@ -1,8 +1,9 @@
# sway
-"**S**irCmpwn's **Way**land compositor" е в процес на разработка, съвместим с i3, [Wayland](http://wayland.freedesktop.org/) композитор.
-Прочетете [FAQ](https://github.com/swaywm/sway/wiki). Присъединете се в
-[IRC канала](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на
+Sway е в процес на разработка, съвместим с i3,
+[Wayland](http://wayland.freedesktop.org/) композитор. Прочетете
+[FAQ](https://github.com/swaywm/sway/wiki). Присъединете се в [IRC
+канала](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/README.de.md b/README.de.md
index 2c2e14e8..bf92b196 100644
--- a/README.de.md
+++ b/README.de.md
@@ -3,10 +3,11 @@
Der Fortschritt dieser Übersetzung kann [hier](https://github.com/swaywm/sway/issues/1318)
eingesehen werden.
-"**S**irCmpwn's **Way**land compositor" ist ein i3-kompatibler
-[Wayland](http://wayland.freedesktop.org/)-Kompositor. Lies die
-[FAQ](https://github.com/swaywm/sway/wiki#faq). Tritt dem
-[IRC-Channel](http://webchat.freenode.net/?channels=sway&uio=d4) bei (#sway in irc.freenode.net).
+Sway ist ein i3-kompatibler
+[Wayland](http://wayland.freedesktop.org/)-Kompositor. Lies die
+[FAQ](https://github.com/swaywm/sway/wiki#faq). Tritt dem
+[IRC-Channel](http://webchat.freenode.net/?channels=sway&uio=d4) bei (#sway in
+irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/README.el.md b/README.el.md
index 3c9d65c9..79acd422 100644
--- a/README.el.md
+++ b/README.el.md
@@ -1,6 +1,6 @@
# sway
-"Ο Sway (**S**irCmpwn's **Way**land) είναι ένας **υπό ανάπτυξη** [Wayland](http://wayland.freedesktop.org/) διαχειριστής παραθύρων συμβατός με τον αντίστοιχο διαχειριστή παραθύρων i3 για τον X11.
+Sway είναι ένας **υπό ανάπτυξη** [Wayland](http://wayland.freedesktop.org/) διαχειριστής παραθύρων συμβατός με τον αντίστοιχο διαχειριστή παραθύρων i3 για τον X11.
Διαβάστε τις [Συνήθεις Ερωτήσεις](https://github.com/swaywm/sway/wiki). Συνδεθείτε στο [κανάλι μας στο IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway στο
irc.freenode.net).
diff --git a/README.fr.md b/README.fr.md
index 935d288f..8ad4d3b6 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -1,9 +1,9 @@
# sway
-"**S**irCmpwn's **Way**land compositor" est un compositeur [Wayland](http://wayland.freedesktop.org/)
-compatible avec i3, **en cours de développement**.
-Lisez la [FAQ](https://github.com/swaywm/sway/wiki). Rejoignez le
-[canal IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway sur
+Sway est un compositeur [Wayland](http://wayland.freedesktop.org/) compatible
+avec i3, **en cours de développement**. Lisez la
+[FAQ](https://github.com/swaywm/sway/wiki). Rejoignez le [canal
+IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway sur
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/README.it.md b/README.it.md
index af986844..8a83bc78 100644
--- a/README.it.md
+++ b/README.it.md
@@ -1,10 +1,9 @@
# sway
-"**S**irCmpwn's **Way**land compositor" è un compositor
-[Wayland](http://wayland.freedesktop.org/) **in via di sviluppo**
-compatibile con i3.
-Leggi le [FAQ (in Inglese)](https://github.com/swaywm/sway/wiki). Unisciti al
-[canale IRC (in Inglese)](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on
+Sway è un compositor [Wayland](http://wayland.freedesktop.org/) **in via di
+sviluppo** compatibile con i3. Leggi le [FAQ (in
+Inglese)](https://github.com/swaywm/sway/wiki). Unisciti al [canale IRC (in
+Inglese)](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/README.ja.md b/README.ja.md
index b9e541f0..d82e78b2 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -1,7 +1,6 @@
# sway
-"**S**irCmpwn's **Way**land compositor"は**開発中**の
-i3互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。
+Swayは**開発中**のi3互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。
[FAQ](https://github.com/swaywm/sway/wiki)も合わせてご覧ください。
[IRC チャンネル](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on irc.freenode.net)もあります。
diff --git a/README.md b/README.md
index 6cb212fc..1deb9a4c 100644
--- a/README.md
+++ b/README.md
@@ -3,10 +3,10 @@
[**English**](https://github.com/swaywm/sway/blob/master/README.md#sway--) - [日本語](https://github.com/swaywm/sway/blob/master/README.ja.md#sway--) - [Deutsch](https://github.com/swaywm/sway/blob/master/README.de.md#sway--) - [Ελληνικά](https://github.com/swaywm/sway/blob/master/README.el.md#sway--) - [Français](https://github.com/swaywm/sway/blob/master/README.fr.md#sway--) - [Українська](https://github.com/swaywm/sway/blob/master/README.uk.md#sway--) - [Italiano](https://github.com/swaywm/sway/blob/master/README.it.md#sway--) - [Português](https://github.com/swaywm/sway/blob/master/README.pt.md#sway--) -
[Русский](https://github.com/swaywm/sway/blob/master/README.ru.md#sway--) - [Български](https://github.com/swaywm/sway/blob/master/README.bg.md#sway--)
-"**S**irCmpwn's **Way**land compositor" is a **work in progress**
-i3-compatible [Wayland](http://wayland.freedesktop.org/) compositor.
-Read the [FAQ](https://github.com/swaywm/sway/wiki). Join the
-[IRC channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on
+sway is a **work in progress** i3-compatible
+[Wayland](http://wayland.freedesktop.org/) compositor. Read the
+[FAQ](https://github.com/swaywm/sway/wiki). Join the [IRC
+channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on
irc.freenode.net).
If you'd like to support sway development, please contribute to [SirCmpwn's
diff --git a/README.pt.md b/README.pt.md
index 91e709c1..8cdfa548 100644
--- a/README.pt.md
+++ b/README.pt.md
@@ -1,8 +1,8 @@
# sway
-"**S**irCmpwn's **Way**land compositor" é um compositor [Wayland](http://wayland.freedesktop.org/)
-compatível com o i3. Leia o [FAQ](https://github.com/swaywm/sway/wiki). Participe do
-[canal IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway no
+Sway é um compositor [Wayland](http://wayland.freedesktop.org/) compatível com o
+i3. Leia o [FAQ](https://github.com/swaywm/sway/wiki). Participe do [canal
+IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway no
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/README.ru.md b/README.ru.md
index 4b34dc2d..255e36aa 100644
--- a/README.ru.md
+++ b/README.ru.md
@@ -1,9 +1,9 @@
# sway
-"**S**irCmpwn's **Way**land compositor" на данный момент **(в разработке)**
-i3-совместимый [Wayland](http://wayland.freedesktop.org/) композитор.
-Прочитайте [FAQ](https://github.com/swaywm/sway/wiki). Присоединяйтесь к
-[IRC каналу](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на
+Sway на данный момент **(в разработке)** i3-совместимый
+[Wayland](http://wayland.freedesktop.org/) композитор. Прочитайте
+[FAQ](https://github.com/swaywm/sway/wiki). Присоединяйтесь к [IRC
+каналу](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на
irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/README.uk.md b/README.uk.md
index 9ae7425a..5e9345b3 100644
--- a/README.uk.md
+++ b/README.uk.md
@@ -1,10 +1,10 @@
# sway
-**Sway** ("**S**irCmpwn's **Way**land compositor") це сумісний з i3 композитор
-[Wayland](http://wayland.freedesktop.org/) (**у стані розробки**).
-Ознайомтесь з [ЧаПами](https://github.com/swaywm/sway/wiki).
-Приєднуйтесь до [спільноти в IRC](http://webchat.freenode.net/?channels=sway&uio=d4)
-(#sway на irc.freenode.net).
+**Sway** це сумісний з i3 композитор [Wayland](http://wayland.freedesktop.org/)
+(**у стані розробки**). Ознайомтесь з
+[ЧаПами](https://github.com/swaywm/sway/wiki). Приєднуйтесь до [спільноти в
+IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на
+irc.freenode.net).
[![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png)
diff --git a/common/ipc-client.c b/common/ipc-client.c
index 496fd131..3515ef0a 100644
--- a/common/ipc-client.c
+++ b/common/ipc-client.c
@@ -7,7 +7,6 @@
#include <sys/un.h>
#include <unistd.h>
#include "ipc-client.h"
-#include "readline.h"
#include "log.h"
static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'};
@@ -18,28 +17,30 @@ char *get_socketpath(void) {
if (swaysock) {
return strdup(swaysock);
}
+ char *line = NULL;
+ size_t line_size = 0;
FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r");
if (fp) {
- char *line = read_line(fp);
+ getline(&line, &line_size, fp);
pclose(fp);
if (line && *line) {
return line;
}
- free(line);
}
const char *i3sock = getenv("I3SOCK");
if (i3sock) {
+ free(line);
return strdup(i3sock);
}
fp = popen("i3 --get-socketpath 2>/dev/null", "r");
if (fp) {
- char *line = read_line(fp);
+ getline(&line, &line_size, fp);
pclose(fp);
if (line && *line) {
return line;
}
- free(line);
}
+ free(line);
return NULL;
}
diff --git a/common/meson.build b/common/meson.build
index 224a9c3f..4ad872d1 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -8,7 +8,6 @@ lib_sway_common = static_library(
'loop.c',
'list.c',
'pango.c',
- 'readline.c',
'stringop.c',
'unicode.c',
'util.c'
diff --git a/common/readline.c b/common/readline.c
deleted file mode 100644
index 58652429..00000000
--- a/common/readline.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#define _POSIX_C_SOURCE 200809L
-#include "readline.h"
-#include "log.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-char *read_line(FILE *file) {
- size_t length = 0, size = 128;
- char *string = malloc(size);
- char lastChar = '\0';
- if (!string) {
- wlr_log(WLR_ERROR, "Unable to allocate memory for read_line");
- return NULL;
- }
- while (1) {
- int c = getc(file);
- if (c == '\n' && lastChar == '\\'){
- --length; // Ignore last character.
- lastChar = '\0';
- continue;
- }
- if (c == EOF || c == '\n' || c == '\0') {
- break;
- }
- if (c == '\r') {
- continue;
- }
- lastChar = c;
- if (length == size) {
- char *new_string = realloc(string, size *= 2);
- if (!new_string) {
- free(string);
- wlr_log(WLR_ERROR, "Unable to allocate memory for read_line");
- return NULL;
- }
- string = new_string;
- }
- string[length++] = c;
- }
- if (length + 1 == size) {
- char *new_string = realloc(string, length + 1);
- if (!new_string) {
- free(string);
- return NULL;
- }
- string = new_string;
- }
- string[length] = '\0';
- return string;
-}
-
-char *peek_line(FILE *file, int line_offset, long *position) {
- long pos = ftell(file);
- size_t length = 0;
- char *line = NULL;
- for (int i = 0; i <= line_offset; i++) {
- ssize_t read = getline(&line, &length, file);
- if (read < 0) {
- free(line);
- line = NULL;
- break;
- }
- if (read > 0 && line[read - 1] == '\n') {
- line[read - 1] = '\0';
- }
- }
- if (position) {
- *position = ftell(file);
- }
- fseek(file, pos, SEEK_SET);
- return line;
-}
diff --git a/common/stringop.c b/common/stringop.c
index 4b8c9a38..8af0d60f 100644
--- a/common/stringop.c
+++ b/common/stringop.c
@@ -9,24 +9,17 @@
#include "string.h"
#include "list.h"
-const char whitespace[] = " \f\n\r\t\v";
+static const char whitespace[] = " \f\n\r\t\v";
-char *strip_whitespace(char *_str) {
- if (*_str == '\0')
- return _str;
- char *strold = _str;
- while (*_str == ' ' || *_str == '\t') {
- _str++;
+void strip_whitespace(char *str) {
+ size_t len = strlen(str);
+ size_t start = strspn(str, whitespace);
+ memmove(str, &str[start], len + 1 - start);
+
+ if (*str) {
+ for (len -= start + 1; isspace(str[len]); --len) {}
+ str[len + 1] = '\0';
}
- char *str = strdup(_str);
- free(strold);
- int i;
- for (i = 0; str[i] != '\0'; ++i);
- do {
- i--;
- } while (i >= 0 && (str[i] == ' ' || str[i] == '\t'));
- str[i + 1] = '\0';
- return str;
}
void strip_quotes(char *str) {
diff --git a/common/util.c b/common/util.c
index 40c64230..d66058a6 100644
--- a/common/util.c
+++ b/common/util.c
@@ -13,7 +13,6 @@
#include <xkbcommon/xkbcommon-names.h>
#include <wlr/types/wlr_keyboard.h>
#include "log.h"
-#include "readline.h"
#include "util.h"
int wrap(int i, int max) {
@@ -87,11 +86,12 @@ pid_t get_parent_pid(pid_t child) {
char *token = NULL;
const char *sep = " ";
FILE *stat = NULL;
+ size_t buf_size = 0;
sprintf(file_name, "/proc/%d/stat", child);
if ((stat = fopen(file_name, "r"))) {
- if ((buffer = read_line(stat))) {
+ if (getline(&buffer, &buf_size, stat) != -1) {
token = strtok(buffer, sep); // pid
token = strtok(NULL, sep); // executable name
token = strtok(NULL, sep); // state
diff --git a/include/readline.h b/include/readline.h
deleted file mode 100644
index ee2eba5d..00000000
--- a/include/readline.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _SWAY_READLINE_H
-#define _SWAY_READLINE_H
-
-#include <stdio.h>
-
-char *read_line(FILE *file);
-char *peek_line(FILE *file, int line_offset, long *position);
-char *read_line_buffer(FILE *file, char *string, size_t string_len);
-
-#endif
diff --git a/include/stringop.h b/include/stringop.h
index d1bfa29d..f7ca60a5 100644
--- a/include/stringop.h
+++ b/include/stringop.h
@@ -3,10 +3,7 @@
#include "list.h"
-// array of whitespace characters to use for delims
-extern const char whitespace[];
-
-char *strip_whitespace(char *str);
+void strip_whitespace(char *str);
char *strip_comments(char *str);
void strip_quotes(char *str);
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
index 78489e21..22e278b0 100644
--- a/include/sway/input/cursor.h
+++ b/include/sway/input/cursor.h
@@ -61,6 +61,8 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
void cursor_rebase(struct sway_cursor *cursor);
void cursor_handle_activity(struct sway_cursor *cursor);
+void cursor_unhide(struct sway_cursor *cursor);
+int cursor_get_timeout(struct sway_cursor *cursor);
/**
* Like cursor_rebase, but also allows focus to change when the cursor enters a
diff --git a/sway/commands.c b/sway/commands.c
index 0883b57b..4e524a88 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -237,15 +237,15 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
criteria_destroy(criteria);
config->handler_context.using_criteria = true;
// Skip leading whitespace
- head += strspn(head, whitespace);
+ for (; isspace(*head); ++head) {}
}
// Split command list
cmdlist = argsep(&head, ";");
- cmdlist += strspn(cmdlist, whitespace);
+ for (; isspace(*cmdlist); ++cmdlist) {}
do {
// Split commands
cmd = argsep(&cmdlist, ",");
- cmd += strspn(cmd, whitespace);
+ for (; isspace(*cmd); ++cmd) {}
if (strcmp(cmd, "") == 0) {
wlr_log(WLR_INFO, "Ignoring empty command.");
continue;
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c
index 495c2338..b4728543 100644
--- a/sway/commands/seat/cursor.c
+++ b/sway/commands/seat/cursor.c
@@ -17,18 +17,8 @@ static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or "
"'cursor <set> <x> <y>' or "
"'curor <press|release> <left|right|1|2|3...>'";
-struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
- struct cmd_results *error = NULL;
- if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
- return error;
- }
- struct sway_seat *seat = config->handler_context.seat;
- if (!seat) {
- return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
- }
-
- struct sway_cursor *cursor = seat->cursor;
-
+static struct cmd_results *handle_command(struct sway_cursor *cursor,
+ int argc, char **argv) {
if (strcasecmp(argv[0], "move") == 0) {
if (argc < 3) {
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
@@ -50,6 +40,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
if (argc < 2) {
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
}
+ struct cmd_results *error = NULL;
if ((error = press_or_release(cursor, argv[0], argv[1]))) {
return error;
}
@@ -58,6 +49,40 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
+struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
+ return error;
+ }
+ struct seat_config *sc = config->handler_context.seat_config;
+ if (!sc) {
+ return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
+ }
+
+ if (config->reading || !config->active) {
+ return cmd_results_new(CMD_DEFER, NULL, NULL);
+ }
+
+ if (strcmp(sc->name, "*") != 0) {
+ struct sway_seat *seat = input_manager_get_seat(sc->name);
+ if (!seat) {
+ return cmd_results_new(CMD_FAILURE, "cursor",
+ "Failed to get seat");
+ }
+ error = handle_command(seat->cursor, argc, argv);
+ } else {
+ struct sway_seat *seat = NULL;
+ wl_list_for_each(seat, &server.input->seats, link) {
+ error = handle_command(seat->cursor, argc, argv);
+ if ((error && error->status != CMD_SUCCESS)) {
+ break;
+ }
+ }
+ }
+
+ return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
+
static struct cmd_results *press_or_release(struct sway_cursor *cursor,
char *action, char *button_str) {
enum wlr_button_state state;
diff --git a/sway/config.c b/sway/config.c
index 5d631b7e..8a0b293c 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 600 // for realpath
+#define _XOPEN_SOURCE 700 // for realpath
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -30,7 +30,6 @@
#include "sway/tree/workspace.h"
#include "cairo.h"
#include "pango.h"
-#include "readline.h"
#include "stringop.h"
#include "list.h"
#include "log.h"
@@ -571,28 +570,49 @@ bool load_include_configs(const char *path, struct sway_config *config,
return true;
}
-static int detect_brace_on_following_line(FILE *file, char *line,
- int line_number) {
- int lines = 0;
- if (line[strlen(line) - 1] != '{' && line[strlen(line) - 1] != '}') {
- char *peeked = NULL;
- long position = 0;
- do {
- free(peeked);
- peeked = peek_line(file, lines, &position);
- if (peeked) {
- peeked = strip_whitespace(peeked);
+// get line, with backslash continuation
+static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file) {
+ char *next_line = NULL;
+ size_t next_line_size = 0;
+ ssize_t nread = getline(lineptr, line_size, file);
+ while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0) {
+ ssize_t next_nread = getline(&next_line, &next_line_size, file);
+ if (next_nread == -1) {
+ break;
+ }
+
+ nread += next_nread - 2;
+ if ((ssize_t) *line_size < nread + 1) {
+ *line_size = nread + 1;
+ *lineptr = realloc(*lineptr, *line_size);
+ if (!*lineptr) {
+ nread = -1;
+ break;
}
- lines++;
- } while (peeked && strlen(peeked) == 0);
+ }
+ strcpy(&(*lineptr)[nread - next_nread], next_line);
+ }
+ free(next_line);
+ return nread;
+}
- if (peeked && strlen(peeked) == 1 && peeked[0] == '{') {
- fseek(file, position, SEEK_SET);
- } else {
- lines = 0;
+static int detect_brace(FILE *file) {
+ int lines = 0;
+ long pos = ftell(file);
+ char *line = NULL;
+ size_t line_size = 0;
+ while ((getline(&line, &line_size, file)) != -1) {
+ lines++;
+ strip_whitespace(line);
+ if (*line) {
+ if (strcmp(line, "{") != 0) {
+ fseek(file, pos, SEEK_SET);
+ lines = 0;
+ }
+ break;
}
- free(peeked);
}
+ free(line);
return lines;
}
@@ -635,55 +655,47 @@ bool read_config(FILE *file, struct sway_config *config,
bool success = true;
int line_number = 0;
- char *line;
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t nread;
list_t *stack = create_list();
size_t read = 0;
- while (!feof(file)) {
- char *block = stack->length ? stack->items[0] : NULL;
- line = read_line(file);
- if (!line) {
- continue;
- }
- line_number++;
- wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line);
-
+ while ((nread = getline_with_cont(&line, &line_size, file)) != -1) {
if (reading_main_config) {
- size_t length = strlen(line);
-
- if (read + length > config_size) {
+ if (read + nread > config_size) {
wlr_log(WLR_ERROR, "Config file changed during reading");
- list_free_items_and_destroy(stack);
- free(line);
- return false;
+ success = false;
+ break;
}
- strcpy(this_config + read, line);
- if (line_number != 1) {
- this_config[read - 1] = '\n';
- }
- read += length + 1;
+ strcpy(&this_config[read], line);
+ read += nread;
}
- line = strip_whitespace(line);
- if (line[0] == '#') {
- free(line);
- continue;
+ if (line[nread - 1] == '\n') {
+ line[nread - 1] = '\0';
}
- if (strlen(line) == 0) {
- free(line);
+
+ line_number++;
+ wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line);
+
+ strip_whitespace(line);
+ if (!*line || line[0] == '#') {
continue;
}
- int brace_detected = detect_brace_on_following_line(file, line,
- line_number);
- if (brace_detected > 0) {
- line_number += brace_detected;
- wlr_log(WLR_DEBUG, "Detected open brace on line %d", line_number);
+ int brace_detected = 0;
+ if (line[strlen(line) - 1] != '{' && line[strlen(line) - 1] != '}') {
+ brace_detected = detect_brace(file);
+ if (brace_detected > 0) {
+ line_number += brace_detected;
+ wlr_log(WLR_DEBUG, "Detected open brace on line %d", line_number);
+ }
}
+ char *block = stack->length ? stack->items[0] : NULL;
char *expanded = expand_line(block, line, brace_detected > 0);
if (!expanded) {
- list_free_items_and_destroy(stack);
- free(line);
- return false;
+ success = false;
+ break;
}
config->current_config_line_number = line_number;
config->current_config_line = line;
@@ -743,9 +755,9 @@ bool read_config(FILE *file, struct sway_config *config,
default:;
}
free(expanded);
- free(line);
free_cmd_results(res);
}
+ free(line);
list_free_items_and_destroy(stack);
config->current_config_line_number = 0;
config->current_config_line = NULL;
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index bf0038b4..f46938e2 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -363,7 +363,7 @@ static void transaction_progress_queue(void) {
static int handle_timeout(void *data) {
struct sway_transaction *transaction = data;
- wlr_log(WLR_DEBUG, "Transaction %p timed out (%li waiting)",
+ wlr_log(WLR_DEBUG, "Transaction %p timed out (%zi waiting)",
transaction, transaction->num_waiting);
transaction->num_waiting = 0;
transaction_progress_queue();
@@ -472,7 +472,7 @@ static void set_instruction_ready(
struct timespec *start = &transaction->commit_time;
float ms = (now.tv_sec - start->tv_sec) * 1000 +
(now.tv_nsec - start->tv_nsec) / 1000000.0;
- wlr_log(WLR_DEBUG, "Transaction %p: %li/%li ready in %.1fms (%s)",
+ wlr_log(WLR_DEBUG, "Transaction %p: %zi/%zi ready in %.1fms (%s)",
transaction,
transaction->num_configures - transaction->num_waiting + 1,
transaction->num_configures, ms,
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 66a9e435..510030ae 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -621,7 +621,7 @@ static int hide_notify(void *data) {
return 1;
}
-void cursor_handle_activity(struct sway_cursor *cursor) {
+int cursor_get_timeout(struct sway_cursor *cursor){
struct seat_config *sc = seat_get_config(cursor->seat);
if (!sc) {
sc = seat_get_config_by_name("*");
@@ -630,20 +630,31 @@ void cursor_handle_activity(struct sway_cursor *cursor) {
if (timeout < 0) {
timeout = 0;
}
- wl_event_source_timer_update(cursor->hide_source, timeout);
+ return timeout;
+}
+
+void cursor_handle_activity(struct sway_cursor *cursor) {
+ wl_event_source_timer_update(
+ cursor->hide_source, cursor_get_timeout(cursor));
wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
if (cursor->hidden) {
- cursor->hidden = false;
- if (cursor->image_surface) {
- cursor_set_image_surface(cursor, cursor->image_surface,
- cursor->hotspot_x, cursor->hotspot_y,
- cursor->image_client);
- } else {
- const char *image = cursor->image;
- cursor->image = NULL;
- cursor_set_image(cursor, image, cursor->image_client);
- }
+ cursor_unhide(cursor);
+ }
+}
+
+void cursor_unhide(struct sway_cursor *cursor) {
+ cursor->hidden = false;
+ if (cursor->image_surface) {
+ cursor_set_image_surface(cursor,
+ cursor->image_surface,
+ cursor->hotspot_x,
+ cursor->hotspot_y,
+ cursor->image_client);
+ } else {
+ const char *image = cursor->image;
+ cursor->image = NULL;
+ cursor_set_image(cursor, image, cursor->image_client);
}
}
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 61087733..04e14355 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -49,7 +49,7 @@ char *input_device_get_identifier(struct wlr_input_device *device) {
int vendor = device->vendor;
int product = device->product;
char *name = strdup(device->name);
- name = strip_whitespace(name);
+ strip_whitespace(name);
char *p = name;
for (; *p; ++p) {
diff --git a/sway/input/seat.c b/sway/input/seat.c
index e8b2cdcf..41a3a4df 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1237,4 +1237,8 @@ void seat_consider_warp_to_focus(struct sway_seat *seat) {
} else {
cursor_warp_to_workspace(seat->cursor, focus->sway_workspace);
}
+ if (seat->cursor->hidden){
+ cursor_unhide(seat->cursor);
+ wl_event_source_timer_update(seat->cursor->hide_source, cursor_get_timeout(seat->cursor));
+ }
}
diff --git a/sway/main.c b/sway/main.c
index f70e751d..d08c0457 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -3,6 +3,7 @@
#include <pango/pangocairo.h>
#include <signal.h>
#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -22,7 +23,6 @@
#include "sway/ipc-server.h"
#include "ipc-client.h"
#include "log.h"
-#include "readline.h"
#include "stringop.h"
#include "util.h"
@@ -47,31 +47,28 @@ void detect_raspi(void) {
if (!f) {
return;
}
- char *line;
- while(!feof(f)) {
- if (!(line = read_line(f))) {
- break;
- }
+ char *line = NULL;
+ size_t line_size = 0;
+ while (getline(&line, &line_size, f) != -1) {
if (strstr(line, "Raspberry Pi")) {
raspi = true;
+ break;
}
- free(line);
}
fclose(f);
FILE *g = fopen("/proc/modules", "r");
if (!g) {
+ free(line);
return;
}
bool vc4 = false;
- while (!feof(g)) {
- if (!(line = read_line(g))) {
- break;
- }
+ while (getline(&line, &line_size, g) != -1) {
if (strstr(line, "vc4")) {
vc4 = true;
+ break;
}
- free(line);
}
+ free(line);
fclose(g);
if (!vc4 && raspi) {
fprintf(stderr, "\x1B[1;31mWarning: You have a "
@@ -86,13 +83,10 @@ void detect_proprietary(int allow_unsupported_gpu) {
if (!f) {
return;
}
- while (!feof(f)) {
- char *line;
- if (!(line = read_line(f))) {
- break;
- }
+ char *line = NULL;
+ size_t line_size = 0;
+ while (getline(&line, &line_size, f) != -1) {
if (strstr(line, "nvidia")) {
- free(line);
if (allow_unsupported_gpu) {
wlr_log(WLR_ERROR,
"!!! Proprietary Nvidia drivers are in use !!!");
@@ -106,7 +100,6 @@ void detect_proprietary(int allow_unsupported_gpu) {
break;
}
if (strstr(line, "fglrx")) {
- free(line);
if (allow_unsupported_gpu) {
wlr_log(WLR_ERROR,
"!!! Proprietary AMD drivers are in use !!!");
@@ -118,8 +111,8 @@ void detect_proprietary(int allow_unsupported_gpu) {
}
break;
}
- free(line);
}
+ free(line);
fclose(f);
}
@@ -146,6 +139,19 @@ static void log_env(void) {
}
}
+static void log_file(FILE *f) {
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t nread;
+ while ((nread = getline(&line, &line_size, f)) != -1) {
+ if (line[nread - 1] == '\n') {
+ line[nread - 1] = '\0';
+ }
+ wlr_log(WLR_INFO, "%s", line);
+ }
+ free(line);
+}
+
static void log_distro(void) {
const char *paths[] = {
"/etc/lsb-release",
@@ -158,16 +164,7 @@ static void log_distro(void) {
FILE *f = fopen(paths[i], "r");
if (f) {
wlr_log(WLR_INFO, "Contents of %s:", paths[i]);
- while (!feof(f)) {
- char *line;
- if (!(line = read_line(f))) {
- break;
- }
- if (*line) {
- wlr_log(WLR_INFO, "%s", line);
- }
- free(line);
- }
+ log_file(f);
fclose(f);
}
}
@@ -179,16 +176,7 @@ static void log_kernel(void) {
wlr_log(WLR_INFO, "Unable to determine kernel version");
return;
}
- while (!feof(f)) {
- char *line;
- if (!(line = read_line(f))) {
- break;
- }
- if (*line) {
- wlr_log(WLR_INFO, "%s", line);
- }
- free(line);
- }
+ log_file(f);
pclose(f);
}
diff --git a/sway/server.c b/sway/server.c
index b1d7d3fc..13264a2c 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -7,6 +7,7 @@
#include <wlr/backend/session.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
+#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_gamma_control.h>
@@ -140,6 +141,7 @@ bool server_init(struct sway_server *server) {
wlr_export_dmabuf_manager_v1_create(server->wl_display);
wlr_screencopy_manager_v1_create(server->wl_display);
+ wlr_data_control_manager_v1_create(server->wl_display);
server->socket = wl_display_add_socket_auto(server->wl_display);
if (!server->socket) {
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index f0dea993..3757a097 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -327,7 +327,8 @@ runtime.
A view that does not have focus.
*client.urgent*
- A view with an urgency hint. *Note*: This is not currently implemented.
+ A view with an urgency hint. *Note*: Native Wayland windows do not
+ support urgency. Urgency only works for Xwayland windows.
The meaning of each color is:
@@ -431,7 +432,7 @@ The default colors are:
*focus\_follows\_mouse* yes|no|always
If set to _yes_, moving your mouse over a window will focus that window. If
- set to _always_, the window under the cursor will always be focused, even
+ set to _always_, the window under the cursor will always be focused, even
after switching between workspaces.
*focus\_wrapping* yes|no|force
@@ -450,11 +451,11 @@ The default colors are:
Thickness of the titlebar border in pixels
*titlebar\_padding* <horizontal> [<vertical>]
- Padding of the text in the titlebar. _horizontal_ value affects horizontal
- padding of the text while _vertical_ value affects vertical padding (space
- above and below text). Padding includes titlebar borders so their value
+ Padding of the text in the titlebar. _horizontal_ value affects horizontal
+ padding of the text while _vertical_ value affects vertical padding (space
+ above and below text). Padding includes titlebar borders so their value
should be greater than titlebar\_border\_thickness. If _vertical_ value is
- not specified it is set to the _horizontal_ value.
+ not specified it is set to the _horizontal_ value.
*for\_window* <criteria> <command>
Whenever a window that matches _criteria_ appears, run list of commands.
diff --git a/sway/tree/view.c b/sway/tree/view.c
index deb20676..5371ee20 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -654,14 +654,8 @@ void view_unmap(struct sway_view *view) {
struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) {
- if (config->mouse_warping == WARP_CONTAINER) {
- struct sway_node *node = seat_get_focus(seat);
- if (node && node->type == N_CONTAINER) {
- cursor_warp_to_container(seat->cursor, node->sway_container);
- } else if (node && node->type == N_WORKSPACE) {
- cursor_warp_to_workspace(seat->cursor, node->sway_workspace);
- }
- }
+ seat->cursor->image_surface = NULL;
+ seat_consider_warp_to_focus(seat);
}
transaction_commit_dirty();
diff --git a/swaybar/status_line.c b/swaybar/status_line.c
index 2e6ef173..f0e2c300 100644
--- a/swaybar/status_line.c
+++ b/swaybar/status_line.c
@@ -12,7 +12,6 @@
#include "swaybar/config.h"
#include "swaybar/i3bar.h"
#include "swaybar/status_line.h"
-#include "readline.h"
static void status_line_close_fds(struct status_line *status) {
if (status->read_fd != -1) {
diff --git a/swayidle/main.c b/swayidle/main.c
index 9a76e58c..41eecc41 100644
--- a/swayidle/main.c
+++ b/swayidle/main.c
@@ -1,6 +1,7 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
#include <getopt.h>
#include <pthread.h>
#include <signal.h>
@@ -104,9 +105,21 @@ static void acquire_sleep_lock(void) {
if (ret < 0) {
wlr_log(WLR_ERROR, "Failed to parse D-Bus response for Inhibit: %s",
strerror(-ret));
+ sd_bus_error_free(&error);
+ sd_bus_message_unref(msg);
+ return;
} else {
wlr_log(WLR_INFO, "Got sleep lock: %d", lock_fd);
}
+
+ // sd_bus_message_unref closes the file descriptor so we need
+ // to copy it beforehand
+ lock_fd = fcntl(lock_fd, F_DUPFD_CLOEXEC, 3);
+ if (lock_fd < 0) {
+ wlr_log(WLR_ERROR, "Failed to copy sleep lock fd: %s",
+ strerror(errno));
+ }
+
sd_bus_error_free(&error);
sd_bus_message_unref(msg);
}
diff --git a/swaylock/main.c b/swaylock/main.c
index 9aeb4e64..9a4f3b58 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -23,7 +23,6 @@
#include "cairo.h"
#include "log.h"
#include "loop.h"
-#include "readline.h"
#include "stringop.h"
#include "util.h"
#include "wlr-input-inhibitor-unstable-v1-client-protocol.h"
@@ -808,36 +807,32 @@ static int load_config(char *path, struct swaylock_state *state,
wlr_log(WLR_ERROR, "Failed to read config. Running without it.");
return 0;
}
- char *line;
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t nread;
int line_number = 0;
- while (!feof(config)) {
- line = read_line(config);
- if (!line) {
- continue;
- }
-
+ int result = 0;
+ while ((nread = getline(&line, &line_size, config)) != -1) {
line_number++;
- if (line[0] == '#') {
- free(line);
- continue;
+
+ if (line[nread - 1] == '\n') {
+ line[--nread] = '\0';
}
- if (strlen(line) == 0) {
- free(line);
+
+ if (!*line || line[0] == '#') {
continue;
}
wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line);
- char flag[strlen(line) + 3];
+ char flag[nread + 3];
sprintf(flag, "--%s", line);
char *argv[] = {"swaylock", flag};
- int result = parse_options(2, argv, state, line_mode, NULL);
+ result = parse_options(2, argv, state, line_mode, NULL);
if (result != 0) {
- free(line);
- fclose(config);
- return result;
+ break;
}
- free(line);
}
+ free(line);
fclose(config);
return 0;
}
diff --git a/swaylock/password.c b/swaylock/password.c
index 3059203a..3bd113ad 100644
--- a/swaylock/password.c
+++ b/swaylock/password.c
@@ -146,14 +146,6 @@ void swaylock_handle_key(struct swaylock_state *state,
schedule_indicator_clear(state);
break;
case XKB_KEY_Caps_Lock:
- /* The state is getting active after this
- * so we need to manually toggle it */
- state->xkb.caps_lock = !state->xkb.caps_lock;
- state->auth_state = AUTH_STATE_INPUT_NOP;
- damage_state(state);
- schedule_indicator_clear(state);
- schedule_password_clear(state);
- break;
case XKB_KEY_Shift_L:
case XKB_KEY_Shift_R:
case XKB_KEY_Control_L:
diff --git a/swaylock/seat.c b/swaylock/seat.c
index 7b72114f..f0b1385e 100644
--- a/swaylock/seat.c
+++ b/swaylock/seat.c
@@ -63,8 +63,12 @@ static void keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard,
struct swaylock_state *state = data;
xkb_state_update_mask(state->xkb.state,
mods_depressed, mods_latched, mods_locked, 0, 0, group);
- state->xkb.caps_lock = xkb_state_mod_name_is_active(state->xkb.state,
+ int caps_lock = xkb_state_mod_name_is_active(state->xkb.state,
XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED);
+ if (caps_lock != state->xkb.caps_lock) {
+ state->xkb.caps_lock = caps_lock;
+ damage_state(state);
+ }
state->xkb.control = xkb_state_mod_name_is_active(state->xkb.state,
XKB_MOD_NAME_CTRL,
XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
diff --git a/swaymsg/main.c b/swaymsg/main.c
index c9c557da..f1bb5e3e 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -12,7 +12,6 @@
#include <json-c/json.h>
#include "stringop.h"
#include "ipc-client.h"
-#include "readline.h"
#include "log.h"
void sway_terminate(int exit_code) {
diff --git a/swaynag/config.c b/swaynag/config.c
index e724aa0c..85aa380a 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -1,10 +1,10 @@
#define _POSIX_C_SOURCE 200809L
#include <getopt.h>
+#include <stdio.h>
#include <stdlib.h>
#include <wordexp.h>
#include "log.h"
#include "list.h"
-#include "readline.h"
#include "swaynag/swaynag.h"
#include "swaynag/types.h"
#include "util.h"
@@ -12,21 +12,19 @@
static char *read_from_stdin(void) {
char *buffer = NULL;
- while (!feof(stdin)) {
- char *line = read_line(stdin);
- if (!line) {
- continue;
- }
-
- size_t curlen = buffer ? strlen(buffer) : 0;
- buffer = realloc(buffer, curlen + strlen(line) + 2);
- snprintf(buffer + curlen, strlen(line) + 2, "%s\n", line);
-
- free(line);
+ size_t buffer_len = 0;
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t nread;
+ while ((nread = getline(&line, &line_size, stdin)) != -1) {
+ buffer = realloc(buffer, buffer_len + nread);
+ snprintf(&buffer[buffer_len], nread + 1, "%s", line);
+ buffer_len += nread;
}
+ free(line);
- while (buffer && buffer[strlen(buffer) - 1] == '\n') {
- buffer[strlen(buffer) - 1] = '\0';
+ while (buffer && buffer[buffer_len - 1] == '\n') {
+ buffer[--buffer_len] = '\0';
}
return buffer;
@@ -348,32 +346,24 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) {
type->name = strdup("<config>");
list_add(types, type);
- char *line;
+ char *line = NULL;
+ size_t line_size = 0;
+ ssize_t nread;
int line_number = 0;
- while (!feof(config)) {
- line = read_line(config);
- if (!line) {
- continue;
- }
-
+ int result = 0;
+ while ((nread = getline(&line, &line_size, config)) != -1) {
line_number++;
- if (line[0] == '#') {
- free(line);
- continue;
- }
- if (strlen(line) == 0) {
- free(line);
+ if (!*line || line[0] == '\n' || line[0] == '#') {
continue;
}
if (line[0] == '[') {
char *close = strchr(line, ']');
if (!close) {
- free(line);
- fclose(config);
fprintf(stderr, "Closing bracket not found on line %d\n",
line_number);
- return 1;
+ result = 1;
+ break;
}
char *name = calloc(1, close - line);
strncat(name, line + 1, close - line - 1);
@@ -385,21 +375,17 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) {
}
free(name);
} else {
- char flag[strlen(line) + 3];
+ char flag[nread + 3];
sprintf(flag, "--%s", line);
char *argv[] = {"swaynag", flag};
- int result;
result = swaynag_parse_options(2, argv, swaynag, types, type,
NULL, NULL);
if (result != 0) {
- free(line);
- fclose(config);
- return result;
+ break;
}
}
-
- free(line);
}
+ free(line);
fclose(config);
- return 0;
+ return result;
}