diff options
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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "**S**irCmpwn's **Way**land compositor" е в процес на разработка, съвместим с i3, [Wayland](http://wayland.freedesktop.org/) композитор. | 3 | Sway е в процес на разработка, съвместим с i3, |
4 | Прочетете [FAQ](https://github.com/swaywm/sway/wiki). Присъединете се в | 4 | [Wayland](http://wayland.freedesktop.org/) композитор. Прочетете |
5 | [IRC канала](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на | 5 | [FAQ](https://github.com/swaywm/sway/wiki). Присъединете се в [IRC |
6 | канала](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на | ||
6 | irc.freenode.net). | 7 | irc.freenode.net). |
7 | 8 | ||
8 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 9 | [![](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 @@ | |||
3 | Der Fortschritt dieser Übersetzung kann [hier](https://github.com/swaywm/sway/issues/1318) | 3 | Der Fortschritt dieser Übersetzung kann [hier](https://github.com/swaywm/sway/issues/1318) |
4 | eingesehen werden. | 4 | eingesehen werden. |
5 | 5 | ||
6 | "**S**irCmpwn's **Way**land compositor" ist ein i3-kompatibler | 6 | Sway ist ein i3-kompatibler |
7 | [Wayland](http://wayland.freedesktop.org/)-Kompositor. Lies die | 7 | [Wayland](http://wayland.freedesktop.org/)-Kompositor. Lies die |
8 | [FAQ](https://github.com/swaywm/sway/wiki#faq). Tritt dem | 8 | [FAQ](https://github.com/swaywm/sway/wiki#faq). Tritt dem |
9 | [IRC-Channel](http://webchat.freenode.net/?channels=sway&uio=d4) bei (#sway in irc.freenode.net). | 9 | [IRC-Channel](http://webchat.freenode.net/?channels=sway&uio=d4) bei (#sway in |
10 | irc.freenode.net). | ||
10 | 11 | ||
11 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 12 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) |
12 | 13 | ||
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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "Ο Sway (**S**irCmpwn's **Way**land) είναι ένας **υπό ανάπτυξη** [Wayland](http://wayland.freedesktop.org/) διαχειριστής παραθύρων συμβατός με τον αντίστοιχο διαχειριστή παραθύρων i3 για τον X11. | 3 | Sway είναι ένας **υπό ανάπτυξη** [Wayland](http://wayland.freedesktop.org/) διαχειριστής παραθύρων συμβατός με τον αντίστοιχο διαχειριστή παραθύρων i3 για τον X11. |
4 | Διαβάστε τις [Συνήθεις Ερωτήσεις](https://github.com/swaywm/sway/wiki). Συνδεθείτε στο [κανάλι μας στο IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway στο | 4 | Διαβάστε τις [Συνήθεις Ερωτήσεις](https://github.com/swaywm/sway/wiki). Συνδεθείτε στο [κανάλι μας στο IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway στο |
5 | irc.freenode.net). | 5 | irc.freenode.net). |
6 | 6 | ||
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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "**S**irCmpwn's **Way**land compositor" est un compositeur [Wayland](http://wayland.freedesktop.org/) | 3 | Sway est un compositeur [Wayland](http://wayland.freedesktop.org/) compatible |
4 | compatible avec i3, **en cours de développement**. | 4 | avec i3, **en cours de développement**. Lisez la |
5 | Lisez la [FAQ](https://github.com/swaywm/sway/wiki). Rejoignez le | 5 | [FAQ](https://github.com/swaywm/sway/wiki). Rejoignez le [canal |
6 | [canal IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway sur | 6 | IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway sur |
7 | irc.freenode.net). | 7 | irc.freenode.net). |
8 | 8 | ||
9 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 9 | [![](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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "**S**irCmpwn's **Way**land compositor" è un compositor | 3 | Sway è un compositor [Wayland](http://wayland.freedesktop.org/) **in via di |
4 | [Wayland](http://wayland.freedesktop.org/) **in via di sviluppo** | 4 | sviluppo** compatibile con i3. Leggi le [FAQ (in |
5 | compatibile con i3. | 5 | Inglese)](https://github.com/swaywm/sway/wiki). Unisciti al [canale IRC (in |
6 | Leggi le [FAQ (in Inglese)](https://github.com/swaywm/sway/wiki). Unisciti al | 6 | Inglese)](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on |
7 | [canale IRC (in Inglese)](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on | ||
8 | irc.freenode.net). | 7 | irc.freenode.net). |
9 | 8 | ||
10 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 9 | [![](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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "**S**irCmpwn's **Way**land compositor"は**開発中**の | 3 | Swayは**開発中**のi3互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。 |
4 | i3互換な[Wayland](http://wayland.freedesktop.org/)コンポジタです。 | ||
5 | [FAQ](https://github.com/swaywm/sway/wiki)も合わせてご覧ください。 | 4 | [FAQ](https://github.com/swaywm/sway/wiki)も合わせてご覧ください。 |
6 | [IRC チャンネル](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on irc.freenode.net)もあります。 | 5 | [IRC チャンネル](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on irc.freenode.net)もあります。 |
7 | 6 | ||
@@ -3,10 +3,10 @@ | |||
3 | [**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--) - | 3 | [**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--) - |
4 | [Русский](https://github.com/swaywm/sway/blob/master/README.ru.md#sway--) - [Български](https://github.com/swaywm/sway/blob/master/README.bg.md#sway--) | 4 | [Русский](https://github.com/swaywm/sway/blob/master/README.ru.md#sway--) - [Български](https://github.com/swaywm/sway/blob/master/README.bg.md#sway--) |
5 | 5 | ||
6 | "**S**irCmpwn's **Way**land compositor" is a **work in progress** | 6 | sway is a **work in progress** i3-compatible |
7 | i3-compatible [Wayland](http://wayland.freedesktop.org/) compositor. | 7 | [Wayland](http://wayland.freedesktop.org/) compositor. Read the |
8 | Read the [FAQ](https://github.com/swaywm/sway/wiki). Join the | 8 | [FAQ](https://github.com/swaywm/sway/wiki). Join the [IRC |
9 | [IRC channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on | 9 | channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on |
10 | irc.freenode.net). | 10 | irc.freenode.net). |
11 | 11 | ||
12 | If you'd like to support sway development, please contribute to [SirCmpwn's | 12 | 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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "**S**irCmpwn's **Way**land compositor" é um compositor [Wayland](http://wayland.freedesktop.org/) | 3 | Sway é um compositor [Wayland](http://wayland.freedesktop.org/) compatível com o |
4 | compatível com o i3. Leia o [FAQ](https://github.com/swaywm/sway/wiki). Participe do | 4 | i3. Leia o [FAQ](https://github.com/swaywm/sway/wiki). Participe do [canal |
5 | [canal IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway no | 5 | IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway no |
6 | irc.freenode.net). | 6 | irc.freenode.net). |
7 | 7 | ||
8 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 8 | [![](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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | "**S**irCmpwn's **Way**land compositor" на данный момент **(в разработке)** | 3 | Sway на данный момент **(в разработке)** i3-совместимый |
4 | i3-совместимый [Wayland](http://wayland.freedesktop.org/) композитор. | 4 | [Wayland](http://wayland.freedesktop.org/) композитор. Прочитайте |
5 | Прочитайте [FAQ](https://github.com/swaywm/sway/wiki). Присоединяйтесь к | 5 | [FAQ](https://github.com/swaywm/sway/wiki). Присоединяйтесь к [IRC |
6 | [IRC каналу](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на | 6 | каналу](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на |
7 | irc.freenode.net). | 7 | irc.freenode.net). |
8 | 8 | ||
9 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 9 | [![](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 @@ | |||
1 | # sway | 1 | # sway |
2 | 2 | ||
3 | **Sway** ("**S**irCmpwn's **Way**land compositor") це сумісний з i3 композитор | 3 | **Sway** це сумісний з i3 композитор [Wayland](http://wayland.freedesktop.org/) |
4 | [Wayland](http://wayland.freedesktop.org/) (**у стані розробки**). | 4 | (**у стані розробки**). Ознайомтесь з |
5 | Ознайомтесь з [ЧаПами](https://github.com/swaywm/sway/wiki). | 5 | [ЧаПами](https://github.com/swaywm/sway/wiki). Приєднуйтесь до [спільноти в |
6 | Приєднуйтесь до [спільноти в IRC](http://webchat.freenode.net/?channels=sway&uio=d4) | 6 | IRC](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway на |
7 | (#sway на irc.freenode.net). | 7 | irc.freenode.net). |
8 | 8 | ||
9 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) | 9 | [![](https://sr.ht/ICd5.png)](https://sr.ht/ICd5.png) |
10 | 10 | ||
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 @@ | |||
7 | #include <sys/un.h> | 7 | #include <sys/un.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | #include "ipc-client.h" | 9 | #include "ipc-client.h" |
10 | #include "readline.h" | ||
11 | #include "log.h" | 10 | #include "log.h" |
12 | 11 | ||
13 | static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'}; | 12 | static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'}; |
@@ -18,28 +17,30 @@ char *get_socketpath(void) { | |||
18 | if (swaysock) { | 17 | if (swaysock) { |
19 | return strdup(swaysock); | 18 | return strdup(swaysock); |
20 | } | 19 | } |
20 | char *line = NULL; | ||
21 | size_t line_size = 0; | ||
21 | FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r"); | 22 | FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r"); |
22 | if (fp) { | 23 | if (fp) { |
23 | char *line = read_line(fp); | 24 | getline(&line, &line_size, fp); |
24 | pclose(fp); | 25 | pclose(fp); |
25 | if (line && *line) { | 26 | if (line && *line) { |
26 | return line; | 27 | return line; |
27 | } | 28 | } |
28 | free(line); | ||
29 | } | 29 | } |
30 | const char *i3sock = getenv("I3SOCK"); | 30 | const char *i3sock = getenv("I3SOCK"); |
31 | if (i3sock) { | 31 | if (i3sock) { |
32 | free(line); | ||
32 | return strdup(i3sock); | 33 | return strdup(i3sock); |
33 | } | 34 | } |
34 | fp = popen("i3 --get-socketpath 2>/dev/null", "r"); | 35 | fp = popen("i3 --get-socketpath 2>/dev/null", "r"); |
35 | if (fp) { | 36 | if (fp) { |
36 | char *line = read_line(fp); | 37 | getline(&line, &line_size, fp); |
37 | pclose(fp); | 38 | pclose(fp); |
38 | if (line && *line) { | 39 | if (line && *line) { |
39 | return line; | 40 | return line; |
40 | } | 41 | } |
41 | free(line); | ||
42 | } | 42 | } |
43 | free(line); | ||
43 | return NULL; | 44 | return NULL; |
44 | } | 45 | } |
45 | 46 | ||
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( | |||
8 | 'loop.c', | 8 | 'loop.c', |
9 | 'list.c', | 9 | 'list.c', |
10 | 'pango.c', | 10 | 'pango.c', |
11 | 'readline.c', | ||
12 | 'stringop.c', | 11 | 'stringop.c', |
13 | 'unicode.c', | 12 | 'unicode.c', |
14 | 'util.c' | 13 | '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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include "readline.h" | ||
3 | #include "log.h" | ||
4 | #include <stdlib.h> | ||
5 | #include <stdio.h> | ||
6 | |||
7 | char *read_line(FILE *file) { | ||
8 | size_t length = 0, size = 128; | ||
9 | char *string = malloc(size); | ||
10 | char lastChar = '\0'; | ||
11 | if (!string) { | ||
12 | wlr_log(WLR_ERROR, "Unable to allocate memory for read_line"); | ||
13 | return NULL; | ||
14 | } | ||
15 | while (1) { | ||
16 | int c = getc(file); | ||
17 | if (c == '\n' && lastChar == '\\'){ | ||
18 | --length; // Ignore last character. | ||
19 | lastChar = '\0'; | ||
20 | continue; | ||
21 | } | ||
22 | if (c == EOF || c == '\n' || c == '\0') { | ||
23 | break; | ||
24 | } | ||
25 | if (c == '\r') { | ||
26 | continue; | ||
27 | } | ||
28 | lastChar = c; | ||
29 | if (length == size) { | ||
30 | char *new_string = realloc(string, size *= 2); | ||
31 | if (!new_string) { | ||
32 | free(string); | ||
33 | wlr_log(WLR_ERROR, "Unable to allocate memory for read_line"); | ||
34 | return NULL; | ||
35 | } | ||
36 | string = new_string; | ||
37 | } | ||
38 | string[length++] = c; | ||
39 | } | ||
40 | if (length + 1 == size) { | ||
41 | char *new_string = realloc(string, length + 1); | ||
42 | if (!new_string) { | ||
43 | free(string); | ||
44 | return NULL; | ||
45 | } | ||
46 | string = new_string; | ||
47 | } | ||
48 | string[length] = '\0'; | ||
49 | return string; | ||
50 | } | ||
51 | |||
52 | char *peek_line(FILE *file, int line_offset, long *position) { | ||
53 | long pos = ftell(file); | ||
54 | size_t length = 0; | ||
55 | char *line = NULL; | ||
56 | for (int i = 0; i <= line_offset; i++) { | ||
57 | ssize_t read = getline(&line, &length, file); | ||
58 | if (read < 0) { | ||
59 | free(line); | ||
60 | line = NULL; | ||
61 | break; | ||
62 | } | ||
63 | if (read > 0 && line[read - 1] == '\n') { | ||
64 | line[read - 1] = '\0'; | ||
65 | } | ||
66 | } | ||
67 | if (position) { | ||
68 | *position = ftell(file); | ||
69 | } | ||
70 | fseek(file, pos, SEEK_SET); | ||
71 | return line; | ||
72 | } | ||
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 @@ | |||
9 | #include "string.h" | 9 | #include "string.h" |
10 | #include "list.h" | 10 | #include "list.h" |
11 | 11 | ||
12 | const char whitespace[] = " \f\n\r\t\v"; | 12 | static const char whitespace[] = " \f\n\r\t\v"; |
13 | 13 | ||
14 | char *strip_whitespace(char *_str) { | 14 | void strip_whitespace(char *str) { |
15 | if (*_str == '\0') | 15 | size_t len = strlen(str); |
16 | return _str; | 16 | size_t start = strspn(str, whitespace); |
17 | char *strold = _str; | 17 | memmove(str, &str[start], len + 1 - start); |
18 | while (*_str == ' ' || *_str == '\t') { | 18 | |
19 | _str++; | 19 | if (*str) { |
20 | for (len -= start + 1; isspace(str[len]); --len) {} | ||
21 | str[len + 1] = '\0'; | ||
20 | } | 22 | } |
21 | char *str = strdup(_str); | ||
22 | free(strold); | ||
23 | int i; | ||
24 | for (i = 0; str[i] != '\0'; ++i); | ||
25 | do { | ||
26 | i--; | ||
27 | } while (i >= 0 && (str[i] == ' ' || str[i] == '\t')); | ||
28 | str[i + 1] = '\0'; | ||
29 | return str; | ||
30 | } | 23 | } |
31 | 24 | ||
32 | void strip_quotes(char *str) { | 25 | 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 @@ | |||
13 | #include <xkbcommon/xkbcommon-names.h> | 13 | #include <xkbcommon/xkbcommon-names.h> |
14 | #include <wlr/types/wlr_keyboard.h> | 14 | #include <wlr/types/wlr_keyboard.h> |
15 | #include "log.h" | 15 | #include "log.h" |
16 | #include "readline.h" | ||
17 | #include "util.h" | 16 | #include "util.h" |
18 | 17 | ||
19 | int wrap(int i, int max) { | 18 | int wrap(int i, int max) { |
@@ -87,11 +86,12 @@ pid_t get_parent_pid(pid_t child) { | |||
87 | char *token = NULL; | 86 | char *token = NULL; |
88 | const char *sep = " "; | 87 | const char *sep = " "; |
89 | FILE *stat = NULL; | 88 | FILE *stat = NULL; |
89 | size_t buf_size = 0; | ||
90 | 90 | ||
91 | sprintf(file_name, "/proc/%d/stat", child); | 91 | sprintf(file_name, "/proc/%d/stat", child); |
92 | 92 | ||
93 | if ((stat = fopen(file_name, "r"))) { | 93 | if ((stat = fopen(file_name, "r"))) { |
94 | if ((buffer = read_line(stat))) { | 94 | if (getline(&buffer, &buf_size, stat) != -1) { |
95 | token = strtok(buffer, sep); // pid | 95 | token = strtok(buffer, sep); // pid |
96 | token = strtok(NULL, sep); // executable name | 96 | token = strtok(NULL, sep); // executable name |
97 | token = strtok(NULL, sep); // state | 97 | 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 @@ | |||
1 | #ifndef _SWAY_READLINE_H | ||
2 | #define _SWAY_READLINE_H | ||
3 | |||
4 | #include <stdio.h> | ||
5 | |||
6 | char *read_line(FILE *file); | ||
7 | char *peek_line(FILE *file, int line_offset, long *position); | ||
8 | char *read_line_buffer(FILE *file, char *string, size_t string_len); | ||
9 | |||
10 | #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 @@ | |||
3 | 3 | ||
4 | #include "list.h" | 4 | #include "list.h" |
5 | 5 | ||
6 | // array of whitespace characters to use for delims | 6 | void strip_whitespace(char *str); |
7 | extern const char whitespace[]; | ||
8 | |||
9 | char *strip_whitespace(char *str); | ||
10 | char *strip_comments(char *str); | 7 | char *strip_comments(char *str); |
11 | void strip_quotes(char *str); | 8 | void strip_quotes(char *str); |
12 | 9 | ||
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); | |||
61 | void cursor_rebase(struct sway_cursor *cursor); | 61 | void cursor_rebase(struct sway_cursor *cursor); |
62 | 62 | ||
63 | void cursor_handle_activity(struct sway_cursor *cursor); | 63 | void cursor_handle_activity(struct sway_cursor *cursor); |
64 | void cursor_unhide(struct sway_cursor *cursor); | ||
65 | int cursor_get_timeout(struct sway_cursor *cursor); | ||
64 | 66 | ||
65 | /** | 67 | /** |
66 | * Like cursor_rebase, but also allows focus to change when the cursor enters a | 68 | * 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, | |||
237 | criteria_destroy(criteria); | 237 | criteria_destroy(criteria); |
238 | config->handler_context.using_criteria = true; | 238 | config->handler_context.using_criteria = true; |
239 | // Skip leading whitespace | 239 | // Skip leading whitespace |
240 | head += strspn(head, whitespace); | 240 | for (; isspace(*head); ++head) {} |
241 | } | 241 | } |
242 | // Split command list | 242 | // Split command list |
243 | cmdlist = argsep(&head, ";"); | 243 | cmdlist = argsep(&head, ";"); |
244 | cmdlist += strspn(cmdlist, whitespace); | 244 | for (; isspace(*cmdlist); ++cmdlist) {} |
245 | do { | 245 | do { |
246 | // Split commands | 246 | // Split commands |
247 | cmd = argsep(&cmdlist, ","); | 247 | cmd = argsep(&cmdlist, ","); |
248 | cmd += strspn(cmd, whitespace); | 248 | for (; isspace(*cmd); ++cmd) {} |
249 | if (strcmp(cmd, "") == 0) { | 249 | if (strcmp(cmd, "") == 0) { |
250 | wlr_log(WLR_INFO, "Ignoring empty command."); | 250 | wlr_log(WLR_INFO, "Ignoring empty command."); |
251 | continue; | 251 | 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 " | |||
17 | "'cursor <set> <x> <y>' or " | 17 | "'cursor <set> <x> <y>' or " |
18 | "'curor <press|release> <left|right|1|2|3...>'"; | 18 | "'curor <press|release> <left|right|1|2|3...>'"; |
19 | 19 | ||
20 | struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | 20 | static struct cmd_results *handle_command(struct sway_cursor *cursor, |
21 | struct cmd_results *error = NULL; | 21 | int argc, char **argv) { |
22 | if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) { | ||
23 | return error; | ||
24 | } | ||
25 | struct sway_seat *seat = config->handler_context.seat; | ||
26 | if (!seat) { | ||
27 | return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined"); | ||
28 | } | ||
29 | |||
30 | struct sway_cursor *cursor = seat->cursor; | ||
31 | |||
32 | if (strcasecmp(argv[0], "move") == 0) { | 22 | if (strcasecmp(argv[0], "move") == 0) { |
33 | if (argc < 3) { | 23 | if (argc < 3) { |
34 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 24 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); |
@@ -50,6 +40,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | |||
50 | if (argc < 2) { | 40 | if (argc < 2) { |
51 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 41 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); |
52 | } | 42 | } |
43 | struct cmd_results *error = NULL; | ||
53 | if ((error = press_or_release(cursor, argv[0], argv[1]))) { | 44 | if ((error = press_or_release(cursor, argv[0], argv[1]))) { |
54 | return error; | 45 | return error; |
55 | } | 46 | } |
@@ -58,6 +49,40 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | |||
58 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 49 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
59 | } | 50 | } |
60 | 51 | ||
52 | struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | ||
53 | struct cmd_results *error = NULL; | ||
54 | if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) { | ||
55 | return error; | ||
56 | } | ||
57 | struct seat_config *sc = config->handler_context.seat_config; | ||
58 | if (!sc) { | ||
59 | return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined"); | ||
60 | } | ||
61 | |||
62 | if (config->reading || !config->active) { | ||
63 | return cmd_results_new(CMD_DEFER, NULL, NULL); | ||
64 | } | ||
65 | |||
66 | if (strcmp(sc->name, "*") != 0) { | ||
67 | struct sway_seat *seat = input_manager_get_seat(sc->name); | ||
68 | if (!seat) { | ||
69 | return cmd_results_new(CMD_FAILURE, "cursor", | ||
70 | "Failed to get seat"); | ||
71 | } | ||
72 | error = handle_command(seat->cursor, argc, argv); | ||
73 | } else { | ||
74 | struct sway_seat *seat = NULL; | ||
75 | wl_list_for_each(seat, &server.input->seats, link) { | ||
76 | error = handle_command(seat->cursor, argc, argv); | ||
77 | if ((error && error->status != CMD_SUCCESS)) { | ||
78 | break; | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | |||
83 | return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
84 | } | ||
85 | |||
61 | static struct cmd_results *press_or_release(struct sway_cursor *cursor, | 86 | static struct cmd_results *press_or_release(struct sway_cursor *cursor, |
62 | char *action, char *button_str) { | 87 | char *action, char *button_str) { |
63 | enum wlr_button_state state; | 88 | 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 @@ | |||
1 | #define _XOPEN_SOURCE 600 // for realpath | 1 | #define _XOPEN_SOURCE 700 // for realpath |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
@@ -30,7 +30,6 @@ | |||
30 | #include "sway/tree/workspace.h" | 30 | #include "sway/tree/workspace.h" |
31 | #include "cairo.h" | 31 | #include "cairo.h" |
32 | #include "pango.h" | 32 | #include "pango.h" |
33 | #include "readline.h" | ||
34 | #include "stringop.h" | 33 | #include "stringop.h" |
35 | #include "list.h" | 34 | #include "list.h" |
36 | #include "log.h" | 35 | #include "log.h" |
@@ -571,28 +570,49 @@ bool load_include_configs(const char *path, struct sway_config *config, | |||
571 | return true; | 570 | return true; |
572 | } | 571 | } |
573 | 572 | ||
574 | static int detect_brace_on_following_line(FILE *file, char *line, | 573 | // get line, with backslash continuation |
575 | int line_number) { | 574 | static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file) { |
576 | int lines = 0; | 575 | char *next_line = NULL; |
577 | if (line[strlen(line) - 1] != '{' && line[strlen(line) - 1] != '}') { | 576 | size_t next_line_size = 0; |
578 | char *peeked = NULL; | 577 | ssize_t nread = getline(lineptr, line_size, file); |
579 | long position = 0; | 578 | while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0) { |
580 | do { | 579 | ssize_t next_nread = getline(&next_line, &next_line_size, file); |
581 | free(peeked); | 580 | if (next_nread == -1) { |
582 | peeked = peek_line(file, lines, &position); | 581 | break; |
583 | if (peeked) { | 582 | } |
584 | peeked = strip_whitespace(peeked); | 583 | |
584 | nread += next_nread - 2; | ||
585 | if ((ssize_t) *line_size < nread + 1) { | ||
586 | *line_size = nread + 1; | ||
587 | *lineptr = realloc(*lineptr, *line_size); | ||
588 | if (!*lineptr) { | ||
589 | nread = -1; | ||
590 | break; | ||
585 | } | 591 | } |
586 | lines++; | 592 | } |
587 | } while (peeked && strlen(peeked) == 0); | 593 | strcpy(&(*lineptr)[nread - next_nread], next_line); |
594 | } | ||
595 | free(next_line); | ||
596 | return nread; | ||
597 | } | ||
588 | 598 | ||
589 | if (peeked && strlen(peeked) == 1 && peeked[0] == '{') { | 599 | static int detect_brace(FILE *file) { |
590 | fseek(file, position, SEEK_SET); | 600 | int lines = 0; |
591 | } else { | 601 | long pos = ftell(file); |
592 | lines = 0; | 602 | char *line = NULL; |
603 | size_t line_size = 0; | ||
604 | while ((getline(&line, &line_size, file)) != -1) { | ||
605 | lines++; | ||
606 | strip_whitespace(line); | ||
607 | if (*line) { | ||
608 | if (strcmp(line, "{") != 0) { | ||
609 | fseek(file, pos, SEEK_SET); | ||
610 | lines = 0; | ||
611 | } | ||
612 | break; | ||
593 | } | 613 | } |
594 | free(peeked); | ||
595 | } | 614 | } |
615 | free(line); | ||
596 | return lines; | 616 | return lines; |
597 | } | 617 | } |
598 | 618 | ||
@@ -635,55 +655,47 @@ bool read_config(FILE *file, struct sway_config *config, | |||
635 | 655 | ||
636 | bool success = true; | 656 | bool success = true; |
637 | int line_number = 0; | 657 | int line_number = 0; |
638 | char *line; | 658 | char *line = NULL; |
659 | size_t line_size = 0; | ||
660 | ssize_t nread; | ||
639 | list_t *stack = create_list(); | 661 | list_t *stack = create_list(); |
640 | size_t read = 0; | 662 | size_t read = 0; |
641 | while (!feof(file)) { | 663 | while ((nread = getline_with_cont(&line, &line_size, file)) != -1) { |
642 | char *block = stack->length ? stack->items[0] : NULL; | ||
643 | line = read_line(file); | ||
644 | if (!line) { | ||
645 | continue; | ||
646 | } | ||
647 | line_number++; | ||
648 | wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line); | ||
649 | |||
650 | if (reading_main_config) { | 664 | if (reading_main_config) { |
651 | size_t length = strlen(line); | 665 | if (read + nread > config_size) { |
652 | |||
653 | if (read + length > config_size) { | ||
654 | wlr_log(WLR_ERROR, "Config file changed during reading"); | 666 | wlr_log(WLR_ERROR, "Config file changed during reading"); |
655 | list_free_items_and_destroy(stack); | 667 | success = false; |
656 | free(line); | 668 | break; |
657 | return false; | ||
658 | } | 669 | } |
659 | 670 | ||
660 | strcpy(this_config + read, line); | 671 | strcpy(&this_config[read], line); |
661 | if (line_number != 1) { | 672 | read += nread; |
662 | this_config[read - 1] = '\n'; | ||
663 | } | ||
664 | read += length + 1; | ||
665 | } | 673 | } |
666 | 674 | ||
667 | line = strip_whitespace(line); | 675 | if (line[nread - 1] == '\n') { |
668 | if (line[0] == '#') { | 676 | line[nread - 1] = '\0'; |
669 | free(line); | ||
670 | continue; | ||
671 | } | 677 | } |
672 | if (strlen(line) == 0) { | 678 | |
673 | free(line); | 679 | line_number++; |
680 | wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line); | ||
681 | |||
682 | strip_whitespace(line); | ||
683 | if (!*line || line[0] == '#') { | ||
674 | continue; | 684 | continue; |
675 | } | 685 | } |
676 | int brace_detected = detect_brace_on_following_line(file, line, | 686 | int brace_detected = 0; |
677 | line_number); | 687 | if (line[strlen(line) - 1] != '{' && line[strlen(line) - 1] != '}') { |
678 | if (brace_detected > 0) { | 688 | brace_detected = detect_brace(file); |
679 | line_number += brace_detected; | 689 | if (brace_detected > 0) { |
680 | wlr_log(WLR_DEBUG, "Detected open brace on line %d", line_number); | 690 | line_number += brace_detected; |
691 | wlr_log(WLR_DEBUG, "Detected open brace on line %d", line_number); | ||
692 | } | ||
681 | } | 693 | } |
694 | char *block = stack->length ? stack->items[0] : NULL; | ||
682 | char *expanded = expand_line(block, line, brace_detected > 0); | 695 | char *expanded = expand_line(block, line, brace_detected > 0); |
683 | if (!expanded) { | 696 | if (!expanded) { |
684 | list_free_items_and_destroy(stack); | 697 | success = false; |
685 | free(line); | 698 | break; |
686 | return false; | ||
687 | } | 699 | } |
688 | config->current_config_line_number = line_number; | 700 | config->current_config_line_number = line_number; |
689 | config->current_config_line = line; | 701 | config->current_config_line = line; |
@@ -743,9 +755,9 @@ bool read_config(FILE *file, struct sway_config *config, | |||
743 | default:; | 755 | default:; |
744 | } | 756 | } |
745 | free(expanded); | 757 | free(expanded); |
746 | free(line); | ||
747 | free_cmd_results(res); | 758 | free_cmd_results(res); |
748 | } | 759 | } |
760 | free(line); | ||
749 | list_free_items_and_destroy(stack); | 761 | list_free_items_and_destroy(stack); |
750 | config->current_config_line_number = 0; | 762 | config->current_config_line_number = 0; |
751 | config->current_config_line = NULL; | 763 | 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) { | |||
363 | 363 | ||
364 | static int handle_timeout(void *data) { | 364 | static int handle_timeout(void *data) { |
365 | struct sway_transaction *transaction = data; | 365 | struct sway_transaction *transaction = data; |
366 | wlr_log(WLR_DEBUG, "Transaction %p timed out (%li waiting)", | 366 | wlr_log(WLR_DEBUG, "Transaction %p timed out (%zi waiting)", |
367 | transaction, transaction->num_waiting); | 367 | transaction, transaction->num_waiting); |
368 | transaction->num_waiting = 0; | 368 | transaction->num_waiting = 0; |
369 | transaction_progress_queue(); | 369 | transaction_progress_queue(); |
@@ -472,7 +472,7 @@ static void set_instruction_ready( | |||
472 | struct timespec *start = &transaction->commit_time; | 472 | struct timespec *start = &transaction->commit_time; |
473 | float ms = (now.tv_sec - start->tv_sec) * 1000 + | 473 | float ms = (now.tv_sec - start->tv_sec) * 1000 + |
474 | (now.tv_nsec - start->tv_nsec) / 1000000.0; | 474 | (now.tv_nsec - start->tv_nsec) / 1000000.0; |
475 | wlr_log(WLR_DEBUG, "Transaction %p: %li/%li ready in %.1fms (%s)", | 475 | wlr_log(WLR_DEBUG, "Transaction %p: %zi/%zi ready in %.1fms (%s)", |
476 | transaction, | 476 | transaction, |
477 | transaction->num_configures - transaction->num_waiting + 1, | 477 | transaction->num_configures - transaction->num_waiting + 1, |
478 | transaction->num_configures, ms, | 478 | 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) { | |||
621 | return 1; | 621 | return 1; |
622 | } | 622 | } |
623 | 623 | ||
624 | void cursor_handle_activity(struct sway_cursor *cursor) { | 624 | int cursor_get_timeout(struct sway_cursor *cursor){ |
625 | struct seat_config *sc = seat_get_config(cursor->seat); | 625 | struct seat_config *sc = seat_get_config(cursor->seat); |
626 | if (!sc) { | 626 | if (!sc) { |
627 | sc = seat_get_config_by_name("*"); | 627 | sc = seat_get_config_by_name("*"); |
@@ -630,20 +630,31 @@ void cursor_handle_activity(struct sway_cursor *cursor) { | |||
630 | if (timeout < 0) { | 630 | if (timeout < 0) { |
631 | timeout = 0; | 631 | timeout = 0; |
632 | } | 632 | } |
633 | wl_event_source_timer_update(cursor->hide_source, timeout); | 633 | return timeout; |
634 | } | ||
635 | |||
636 | void cursor_handle_activity(struct sway_cursor *cursor) { | ||
637 | wl_event_source_timer_update( | ||
638 | cursor->hide_source, cursor_get_timeout(cursor)); | ||
634 | 639 | ||
635 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); | 640 | wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); |
636 | if (cursor->hidden) { | 641 | if (cursor->hidden) { |
637 | cursor->hidden = false; | 642 | cursor_unhide(cursor); |
638 | if (cursor->image_surface) { | 643 | } |
639 | cursor_set_image_surface(cursor, cursor->image_surface, | 644 | } |
640 | cursor->hotspot_x, cursor->hotspot_y, | 645 | |
641 | cursor->image_client); | 646 | void cursor_unhide(struct sway_cursor *cursor) { |
642 | } else { | 647 | cursor->hidden = false; |
643 | const char *image = cursor->image; | 648 | if (cursor->image_surface) { |
644 | cursor->image = NULL; | 649 | cursor_set_image_surface(cursor, |
645 | cursor_set_image(cursor, image, cursor->image_client); | 650 | cursor->image_surface, |
646 | } | 651 | cursor->hotspot_x, |
652 | cursor->hotspot_y, | ||
653 | cursor->image_client); | ||
654 | } else { | ||
655 | const char *image = cursor->image; | ||
656 | cursor->image = NULL; | ||
657 | cursor_set_image(cursor, image, cursor->image_client); | ||
647 | } | 658 | } |
648 | } | 659 | } |
649 | 660 | ||
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) { | |||
49 | int vendor = device->vendor; | 49 | int vendor = device->vendor; |
50 | int product = device->product; | 50 | int product = device->product; |
51 | char *name = strdup(device->name); | 51 | char *name = strdup(device->name); |
52 | name = strip_whitespace(name); | 52 | strip_whitespace(name); |
53 | 53 | ||
54 | char *p = name; | 54 | char *p = name; |
55 | for (; *p; ++p) { | 55 | 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) { | |||
1237 | } else { | 1237 | } else { |
1238 | cursor_warp_to_workspace(seat->cursor, focus->sway_workspace); | 1238 | cursor_warp_to_workspace(seat->cursor, focus->sway_workspace); |
1239 | } | 1239 | } |
1240 | if (seat->cursor->hidden){ | ||
1241 | cursor_unhide(seat->cursor); | ||
1242 | wl_event_source_timer_update(seat->cursor->hide_source, cursor_get_timeout(seat->cursor)); | ||
1243 | } | ||
1240 | } | 1244 | } |
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 @@ | |||
3 | #include <pango/pangocairo.h> | 3 | #include <pango/pangocairo.h> |
4 | #include <signal.h> | 4 | #include <signal.h> |
5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
6 | #include <stdio.h> | ||
6 | #include <stdlib.h> | 7 | #include <stdlib.h> |
7 | #include <stdio.h> | 8 | #include <stdio.h> |
8 | #include <string.h> | 9 | #include <string.h> |
@@ -22,7 +23,6 @@ | |||
22 | #include "sway/ipc-server.h" | 23 | #include "sway/ipc-server.h" |
23 | #include "ipc-client.h" | 24 | #include "ipc-client.h" |
24 | #include "log.h" | 25 | #include "log.h" |
25 | #include "readline.h" | ||
26 | #include "stringop.h" | 26 | #include "stringop.h" |
27 | #include "util.h" | 27 | #include "util.h" |
28 | 28 | ||
@@ -47,31 +47,28 @@ void detect_raspi(void) { | |||
47 | if (!f) { | 47 | if (!f) { |
48 | return; | 48 | return; |
49 | } | 49 | } |
50 | char *line; | 50 | char *line = NULL; |
51 | while(!feof(f)) { | 51 | size_t line_size = 0; |
52 | if (!(line = read_line(f))) { | 52 | while (getline(&line, &line_size, f) != -1) { |
53 | break; | ||
54 | } | ||
55 | if (strstr(line, "Raspberry Pi")) { | 53 | if (strstr(line, "Raspberry Pi")) { |
56 | raspi = true; | 54 | raspi = true; |
55 | break; | ||
57 | } | 56 | } |
58 | free(line); | ||
59 | } | 57 | } |
60 | fclose(f); | 58 | fclose(f); |
61 | FILE *g = fopen("/proc/modules", "r"); | 59 | FILE *g = fopen("/proc/modules", "r"); |
62 | if (!g) { | 60 | if (!g) { |
61 | free(line); | ||
63 | return; | 62 | return; |
64 | } | 63 | } |
65 | bool vc4 = false; | 64 | bool vc4 = false; |
66 | while (!feof(g)) { | 65 | while (getline(&line, &line_size, g) != -1) { |
67 | if (!(line = read_line(g))) { | ||
68 | break; | ||
69 | } | ||
70 | if (strstr(line, "vc4")) { | 66 | if (strstr(line, "vc4")) { |
71 | vc4 = true; | 67 | vc4 = true; |
68 | break; | ||
72 | } | 69 | } |
73 | free(line); | ||
74 | } | 70 | } |
71 | free(line); | ||
75 | fclose(g); | 72 | fclose(g); |
76 | if (!vc4 && raspi) { | 73 | if (!vc4 && raspi) { |
77 | fprintf(stderr, "\x1B[1;31mWarning: You have a " | 74 | fprintf(stderr, "\x1B[1;31mWarning: You have a " |
@@ -86,13 +83,10 @@ void detect_proprietary(int allow_unsupported_gpu) { | |||
86 | if (!f) { | 83 | if (!f) { |
87 | return; | 84 | return; |
88 | } | 85 | } |
89 | while (!feof(f)) { | 86 | char *line = NULL; |
90 | char *line; | 87 | size_t line_size = 0; |
91 | if (!(line = read_line(f))) { | 88 | while (getline(&line, &line_size, f) != -1) { |
92 | break; | ||
93 | } | ||
94 | if (strstr(line, "nvidia")) { | 89 | if (strstr(line, "nvidia")) { |
95 | free(line); | ||
96 | if (allow_unsupported_gpu) { | 90 | if (allow_unsupported_gpu) { |
97 | wlr_log(WLR_ERROR, | 91 | wlr_log(WLR_ERROR, |
98 | "!!! Proprietary Nvidia drivers are in use !!!"); | 92 | "!!! Proprietary Nvidia drivers are in use !!!"); |
@@ -106,7 +100,6 @@ void detect_proprietary(int allow_unsupported_gpu) { | |||
106 | break; | 100 | break; |
107 | } | 101 | } |
108 | if (strstr(line, "fglrx")) { | 102 | if (strstr(line, "fglrx")) { |
109 | free(line); | ||
110 | if (allow_unsupported_gpu) { | 103 | if (allow_unsupported_gpu) { |
111 | wlr_log(WLR_ERROR, | 104 | wlr_log(WLR_ERROR, |
112 | "!!! Proprietary AMD drivers are in use !!!"); | 105 | "!!! Proprietary AMD drivers are in use !!!"); |
@@ -118,8 +111,8 @@ void detect_proprietary(int allow_unsupported_gpu) { | |||
118 | } | 111 | } |
119 | break; | 112 | break; |
120 | } | 113 | } |
121 | free(line); | ||
122 | } | 114 | } |
115 | free(line); | ||
123 | fclose(f); | 116 | fclose(f); |
124 | } | 117 | } |
125 | 118 | ||
@@ -146,6 +139,19 @@ static void log_env(void) { | |||
146 | } | 139 | } |
147 | } | 140 | } |
148 | 141 | ||
142 | static void log_file(FILE *f) { | ||
143 | char *line = NULL; | ||
144 | size_t line_size = 0; | ||
145 | ssize_t nread; | ||
146 | while ((nread = getline(&line, &line_size, f)) != -1) { | ||
147 | if (line[nread - 1] == '\n') { | ||
148 | line[nread - 1] = '\0'; | ||
149 | } | ||
150 | wlr_log(WLR_INFO, "%s", line); | ||
151 | } | ||
152 | free(line); | ||
153 | } | ||
154 | |||
149 | static void log_distro(void) { | 155 | static void log_distro(void) { |
150 | const char *paths[] = { | 156 | const char *paths[] = { |
151 | "/etc/lsb-release", | 157 | "/etc/lsb-release", |
@@ -158,16 +164,7 @@ static void log_distro(void) { | |||
158 | FILE *f = fopen(paths[i], "r"); | 164 | FILE *f = fopen(paths[i], "r"); |
159 | if (f) { | 165 | if (f) { |
160 | wlr_log(WLR_INFO, "Contents of %s:", paths[i]); | 166 | wlr_log(WLR_INFO, "Contents of %s:", paths[i]); |
161 | while (!feof(f)) { | 167 | log_file(f); |
162 | char *line; | ||
163 | if (!(line = read_line(f))) { | ||
164 | break; | ||
165 | } | ||
166 | if (*line) { | ||
167 | wlr_log(WLR_INFO, "%s", line); | ||
168 | } | ||
169 | free(line); | ||
170 | } | ||
171 | fclose(f); | 168 | fclose(f); |
172 | } | 169 | } |
173 | } | 170 | } |
@@ -179,16 +176,7 @@ static void log_kernel(void) { | |||
179 | wlr_log(WLR_INFO, "Unable to determine kernel version"); | 176 | wlr_log(WLR_INFO, "Unable to determine kernel version"); |
180 | return; | 177 | return; |
181 | } | 178 | } |
182 | while (!feof(f)) { | 179 | log_file(f); |
183 | char *line; | ||
184 | if (!(line = read_line(f))) { | ||
185 | break; | ||
186 | } | ||
187 | if (*line) { | ||
188 | wlr_log(WLR_INFO, "%s", line); | ||
189 | } | ||
190 | free(line); | ||
191 | } | ||
192 | pclose(f); | 180 | pclose(f); |
193 | } | 181 | } |
194 | 182 | ||
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 @@ | |||
7 | #include <wlr/backend/session.h> | 7 | #include <wlr/backend/session.h> |
8 | #include <wlr/render/wlr_renderer.h> | 8 | #include <wlr/render/wlr_renderer.h> |
9 | #include <wlr/types/wlr_compositor.h> | 9 | #include <wlr/types/wlr_compositor.h> |
10 | #include <wlr/types/wlr_data_control_v1.h> | ||
10 | #include <wlr/types/wlr_export_dmabuf_v1.h> | 11 | #include <wlr/types/wlr_export_dmabuf_v1.h> |
11 | #include <wlr/types/wlr_gamma_control_v1.h> | 12 | #include <wlr/types/wlr_gamma_control_v1.h> |
12 | #include <wlr/types/wlr_gamma_control.h> | 13 | #include <wlr/types/wlr_gamma_control.h> |
@@ -140,6 +141,7 @@ bool server_init(struct sway_server *server) { | |||
140 | 141 | ||
141 | wlr_export_dmabuf_manager_v1_create(server->wl_display); | 142 | wlr_export_dmabuf_manager_v1_create(server->wl_display); |
142 | wlr_screencopy_manager_v1_create(server->wl_display); | 143 | wlr_screencopy_manager_v1_create(server->wl_display); |
144 | wlr_data_control_manager_v1_create(server->wl_display); | ||
143 | 145 | ||
144 | server->socket = wl_display_add_socket_auto(server->wl_display); | 146 | server->socket = wl_display_add_socket_auto(server->wl_display); |
145 | if (!server->socket) { | 147 | 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. | |||
327 | A view that does not have focus. | 327 | A view that does not have focus. |
328 | 328 | ||
329 | *client.urgent* | 329 | *client.urgent* |
330 | A view with an urgency hint. *Note*: This is not currently implemented. | 330 | A view with an urgency hint. *Note*: Native Wayland windows do not |
331 | support urgency. Urgency only works for Xwayland windows. | ||
331 | 332 | ||
332 | The meaning of each color is: | 333 | The meaning of each color is: |
333 | 334 | ||
@@ -431,7 +432,7 @@ The default colors are: | |||
431 | 432 | ||
432 | *focus\_follows\_mouse* yes|no|always | 433 | *focus\_follows\_mouse* yes|no|always |
433 | If set to _yes_, moving your mouse over a window will focus that window. If | 434 | If set to _yes_, moving your mouse over a window will focus that window. If |
434 | set to _always_, the window under the cursor will always be focused, even | 435 | set to _always_, the window under the cursor will always be focused, even |
435 | after switching between workspaces. | 436 | after switching between workspaces. |
436 | 437 | ||
437 | *focus\_wrapping* yes|no|force | 438 | *focus\_wrapping* yes|no|force |
@@ -450,11 +451,11 @@ The default colors are: | |||
450 | Thickness of the titlebar border in pixels | 451 | Thickness of the titlebar border in pixels |
451 | 452 | ||
452 | *titlebar\_padding* <horizontal> [<vertical>] | 453 | *titlebar\_padding* <horizontal> [<vertical>] |
453 | Padding of the text in the titlebar. _horizontal_ value affects horizontal | 454 | Padding of the text in the titlebar. _horizontal_ value affects horizontal |
454 | padding of the text while _vertical_ value affects vertical padding (space | 455 | padding of the text while _vertical_ value affects vertical padding (space |
455 | above and below text). Padding includes titlebar borders so their value | 456 | above and below text). Padding includes titlebar borders so their value |
456 | should be greater than titlebar\_border\_thickness. If _vertical_ value is | 457 | should be greater than titlebar\_border\_thickness. If _vertical_ value is |
457 | not specified it is set to the _horizontal_ value. | 458 | not specified it is set to the _horizontal_ value. |
458 | 459 | ||
459 | *for\_window* <criteria> <command> | 460 | *for\_window* <criteria> <command> |
460 | Whenever a window that matches _criteria_ appears, run list of commands. | 461 | 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) { | |||
654 | 654 | ||
655 | struct sway_seat *seat; | 655 | struct sway_seat *seat; |
656 | wl_list_for_each(seat, &server.input->seats, link) { | 656 | wl_list_for_each(seat, &server.input->seats, link) { |
657 | if (config->mouse_warping == WARP_CONTAINER) { | 657 | seat->cursor->image_surface = NULL; |
658 | struct sway_node *node = seat_get_focus(seat); | 658 | seat_consider_warp_to_focus(seat); |
659 | if (node && node->type == N_CONTAINER) { | ||
660 | cursor_warp_to_container(seat->cursor, node->sway_container); | ||
661 | } else if (node && node->type == N_WORKSPACE) { | ||
662 | cursor_warp_to_workspace(seat->cursor, node->sway_workspace); | ||
663 | } | ||
664 | } | ||
665 | } | 659 | } |
666 | 660 | ||
667 | transaction_commit_dirty(); | 661 | 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 @@ | |||
12 | #include "swaybar/config.h" | 12 | #include "swaybar/config.h" |
13 | #include "swaybar/i3bar.h" | 13 | #include "swaybar/i3bar.h" |
14 | #include "swaybar/status_line.h" | 14 | #include "swaybar/status_line.h" |
15 | #include "readline.h" | ||
16 | 15 | ||
17 | static void status_line_close_fds(struct status_line *status) { | 16 | static void status_line_close_fds(struct status_line *status) { |
18 | if (status->read_fd != -1) { | 17 | 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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <assert.h> | 2 | #include <assert.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <fcntl.h> | ||
4 | #include <getopt.h> | 5 | #include <getopt.h> |
5 | #include <pthread.h> | 6 | #include <pthread.h> |
6 | #include <signal.h> | 7 | #include <signal.h> |
@@ -104,9 +105,21 @@ static void acquire_sleep_lock(void) { | |||
104 | if (ret < 0) { | 105 | if (ret < 0) { |
105 | wlr_log(WLR_ERROR, "Failed to parse D-Bus response for Inhibit: %s", | 106 | wlr_log(WLR_ERROR, "Failed to parse D-Bus response for Inhibit: %s", |
106 | strerror(-ret)); | 107 | strerror(-ret)); |
108 | sd_bus_error_free(&error); | ||
109 | sd_bus_message_unref(msg); | ||
110 | return; | ||
107 | } else { | 111 | } else { |
108 | wlr_log(WLR_INFO, "Got sleep lock: %d", lock_fd); | 112 | wlr_log(WLR_INFO, "Got sleep lock: %d", lock_fd); |
109 | } | 113 | } |
114 | |||
115 | // sd_bus_message_unref closes the file descriptor so we need | ||
116 | // to copy it beforehand | ||
117 | lock_fd = fcntl(lock_fd, F_DUPFD_CLOEXEC, 3); | ||
118 | if (lock_fd < 0) { | ||
119 | wlr_log(WLR_ERROR, "Failed to copy sleep lock fd: %s", | ||
120 | strerror(errno)); | ||
121 | } | ||
122 | |||
110 | sd_bus_error_free(&error); | 123 | sd_bus_error_free(&error); |
111 | sd_bus_message_unref(msg); | 124 | sd_bus_message_unref(msg); |
112 | } | 125 | } |
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 @@ | |||
23 | #include "cairo.h" | 23 | #include "cairo.h" |
24 | #include "log.h" | 24 | #include "log.h" |
25 | #include "loop.h" | 25 | #include "loop.h" |
26 | #include "readline.h" | ||
27 | #include "stringop.h" | 26 | #include "stringop.h" |
28 | #include "util.h" | 27 | #include "util.h" |
29 | #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" | 28 | #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" |
@@ -808,36 +807,32 @@ static int load_config(char *path, struct swaylock_state *state, | |||
808 | wlr_log(WLR_ERROR, "Failed to read config. Running without it."); | 807 | wlr_log(WLR_ERROR, "Failed to read config. Running without it."); |
809 | return 0; | 808 | return 0; |
810 | } | 809 | } |
811 | char *line; | 810 | char *line = NULL; |
811 | size_t line_size = 0; | ||
812 | ssize_t nread; | ||
812 | int line_number = 0; | 813 | int line_number = 0; |
813 | while (!feof(config)) { | 814 | int result = 0; |
814 | line = read_line(config); | 815 | while ((nread = getline(&line, &line_size, config)) != -1) { |
815 | if (!line) { | ||
816 | continue; | ||
817 | } | ||
818 | |||
819 | line_number++; | 816 | line_number++; |
820 | if (line[0] == '#') { | 817 | |
821 | free(line); | 818 | if (line[nread - 1] == '\n') { |
822 | continue; | 819 | line[--nread] = '\0'; |
823 | } | 820 | } |
824 | if (strlen(line) == 0) { | 821 | |
825 | free(line); | 822 | if (!*line || line[0] == '#') { |
826 | continue; | 823 | continue; |
827 | } | 824 | } |
828 | 825 | ||
829 | wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line); | 826 | wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line); |
830 | char flag[strlen(line) + 3]; | 827 | char flag[nread + 3]; |
831 | sprintf(flag, "--%s", line); | 828 | sprintf(flag, "--%s", line); |
832 | char *argv[] = {"swaylock", flag}; | 829 | char *argv[] = {"swaylock", flag}; |
833 | int result = parse_options(2, argv, state, line_mode, NULL); | 830 | result = parse_options(2, argv, state, line_mode, NULL); |
834 | if (result != 0) { | 831 | if (result != 0) { |
835 | free(line); | 832 | break; |
836 | fclose(config); | ||
837 | return result; | ||
838 | } | 833 | } |
839 | free(line); | ||
840 | } | 834 | } |
835 | free(line); | ||
841 | fclose(config); | 836 | fclose(config); |
842 | return 0; | 837 | return 0; |
843 | } | 838 | } |
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, | |||
146 | schedule_indicator_clear(state); | 146 | schedule_indicator_clear(state); |
147 | break; | 147 | break; |
148 | case XKB_KEY_Caps_Lock: | 148 | case XKB_KEY_Caps_Lock: |
149 | /* The state is getting active after this | ||
150 | * so we need to manually toggle it */ | ||
151 | state->xkb.caps_lock = !state->xkb.caps_lock; | ||
152 | state->auth_state = AUTH_STATE_INPUT_NOP; | ||
153 | damage_state(state); | ||
154 | schedule_indicator_clear(state); | ||
155 | schedule_password_clear(state); | ||
156 | break; | ||
157 | case XKB_KEY_Shift_L: | 149 | case XKB_KEY_Shift_L: |
158 | case XKB_KEY_Shift_R: | 150 | case XKB_KEY_Shift_R: |
159 | case XKB_KEY_Control_L: | 151 | 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, | |||
63 | struct swaylock_state *state = data; | 63 | struct swaylock_state *state = data; |
64 | xkb_state_update_mask(state->xkb.state, | 64 | xkb_state_update_mask(state->xkb.state, |
65 | mods_depressed, mods_latched, mods_locked, 0, 0, group); | 65 | mods_depressed, mods_latched, mods_locked, 0, 0, group); |
66 | state->xkb.caps_lock = xkb_state_mod_name_is_active(state->xkb.state, | 66 | int caps_lock = xkb_state_mod_name_is_active(state->xkb.state, |
67 | XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED); | 67 | XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED); |
68 | if (caps_lock != state->xkb.caps_lock) { | ||
69 | state->xkb.caps_lock = caps_lock; | ||
70 | damage_state(state); | ||
71 | } | ||
68 | state->xkb.control = xkb_state_mod_name_is_active(state->xkb.state, | 72 | state->xkb.control = xkb_state_mod_name_is_active(state->xkb.state, |
69 | XKB_MOD_NAME_CTRL, | 73 | XKB_MOD_NAME_CTRL, |
70 | XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); | 74 | 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 @@ | |||
12 | #include <json-c/json.h> | 12 | #include <json-c/json.h> |
13 | #include "stringop.h" | 13 | #include "stringop.h" |
14 | #include "ipc-client.h" | 14 | #include "ipc-client.h" |
15 | #include "readline.h" | ||
16 | #include "log.h" | 15 | #include "log.h" |
17 | 16 | ||
18 | void sway_terminate(int exit_code) { | 17 | 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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <getopt.h> | 2 | #include <getopt.h> |
3 | #include <stdio.h> | ||
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <wordexp.h> | 5 | #include <wordexp.h> |
5 | #include "log.h" | 6 | #include "log.h" |
6 | #include "list.h" | 7 | #include "list.h" |
7 | #include "readline.h" | ||
8 | #include "swaynag/swaynag.h" | 8 | #include "swaynag/swaynag.h" |
9 | #include "swaynag/types.h" | 9 | #include "swaynag/types.h" |
10 | #include "util.h" | 10 | #include "util.h" |
@@ -12,21 +12,19 @@ | |||
12 | 12 | ||
13 | static char *read_from_stdin(void) { | 13 | static char *read_from_stdin(void) { |
14 | char *buffer = NULL; | 14 | char *buffer = NULL; |
15 | while (!feof(stdin)) { | 15 | size_t buffer_len = 0; |
16 | char *line = read_line(stdin); | 16 | char *line = NULL; |
17 | if (!line) { | 17 | size_t line_size = 0; |
18 | continue; | 18 | ssize_t nread; |
19 | } | 19 | while ((nread = getline(&line, &line_size, stdin)) != -1) { |
20 | 20 | buffer = realloc(buffer, buffer_len + nread); | |
21 | size_t curlen = buffer ? strlen(buffer) : 0; | 21 | snprintf(&buffer[buffer_len], nread + 1, "%s", line); |
22 | buffer = realloc(buffer, curlen + strlen(line) + 2); | 22 | buffer_len += nread; |
23 | snprintf(buffer + curlen, strlen(line) + 2, "%s\n", line); | ||
24 | |||
25 | free(line); | ||
26 | } | 23 | } |
24 | free(line); | ||
27 | 25 | ||
28 | while (buffer && buffer[strlen(buffer) - 1] == '\n') { | 26 | while (buffer && buffer[buffer_len - 1] == '\n') { |
29 | buffer[strlen(buffer) - 1] = '\0'; | 27 | buffer[--buffer_len] = '\0'; |
30 | } | 28 | } |
31 | 29 | ||
32 | return buffer; | 30 | return buffer; |
@@ -348,32 +346,24 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) { | |||
348 | type->name = strdup("<config>"); | 346 | type->name = strdup("<config>"); |
349 | list_add(types, type); | 347 | list_add(types, type); |
350 | 348 | ||
351 | char *line; | 349 | char *line = NULL; |
350 | size_t line_size = 0; | ||
351 | ssize_t nread; | ||
352 | int line_number = 0; | 352 | int line_number = 0; |
353 | while (!feof(config)) { | 353 | int result = 0; |
354 | line = read_line(config); | 354 | while ((nread = getline(&line, &line_size, config)) != -1) { |
355 | if (!line) { | ||
356 | continue; | ||
357 | } | ||
358 | |||
359 | line_number++; | 355 | line_number++; |
360 | if (line[0] == '#') { | 356 | if (!*line || line[0] == '\n' || line[0] == '#') { |
361 | free(line); | ||
362 | continue; | ||
363 | } | ||
364 | if (strlen(line) == 0) { | ||
365 | free(line); | ||
366 | continue; | 357 | continue; |
367 | } | 358 | } |
368 | 359 | ||
369 | if (line[0] == '[') { | 360 | if (line[0] == '[') { |
370 | char *close = strchr(line, ']'); | 361 | char *close = strchr(line, ']'); |
371 | if (!close) { | 362 | if (!close) { |
372 | free(line); | ||
373 | fclose(config); | ||
374 | fprintf(stderr, "Closing bracket not found on line %d\n", | 363 | fprintf(stderr, "Closing bracket not found on line %d\n", |
375 | line_number); | 364 | line_number); |
376 | return 1; | 365 | result = 1; |
366 | break; | ||
377 | } | 367 | } |
378 | char *name = calloc(1, close - line); | 368 | char *name = calloc(1, close - line); |
379 | strncat(name, line + 1, close - line - 1); | 369 | strncat(name, line + 1, close - line - 1); |
@@ -385,21 +375,17 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) { | |||
385 | } | 375 | } |
386 | free(name); | 376 | free(name); |
387 | } else { | 377 | } else { |
388 | char flag[strlen(line) + 3]; | 378 | char flag[nread + 3]; |
389 | sprintf(flag, "--%s", line); | 379 | sprintf(flag, "--%s", line); |
390 | char *argv[] = {"swaynag", flag}; | 380 | char *argv[] = {"swaynag", flag}; |
391 | int result; | ||
392 | result = swaynag_parse_options(2, argv, swaynag, types, type, | 381 | result = swaynag_parse_options(2, argv, swaynag, types, type, |
393 | NULL, NULL); | 382 | NULL, NULL); |
394 | if (result != 0) { | 383 | if (result != 0) { |
395 | free(line); | 384 | break; |
396 | fclose(config); | ||
397 | return result; | ||
398 | } | 385 | } |
399 | } | 386 | } |
400 | |||
401 | free(line); | ||
402 | } | 387 | } |
388 | free(line); | ||
403 | fclose(config); | 389 | fclose(config); |
404 | return 0; | 390 | return result; |
405 | } | 391 | } |