Commit Graph

305 Commits (0b621292246f2736eeed82ef106f64749c058f68)

Author SHA1 Message Date
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
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
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
xzfc 1f0c628cde
clang-format: bring back ForeachMacros (#3948)
* clang-format: bring back ForeachMacros

ForeachMacros was disabled in 4211274fcd
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
Orestis Floros 33634fbacd
Fix i3bar leak on handle_destroy_notify 2019-10-14 17:34:38 +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
Orestis Floros baf1067087
i3bar: If click events disabled, use whole bar for other events
Fixes #3700
2019-05-13 12:56:04 +03:00
Orestis Floros 8903f29795
child_handle_button: Call only if x >= offset
c2a1b6e9 was a bit overzealous, other actions should be executed if the
button was pressed after the workspace buttons but before the
statusline.

Also, should we allow other actions everywhere in the bar if click
events are disabled by the child?
2019-03-29 16:10:19 +02:00
Orestis Floros c2a1b6e91f
handle_button: Introduce child_handle_button
Also fixes an issue where action would be called if the button press was
on a separator. For example, if a user scrolled on a separator, the
workspace would change.

Applies to --release commands as well.
2019-03-28 21:05:43 +02:00
Orestis Floros 03d2ccdeef
handle_button: Use full render width for calculations
Fixes #3664

Also, click events' width will now always be >= min_width.
2019-03-28 21:05:29 +02:00
Soumya 3745e6f484
Add "modifiers" to events sent by i3bar 2018-10-25 16:02:06 -07:00
Orestis 5d70e2850f
Merge pull request #3475 from Gravemind/fix-i3bar-re-hidden-on-any-modifier
i3bar: Fix i3bar re-hidden by any modifier (#3474)
2018-10-23 18:41:11 +03:00
Orestis Floros e240c118c7
Close & reopen tray selwin when needed
Fixes #1329
Fixes #3317 (duplicate)
Examples where the tray "disappeared":
- Start without a "tray_output", reload config with "tray_output none",
remove "tray_output none" and reload.
- Start with "tray_output primary" (or "tray_output <output>"), disable
the primary output and then reconnect it.

Fixes #2010
Cached in output_for_tray
2018-10-23 16:41:09 +03:00
Gravemind c40c79538e i3bar: Fix i3bar re-hidden by any modifier (#3474)
The bug was introduced in 4.15-next fe6b3b7474
2018-10-23 15:17:30 +02:00
Orestis Floros a65914f338
Fix missing prototypes
i3 will now compile with no warnings when -Wmissing-prototypes is used.
2018-10-13 21:10:10 +03:00
Orestis Floros 2a9522dda4
Enforce strict prototypes
i3 will now compile with no warnings when -Wstrict-prototypes is used.
2018-10-13 21:10:09 +03:00
Orestis Floros fed059a2b7
Fix "relative_x" and "width" of click events
Now clicks begin at the start of the "actual" block, offsets and
separators don't trigger click events. The width property is now just
the width of the block, including border.

Fixes #3380.
2018-09-16 14:58:20 +03:00
Orestis Floros 9936d049cf
i3bar: Include sb_hoff_px only when needed
Fixes #3404.
2018-09-15 13:27:18 +03:00
Orestis Floros f4981f97bc
Replace strncpy call with memcpy when result is not NUL-terminated
This fixes a new warning from GCC 8.1, -Wstringop-truncation:
https://gcc.gnu.org/gcc-8/changes.html
https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Warning-Options.html#index-Wstringop-truncation

Replacing with memcpy is what gcc suggests:
> As another example, the following call to strncpy results in copying
> to d just the characters preceding the terminating NUL, without
> appending the NUL to the end. Assuming the result of strncpy is
> necessarily a NUL-terminated string is a common mistake, and so the
> call is diagnosed. To avoid the warning when the result is not
> expected to be NUL-terminated, call memcpy instead.
>    void copy (char *d, const char *s)
>    {
>      strncpy (d, s, strlen (s));
>    }
2018-05-08 17:05:46 +03:00
Orestis Floros aca7790217
Fix redundant return statements
… at the end of a function with a void return type.

Found using clang-tidy's readability-redundant-control-flow.
2018-04-27 00:09:42 +03:00
Orestis Floros fe6b3b7474
i3bar: make modifier behave like floating_modifier
Pressed modifiers are determined like in click.c:handle_button_press.

Fixes #3234.
2018-04-17 02:00:03 +03:00
Michael Stapelberg 145ac532aa i3bar: forward the sync request via IPC, not X11
i3bar’s X11 output is not what our testcases are testing — the state
manipulations which i3bar triggers via IPC messages to i3 are what we are
interested in.
2018-03-30 21:14:51 +02:00
Pallav Agarwal 161db6f17d Add relative coordinates in JSON for i3bar click events (fixes #2767)
Add support for relative coordinates in i3bar click events

Rename {x,y}_rel to relative_{x,y}

Update i3bar-protocol doc to mention the added fields in click events
2017-12-20 22:51:14 +05:30
Orestis Floros 315ff17563 Add '--release' flag for bindsym in the bar block
i3bar's handle_button is modified to also handle XCB_BUTTON_RELEASE
events. During these button release events, only custom commands are
checked to avoid sending multiple workspace ipc messages.

The way this patch is implemented will allow to assign a custom command
for both the press and release of the same button:
bar {
  ...
  bindsym buttonX exec command1
  bindsym --release buttonX exec command2
}

Fixes #3068.
2017-12-08 12:16:22 +02:00
Ingo Bürk 458e2a2e46
Merge pull request #3022 from orestisf1993/i3bar-leaks
Fix i3bar leaks
2017-12-03 19:51:25 +01:00
Orestis Floros 54c79e4b2f i3bar: free output data structures 2017-12-03 20:25:34 +02:00
Michael Stapelberg 0d8b6714e3 Move XCB event handling into xcb_prepare_cb.
Previously, we used ev_check watchers, which are executed at the beginning of an
event loop iteration.

This was problematic if one of the handlers happened to fill the XCB event
queue, e.g. by reading a reply from X11 and an event happened in the meantime.

In that situation, we would hand control to the event loop, entirely ignoring
the pending event. This would manifest itself as a 1-minute hang,
reproducible (sometimes) in the i3 testsuite.

issue #2790 describes an instance of this issue in i3bar, and we fixed that by
changing the watcher priority to run last. Handling events in xcb_prepare_cb has
the same effect, as ev_prepare watchers are run just before the event loop goes
to sleep.
2017-10-23 21:06:13 +02:00
Michael Stapelberg 2bff4f1dba Synchronize with i3bar+i3, not just i3. 2017-09-30 13:04:20 +02:00
Michael Stapelberg d968d39b27 Replace http:// with https:// where applicable
The testcases will be updated automatically in a separate commit.
2017-09-24 10:19:07 +02:00
Michael Stapelberg 607e97e651 ipc: rename COMMAND to RUN_COMMAND for consistency (#2956)
All other message types are verbs, only our first-ever message COMMAND wasn’t.

While we’re here, also change the message type dictionary into a table with
clickable links to the corresponding reply type.

Authors of downstream IPC libraries are encouraged to keep the old name around
so as to not break existing code, but mark it as deprecated.
2017-09-17 15:25:00 +02:00
Michael Stapelberg 8106ae7923 i3bar: Bugfix: avoid freeze after VisibilityNotify
fixes #2790
2017-08-20 12:16:43 +02:00
Michael Stapelberg 69efe0176e Prevent accidentally introduced fall-through
This was added in commit e82e26a24d
2017-08-19 17:29:31 +02:00
Ingo Bürk 432c4211ea Allow using left/right scrolling like up/down scrolling.
This commit makes left/right scrolling synonyms for up/down scrolling for
* scrolling on window decoration
* scrolling on i3bar workspaces

fixes #2677
2017-02-14 22:28:01 +01:00
Ingo Bürk 7732971ad8 Introduce named aliases for mouse buttons.
This increases readability and allows us to cover up the fact that
XCB doesn't define constants for left/right scrolling.
2017-02-12 20:44:45 +01:00
Ingo Bürk d58dbc3a77 Only react on the last Expose event in a series of events. (#2636)
Thanks to @psychon for pointing this out during the review of PR #2624.
This commit extends this change to all other occurences of Expose events
within i3.
2017-01-13 09:34:58 -08:00
Ingo Bürk e0582aa5eb Remove unused function arguments. (#2635)
The connection is no longer necessary since the non-cairo paths have
been removed.
2017-01-13 09:34:09 -08:00
Ingo Bürk f7a0453543 Free trayclient when removing it. (#2632)
fixes #2619
2017-01-13 09:28:29 -08:00
Michael Stapelberg f354f53435 Ensure all *.[ch] files include config.h
Including config.h is necessary to get e.g. the _GNU_SOURCE define and
any other definitions that autoconf declares. Hence, config.h needs to
be included as the first header in each file.

This is done either via:
1. Including "common.h" (i3bar)
2. Including "libi3.h"
3. Including "all.h" (i3)
4. Including <config.h> directly

Also remove now-unused I3__FILE__, add copyright/license statement
where missing and switch include/all.h to #pragma once.
2016-10-23 21:09:24 +02:00
Ingo Bürk e82e26a24d Handle ResizeRequests for tray clients. (#2495)
Some tray clients such as VLC use override_redirect on their tray window. As per
specification this means i3bar won't receive a ConfigureRequest, but instead a
ResizeRequest will be triggered. If not selected, the X server will simply confirm
the request which leads to a broken tray window size.

This commit selects and handles the event just like a configure request is handled.

fixes #2494
2016-10-11 11:46:25 -07:00
Michael Stapelberg 9bf346c7a0 Remove compatibility definitions for xcb-util < 0.3.8 (#2473)
Even Debian oldstable has xcb-util 0.3.8.
2016-09-24 09:48:32 -07:00
Eric Engeström 66d9c983e4 Fix spelling mistakes 2016-04-04 09:33:59 +02:00