Commit Graph

76 Commits

Author SHA1 Message Date
a1cd0acac5 Fix random segfault on GTK icon functions
The segfaults were happening on GTK icon theme functions, which are
called via the C++ interface functions such as Gtk::IconTheme::has_icon.

There are multiple modules and threads using this functions on the default
icon theme by calling Gtk::IconTheme::get_default(), which returns the same
object for all callers, and was causing concurrent access to the same internal
data structures on the GTK lib. Even a seemingly read-only function such as
has_icon can cause writes due to the internal icon cache being updated.

To avoid this issues, a program wide global mutex must be used to ensure
a single thread is accessing the default icon theme instance.

This commit implements wrappers for the existing IconTheme function calls,
ensuring the global lock is held while calling the underling GTK functions.
2023-07-03 22:32:24 +01:00
fff4509723 sway/window: fix appid style not cleared (#2227)
Probably a rebase error during development of #1419. The code block now
removed was not supposed to be there anymore.
2023-06-11 08:41:20 +02:00
f557697e92 Rewrite entire label in sway/window module
Closes #1742
2023-03-25 17:37:49 +01:00
63525ec956 Rename function name 2023-03-25 17:33:01 +01:00
ea17a66dfc fix: compilation errors with cpp_std=c++20
There were two main issues with fmtlib and C++20 mode:

 - `fmt::format` defaults to compile-time argument checking and requires
   using `fmt::runtime(format_string)` to bypass that.
 - `std::format` implementation introduces conflicting declarations and
   we have to specify the namespace for all `format`/`format_to` calls.
2023-01-20 22:50:02 -08:00
328573332f sway-window, Issue 1399: new style classes
Provides CSS classes empty, floating, tabbed, tiled, solo, stacked and
app_id.

Adds offscreen-css bool option (default false), only effective when
"all-outputs" is true. This adds styles on outputs without focused
node, according to its focused workspaces window situation.

Adds an "offscreen-css-text" string option (default empty), only
effective when "all-outputs" and "offscreen-style" are set. This
is shown as a text on outputs without a focused node.

Adds a "show-focused-workspace" bool option (default false) to indicate
the workspace name if the whole workspace is focused when nodes are
also present. If not set, empty text is shown, but css classes
according to nodes in the workspace are still applied.

Limitation:
When the top level layout changes, there is no sway event so the
module cannot react. Perhaps in the future recurring polling can
be added to go around this limitation.
2023-01-12 05:53:59 +01:00
e660a3634d Fix linter 2022-10-19 13:29:05 +02:00
54e04b5a30 Refactor rewriteTitle 2022-10-19 13:25:08 +02:00
bcee4e15d3 fix: lint files 2022-08-18 15:22:25 +02:00
b7bd06ad8f Update window.cpp 2022-08-18 15:21:50 +02:00
5b1cd65e20 Fix: better formatting 2022-08-10 10:41:18 +02:00
99ed2bb7fa Feature: sway/window can show 'shell' parameter 2022-08-10 10:34:51 +02:00
4d1aeb7eb8 Merge pull request #1525 from FlexW/feature/icon-heuristics
sway/window: Add heuristics for finding icons
2022-05-23 13:42:26 +02:00
3f123d9c4e sway/window: Add heuristics for finding icons
This adds heuristics for finding the applications icon.
2022-04-18 03:09:25 +02:00
fc6f5741b1 sway/window: Allow the user to change the size of the app icon
Fixes #1461
2022-04-17 23:57:57 +02:00
45988b3dbb Sway/window: Only update icon from main thread
If Gtk objects get updated from other threads than the main thread GTK
can get confused. This is a regression of bcadf64031.

Fixes #1464, #1474
2022-04-17 22:55:58 +02:00
f2fcadbf62 refactor: lint 2022-04-06 08:37:19 +02:00
bcadf64031 Show application icon when using sway window module
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2022-01-24 17:37:51 +01:00
9972384597 sway/window: include floating_nodes when considering window count for class 2021-10-02 18:35:38 +02:00
a03283d65f rewriteTitle: allow multiple sequential rewrites 2021-04-26 20:26:43 +02:00
af3c868a5b Catch exception on erroneous rules
std::regex and std::regex_replace may throw an std::regex_error if the
expression or replacement contain errors.

Log this error and carry on with the next rule, so that the title is
shown even if the config contains errors.
2021-04-21 12:24:47 +02:00
b16c8972c7 Add option to rewrite sway/window title
Rewrites window title according to config option "rewrite".
"rewrite" is an object where keys are regular expressions and values are
rewrite rules if the expression matches. Rules may contain references to
captures of the expression. Regex and replacement follow ECMA-script
rules. If no regex matches, the title is left unchanged.

example:
"sway/window": {
  "rewrite": {
    "(.*) - Mozilla Firefox": " $1",
    "(.*) - zsh": " $1",
  }
}
2021-04-21 12:24:47 +02:00
e19aa1d43a [sway/window] Add app_id to usable fields in title 2021-01-30 01:41:45 +01:00
cb7baee045 Fixed compile error 2020-12-18 18:17:17 -05:00
85ca5027f4 Fix Sway #waybar.solo CSS rule applying on split
This error occurs because of an incorrect assumption that the size of
the list of nodes that contains the focused window is the number of
windows in a workspace.

The windows in a workspace are stored as a tree by Sway, rather than a
list, so the number of windows has to be found by counting the leaves of
a workspace tree.
2020-12-18 18:14:14 -05:00
4a7dd400fe Merge branch 'master' into on-update 2020-04-12 18:32:19 +02:00
b40cdcb5bd refactor: call parent update 2020-04-12 18:30:21 +02:00
ae6ca36fa7 fix(sway): resolve destruction dependency between Ipc and SleeperThread
Ipc destructor closes socket and thus wakes up SleeperThread which was
waiting for socket data in Ipc::handleEvent.
Ipc::handleEvent then proceeds with sending signal to already destroyed
object, causing heap-use-after-free Address Sanitizer error.
2020-02-04 23:22:43 -08:00
66f2cbed51 Fix typo
ouput -> output
2019-08-31 17:50:56 +00:00
a6980fca7f feat: ellipsize modules 2019-06-28 14:16:09 +02:00
bd5146fdcf fix(Label): ELLIPSIZE all label modules 2019-06-28 13:49:04 +02:00
ff9d598c16 fix: add proper mutex 2019-06-17 11:39:45 +02:00
340ec7be91 refactor: AModule 2019-06-15 14:57:52 +02:00
dabe2bebbb feat(sway/window): handle floating nodes 2019-06-14 11:27:40 +02:00
486b5a5d38 fix(sway/window): check output recursively 2019-06-14 10:57:22 +02:00
3c9b533997 fix(window): avoid hexpand 2019-06-11 17:57:17 +02:00
a37b4687ff Revert "refactor(window): we don't need to subscribe workspace events"
This reverts commit 648eecdd83.
2019-06-11 14:06:31 +02:00
648eecdd83 refactor(window): we don't need to subscribe workspace events 2019-06-07 15:08:33 +02:00
1962caf144 refactor(window): gtk stuff in update method 2019-06-04 17:34:00 +02:00
d24d85bebf refactor: move label name and id to label contructor 2019-05-22 12:06:24 +02:00
51be97f9aa Adding spdlog 2019-05-18 19:44:45 -04:00
0c3c548bc0 fix(Window): avoid concurrency 2019-05-13 14:35:45 +02:00
62f8af8a39 fix(Window): avoid multiple same classes 2019-05-13 10:56:48 +02:00
7cdde05568 remove empty and solo classes when they do not apply 2019-05-11 20:36:10 +02:00
5bf0ca85ac refactor: try/catch around json parse 2019-05-09 10:30:54 +02:00
5a44c8c6de refactor: avoid unneeded json parsing 2019-05-07 13:43:48 +02:00
74137befba fix(window): title flickers 2019-05-07 13:31:41 +02:00
717a07d584 refactor(Window): simpler conditions 2019-04-26 15:29:54 +02:00
bb8ff5a99f feat(Bar): add class depend of window in the workspace 2019-04-25 16:47:51 +02:00
311c34ecbc feat(Bar): handle widget size changes 2019-04-24 12:37:24 +02:00