573 Commits

Author SHA1 Message Date
Alessandro Vinciguerra
ca510e5e0f
Shrinking on a per-block basis (#5818)
Co-authored-by: Orestis Floros <orestisflo@gmail.com>
2024-01-28 11:30:28 +01:00
Orestis Floros
f169624560
clang-format: enable InsertBraces (#5882)
Enforces a rule that we have followed for years now. Yes, the diff is
quite big but we get it over with once and we prevent having to nit-pick
future PRs.
2024-01-27 11:37:05 +01:00
Orestis Floros
892ae730cb
Update ubuntu & clang-format in builds (#5467) 2023-04-02 16:24:15 +02:00
Orestis Floros
ba1f40f45f
i3bar: Add protocol for workspace buttons
Closes #3818 (parent issue)
Fixes #1808
Fixes #2333
Fixes #2617
Fixes #3548
2023-01-22 18:59:58 +01:00
Michael Stapelberg
8fe28d1a95 fix -Wmaybe-unused and -Wstringop-truncation warnings 2023-01-02 11:36:37 +01:00
Michael Stapelberg
0b89d4b2a7 implement bar { padding } config directive
related to https://github.com/i3/i3/issues/3724
related to https://github.com/i3/i3/pull/4288
fixes https://github.com/i3/i3/issues/3721
2022-10-30 22:22:08 +01:00
Michael Stapelberg
c45342e74f Merge support for the bar { height } option as-is from i3-gaps
related to https://github.com/i3/i3/issues/3724
related to https://github.com/i3/i3/issues/3721

In a follow-up commit, we can evolve this into the padding directive as
discussed on issue #3721.
2022-10-30 22:22:08 +01:00
George Rodrigues
6ab64aa5b7
Fix typos (#4989) 2022-06-01 09:49:05 +02:00
Ingo Bürk
c822eff1bf
Remove Xlib references (#4845)
* remove Xlib import from i3bar

* remove unused Xlib declarations
2022-02-10 10:25:20 +01:00
rvalieris
64021b6143 check for both arguments NULL on strings_differ 2021-10-22 07:51:07 -03:00
Uli Schlachter
d65a7ed250
Drop xcb_flush() before xcb_aux_sync() (#4378)
xcb_flush() flushes xcb's output buffer. Thus, after this call, all
previous requests are surely written to the connection with the X11
server.

xcb_aux_sync() synchronises with the X11 server. It makes sure all
previous requests were sent to the X11 server and already processed. It
does this via free(xcb_get_input_focus_reply(xcb_get_input_focus())): It
sends a request and waits for its reply. It is guaranteed that the X11
server processes requests in-order.

This means that the sequence xcb_flush(); xcb_aux_sync() first writes
whatever is in the output buffer and then does another write for the
four bytes of the GetInputFocus request from xcb_aux_sync().

Put differently: xcb_flush(); xcb_aux_sync() doesn't do anything more
than just xcb_aux_sync(). In fact, it has slightly more overhead for the
same result.

Thus, this commit drops all calls to xcb_flush() immediately after
xcb_aux_sync().

Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-05-20 21:44:13 +02:00
Orestis Floros
ba134d3c7c
i3bar: Exit with 1 on wrong argument 2021-01-15 23:35:31 +01:00
Orestis Floros
6668d03157
i3bar: LOG version on startup 2021-01-15 23:28:33 +01:00
Orestis Floros
1a29b28fa5
i3bar: No reason to get_workspaces after output event
got_output_reply() requests this information anyway and if it is
received before the output reply, the information will be erased by
get_output_reply().
2021-01-12 08:56:38 +01:00
Orestis Floros
6e0b29a65b
i3bar: properly restart status command after config change 2021-01-12 08:56:38 +01:00
Orestis Floros
0370c5e297
i3bar: Properly close FDs 2021-01-12 08:35:41 +01:00
Orestis Floros
c1ec2ad19b
i3bar: Add default bar_id
Instead of erroring, request the list of bar configs from i3 and use the
first one.
2021-01-03 10:17:43 +01:00
Orestis Floros
fb5d2a05c2
i3bar: Update manpage/help with options 2021-01-03 10:17:39 +01:00
Maxim Schuwalow
90e7a156a2
i3bar: add support for nonprimary output
Added a new output option `nonprimary` that causes the bar to be
displayed on all outputs except the primary one.

Fixes #4083
2020-10-24 11:44:34 +02:00
Andrey Burov
60384d446b Add coordinates relative to the current output in i3bar click events
Currently i3bar click events provide x and y coordinates relative to all monitors.
I've added coordinates relative to the current output.

+-----------+-----------+
|           |   i3bar   |
|           +-----------+
|   HDMI-0  |    DP-0   |
| 1920x1080 | 2560x1080 |
+-----------+-----------+

When you click in the top right corner of the DP-0,
i3bar will provide something like this:

{
  "x": 4480,
  "y": 10,
  "output_x": 2560,
  "output_y": 10,
}

This is useful for creating a rofi menu or something else.
rofi -show run -location 1 -xoffset ${I3_OUTPUT_X} -yoffset ${I3_OUTPUT_Y}
2020-10-23 12:51:21 +03:00
Albert Safin
e3a1c5b294
clang-format: use TypenameMacros
This commit removes line breaks and extra empty lines introduced in
commit fff3f79da9a87a1f790c6328f6615422f2b69b47.
2020-10-20 09:36:44 +02:00
Orestis Floros
f33a49372f
i3bar: Remove duplicate call to kick_tray_clients (#4163)
Fixes #4159
Fixes #4162
2020-08-31 08:58:46 +02:00
Michael Stapelberg
6bb01bbe83 Merge branch 'stable' into next 2020-07-26 10:11:49 +02:00
Orestis Floros
68904aeb38 Fix i3bar Xorg memory leak (#4140)
The `*_free_*` calls in this branch:
51b0583578/i3bar/src/xcb.c (L1854)
are never called when we remove the output from the tailq during a
refresh.

Fixes #4123
2020-07-22 09:33:19 +02:00
Mark Guptill
838b600fea kick tray clients before destroying the bar 2020-06-30 04:34:32 -04:00
Orestis Floros
025743eaf9
Fix i3bar Xorg memory leak (#4140)
The `*_free_*` calls in this branch:
51b0583578/i3bar/src/xcb.c (L1854)
are never called when we remove the output from the tailq during a
refresh.

Fixes #4123
2020-06-27 00:10:53 +02:00
Orestis Floros
81671d454e Call cont_child() more liberally (#3996)
Following the reproduction instructions from
https://github.com/i3/i3/issues/3242#issuecomment-436175346

For me, #3242 happened when the following sequence executed:
1. Fullscreening window correctly calls `stop_child()` in
6e24e2ad6f/i3bar/src/xcb.c (L685)
2. Xrandr change, `reconfig_windows()` is called and `output->visible` is
set to `true` in this line:
6e24e2ad6f/i3bar/src/xcb.c (L1791)
3. When the window's fullscreen is disabled,
`handle_visibility_notify()` returns in this line:
6e24e2ad6f/i3bar/src/xcb.c (L677)
because previously `output->visible` was set to `true`

To fix this, I call `cont_child()` more leniently since it is a no-op
when the child is not stopped.

Fixes #3242
Closes #3761
2020-04-22 08:55:41 +02:00
Orestis Floros
d614f26906 Fix SEGFAULT when i3bar receives invalid input
Fixes #3844
2020-04-22 08:54:51 +02:00
Orestis Floros
0b62129224
Remove unused headers
With help from
https://github.com/include-what-you-use/include-what-you-use/
2020-04-20 04:25:06 +02:00
Orestis Floros
3c522d9f2f
Sort includes in *.c files
Not enabling in .clang-format because it breaks headers files.

Used:
    IncludeCategories:
      - Regex:           '^<config'
        Priority:        0
      - Regex:           '^".*"'
        Priority:        1
      - Regex:           '^<(xcb|xkb|yajl|X11)'
        Priority:        3
      - Regex:           '.*'
        Priority:        2
2020-04-19 09:58:25 +02:00
Orestis Floros
7df88f18eb
Sort dock clients by class and instance
This is similar to #3820 but does not use qsort but an insertion sort in
con_attach.

Since each bar block automatically gets its own incremental bar id,
bards end up being sorted according to their definition order in the
config file.

For i3bar, the WM_CLASS is modified to include an instance name which
depends on the bar_id. This could be useful for other reason, e.g. users
targeting a specific bar instance.

Fixes #3491
2020-04-14 20:47:51 +02:00
Orestis Floros
4212fb6488
i3bar: Set WM_CLASS instance to bar_id 2020-04-14 20:46:49 +02:00
Ingo Bürk
e2b2a28625
Merge pull request #4004 from orestisfl/i3bar-segfault
Fix SEGFAULT when i3bar receives invalid input
2020-04-10 14:00:51 +02:00
Orestis Floros
91ec14f2bc
Fix SEGFAULT when i3bar receives invalid input
Fixes #3844
2020-04-10 11:38:19 +02:00
Orestis Floros
40697a233c
i3bar: Add a macro to log child info
Mentioned in #3242
2020-04-10 03:22:34 +02:00
Orestis Floros
016d4a3f45
Call cont_child() more liberally (#3996)
Following the reproduction instructions from
https://github.com/i3/i3/issues/3242#issuecomment-436175346

For me, #3242 happened when the following sequence executed:
1. Fullscreening window correctly calls `stop_child()` in
6e24e2ad6f/i3bar/src/xcb.c (L685)
2. Xrandr change, `reconfig_windows()` is called and `output->visible` is
set to `true` in this line:
6e24e2ad6f/i3bar/src/xcb.c (L1791)
3. When the window's fullscreen is disabled,
`handle_visibility_notify()` returns in this line:
6e24e2ad6f/i3bar/src/xcb.c (L677)
because previously `output->visible` was set to `true`

To fix this, I call `cont_child()` more leniently since it is a no-op
when the child is not stopped.

Fixes #3242
Closes #3761
2020-04-09 10:43:48 +02:00
Jason
5024a13b8b
Remove comment referencing old source code
Behaviour was changed in f691a55923850a4d315450925fc98733d07b69c9
2020-03-01 05:03:41 +09:00
xzfc
47be36410c
Assume xcb_cursor_context_new never fails (#3955)
According to libxcb-cursor code, the only condition in which
xcb_cursor_context_new() returns a non-zero result is a memory
allocation failure[1].  Thus, it is safe to assume that
xcursor_supported is always true, and remove dead code.

[1]: https://gitlab.freedesktop.org/xorg/lib/libxcb-cursor/blob/0.1.3/cursor/cursor.c#L131-132
2020-02-24 08:48:58 +01:00
Albert Safin
83c7aff089 Limit workspace numbers within 0..INT32_MAX
Before this commit, large workspace numbers treated oddly:

   $ i3-msg 'rename workspace to 1234567890'
   # displayed in i3bar as `0`

   $ i3-msg 'rename workspace to 4294967200'
   $ i3-msg -t get_workspaces | jq '.[]|select(.focused).num'
   -96 # int32_t overflow

   $ i3-msg 'rename workspace to 99999999999999999999'
   $ i3-msg -t get_workspaces | jq '.[]|select(.focused).num'
   -1 # treated as unnumbered

This commit puts a consistent limit on workspace numbers.  Now
workspaces with numbers beyond INT32_MAX are treated as unnumbered.
2020-02-21 02:07:04 +00:00
xzfc
1f0c628cde
clang-format: bring back ForeachMacros (#3948)
* clang-format: bring back ForeachMacros

ForeachMacros was disabled in 4211274fcd028a8e33a084e5695290ae0e9f3020
due to the breakage of include/queue.h. The currently used version,
clang-format-6.0 doesn't break it.

* Add curly braces

Co-authored-by: Orestis Floros <orestisflo@gmail.com>
2020-02-19 11:31:09 +01:00
Orestis Floros
d14e59b3a7
i3bar: Make header declarations extern
See #3914
2020-02-01 17:33:53 +01:00
Iskustvo
5835bbc385 Added workspace ID in GET_WORKSPACES response. 2020-01-08 09:07:53 +01:00
Orestis Floros
33634fbacd
Fix i3bar leak on handle_destroy_notify 2019-10-14 17:34:38 +03:00
Orestis Floros
ee30c34b5c
Fix small leak in i3bar's main
If -s is used, the socket_path returned by getenv is never freed.

Also some small rearrangements.
2019-10-14 03:54:48 +03:00
Orestis Floros
98d96c3a2c
reorder_trayclients_cmp: Correct comment 2019-10-11 19:32:58 +03:00
Orestis Floros
eda814755a
Make tray icon order deterministic
Fixes #3573
2019-10-11 18:25:22 +03:00
Orestis Floros
d5a3b8af02
Introduce trayclient_and_output_from_window
Saves some code repetition
2019-10-11 16:12:48 +03:00
Konst Mayer
94228fd902 Add setting for minimal width of workspace buttons 2019-06-25 13:10:01 +07:00
Ingo Bürk
ca82f95812 feat: added support for user-defined border widths in i3bar blocks (#3726)
This change introduces support for four new properties on the i3bar
protocol, namely "border_top", "border_right", "border_bottom"
and "border_left".

If a block is drawn with a border, these values define the width of
the corresponding edge in pixels. They all default to 1 if not
specified to preserve compatibility.

fixes #3722
2019-06-22 22:18:29 +02:00
Ingo Bürk
48af067dfe feat: support transparency (RGBA) in i3bar (#3727)
We introduce a --transparency flag for i3bar in order to enable a mode which
supports the use of RGBA colors.

An important constraint here is that tray icons will always have
a fully transparent background.

fixes #3723
2019-06-22 17:23:21 +02:00