Commit Graph

95 Commits

Author SHA1 Message Date
Maxim Solovyov
23b0c5a1d5 x: don't require an entire struct x_connection in x_get_visual_for_depth
inspired by the xcb-util's xcb_aux_get_depth_of_visual function
implementation
2024-02-14 21:31:32 +03:00
Maxim Solovyov
1aa90f6466 x: remove x_sync and use xcb_aux_sync instead 2024-02-14 21:12:39 +03:00
Maxim Solovyov
4a79e7b777 render: fix binding the root background pixmap in case of depth mismatch
fix the same issue in the legacy backends, see the previous commit for
details. this commit also removes the x_validate_pixmap function because
it was used only in the get_root_tile function and the fix pretty much
implies and embeds it.
2024-02-02 02:04:45 +03:00
Maxim Solovyov
90f5f4ca29 fix a bunch of typos in comments 2024-01-31 06:09:28 +03:00
Yuxuan Shui
e92745671b compiler: use C23 auto when available
One annoying thing is C23 still defines auto as a storage class despite
it now being used for type inference. As a consequence we must write
"auto const" instead of the more natural "const auto".

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-12-17 08:55:23 +00:00
Maxim Solovyov
ae3c77b1a5 render: address some clang-tidy issues 2023-08-11 01:15:20 +03:00
Yuxuan Shui
1307d9ec70 core: isolate X connection with error handling into a struct
Part of the long running effort to reduce the prevalence of `session_t`.
After this, functions that communicate with X can make use of the error
handling machinary (set_ignore_cookie, set_cant_fail_cookie) without
needing to take a `session_t` parameter.

This commit converts everything to use the new struct `x_connection`,
most of the conversions are mechanical.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-07-04 16:24:53 +01:00
Maxim Solovyov
6b6a8da035 render: remove the unused background_props_str external constant 2023-06-18 14:55:22 +03:00
Yuxuan Shui
62fcfe5d1a backend: remove unused parameter 'ignore_damage'
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-06-08 20:35:16 +01:00
Maxim Solovyov
986b3c1cb3 core: drop xinerama
there are two x extensions for working with monitors (especially
multiple): xinerama and randr. xinerama is old, feature-poor and in
general isn't used anymore compared to the randr: new, feature-rich and
widely-used. for some reason we were using both of them, so let's drop
xinerama to keep things simple, clean and small. and to be modern.

the drop was done in three steps:
* first step was to replace all the xinerama-based code with the
  randr-based one and to replace or remove all the xinerama mentions;
* second step was to replace the xinerama's terminology with the
  randr's one. xinerama was referring only to the word "screen", while
  randr refers to multiple words and i think the word "monitor" is the
  most suitable for us and, hopefully, clear both to a contributor and
  to an end user;
* third step was to refactor the new randr-based code if needed and to
  address related todo's (mostly about moving related functions
  elsewhere).

all the steps were done well except addressing a leftover todo about
moving the win_update_monitor function to the x.c which wasn't done.

the xinerama-shadow-crop option was renamed to crop-shadow-to-monitor,
but it's previous name is still accepted, has effect and the
deprecation message is printed to preserve backwards-compatibility.
2023-01-29 10:51:12 +03:00
Yuxuan Shui
84407099a9 backend: give backends more flexibility regarding shadow creation
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2022-08-26 05:42:51 +01:00
Bernd Busse
4b5cc050d5 Add clip-shadow-above configuration and wintype option
Added the new `clip-shadow-above` configuration and wintype option.
These allow the user to select windows to clip from the shadow region of
other windows, i.e. don't paint shadows on top of them.

This should provide a more useful and userfriendly alternative to the
deprecated `shadow-exclude-reg` option — especially for docks and bars.
2021-07-14 14:43:28 +02:00
bhagwan
d9bfd0192d legacy glx: extend the border into the corners when they are rounded
Authored-By: bhagwan <bhagwan@disroot.org>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2021-04-12 01:54:00 +01:00
Yuxuan Shui
f5fb2648fd x: remove more of session_t parameters
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-26 07:51:03 +00:00
Yuxuan Shui
896c1a7702 render: restrict painting region of glx_round_corners_dst
Mistake during rebase.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-16 23:34:53 +00:00
Yuxuan Shui
06c58d0b8e render: avoid left shifting negative values
It's undefined behavior.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-12-16 22:55:33 +00:00
Yuxuan Shui
0f5f013b96 Rounded corners for legacy glx backend
Authored-by: bhagwan <bhagwan@disroot.org>
Authored-by: Samuel Hand <samuel.d.hand@gmail.com>
2020-12-16 18:10:36 +00:00
Yuxuan Shui
69d4199daa Add rounded-corners-exclude configuration option
Allows the user to selectively disable rounded corners.

Authored-by: Samuel Hand <samuel.d.hand@gmail.com>
2020-11-30 00:35:40 +00:00
Yuxuan Shui
430be62b63 Rounded corners for legacy xrender backend
Authored-by: Samuel Hand <samuel.d.hand@gmail.com>
2020-11-30 00:35:34 +00:00
Yuxuan Shui
dc37370a66 x: remove the last bit of Xlib dependency
Of course, we still use GLX, so we can't completely remove Xlib yet. But
this removes all Xlib uses outside of the backends.

This drops support for COMPOUND_TEXT Xorg strings, so people how wants
multilingual support has to use UTF8, which should be fine since most of
the applications support that.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-10-23 07:58:01 +01:00
Yuxuan Shui
8c1b0657ff Refresh the TODO comments
Removed the outdated ones, clarified some of them, and assigned them to
me.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-08-30 15:25:58 +01:00
Yuxuan Shui
4c1360f92a render: add trapezoid helper functions
Add functions to create shapes like rectangles and circles using xcb
trapezoids.

Contributed-by: Samuel Hand <samuel.d.hand@gmail.com>
2020-08-19 23:39:35 +01:00
Yuxuan Shui
d1f4969fc1 render: move argb_fbconfig to struct session
Because it needs to be cleared when we reset, so we don't use a freed
fbconfig across reset.

Related: #381

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-04-20 19:10:53 +01:00
Yuxuan Shui
0ba7761bd5 Untangle headers
Thanks, clang -fmodules.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-08-10 00:56:26 +01:00
Yuxuan Shui
8eb9d07fa8 Add dummy backend
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-08-04 17:52:45 +01:00
Yuxuan Shui
1f80c8dc16 render: don't free blur_kerns_cache when it's not used
blur_kernel_count could be none zero when user set a blur kernel but
didn't enable blur. In that case deinit_render will try to free
elements of blur_kerns_cache, causing a segfault because
blur_kerns_cache is never allocated.

Fixes #209

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-31 23:52:31 +01:00
Yuxuan Shui
79b135dccc Fix warnings when opengl is disabled
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:52:37 +01:00
Yuxuan Shui
bb756b2238 Fix compiler warning about unused parameters
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-25 02:27:02 +01:00
Yuxuan Shui
426043baa7 Improve transparency detection for blur
Previously, only the WM windows (window manager usually reparents the
application windows under its own window so it can manage them) are
checked for alpha channels. Some of the window managers (e.g. awesome)
acquire alpha channels for all of the WM windows, whether the underlying
application windows have alpha channel or not.

With this change, the application windows are also checked for alpha
channels. If a WM window has alpha but its child doesn't, only the WM
frame will be considered to be semi-transparent. Thus preventing some
unnecessary blurring.

Closes #191

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-13 12:37:28 +01:00
Yuxuan Shui
640b4b1c99 Move resize_region to region.h
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-07-06 13:26:25 +01:00
Yuxuan Shui
8e0b467138 Warn when using new blur methods on old backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-09 01:09:54 +01:00
Yuxuan Shui
fa8faaf91d Remember the number of blur kernels
Don't count the number of blur kernels everytime.

Fixes #188

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-07 22:21:06 +01:00
Yuxuan Shui
abb089e605 Lift the MAX_BLUR_PASS limit
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-07 07:04:50 +01:00
Yuxuan Shui
5e8d6bdc2d Don't destroy glx if it's not initialized
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-06 07:27:30 +01:00
Yuxuan Shui
82b9822fd0 config: introduce new syntax for blur options.
Parsing only, not used yet.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-06-01 00:39:00 +01:00
Yuxuan Shui
939f2fb602 common.h: general clean up
Remove unused functions and definitions. Move some macros into the files
they belong.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:34 +01:00
Yuxuan Shui
197e9dc866 auto enable sync fence for NVIDIA driver users
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:31 +01:00
Yuxuan Shui
bd4c242015 win: split struct win
Currently compton handles window creation event by immediately query all
the information it needs and create a window struct with that
information. However, this is prone to race conditions.

In the future, we want to react to window creation event by creating a
placeholder in the window stack, and only query window information in a
critical section where the X server is grabbed by us.

This commit split struct win into two struct, one as placeholder, the
other for holding actual window information.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:29 +01:00
Yuxuan Shui
abeeb36bb2 x: wrap xcb_generate_id to check for errors
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:28 +01:00
Yuxuan Shui
63dd16ebac Use int in margin_t
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui
0037b7e5fb Eliminate implicit conversions
Use explicit conversions everywhere. Adding bounds check assertions when
necessary.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:25 +01:00
Yuxuan Shui
1f80e547bc core: remove unnecessary win_check_fade_finished
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-05-21 20:15:24 +01:00
Yuxuan Shui
dd240d0576 Deprecate --glx-swap-method
Setting glx-swap-method to value other than "undefined" and "buffer-age"
could potentially cause rendering problems. So remove them, the meaning
of the remaining options can be more precisely captured by "use-damage",
so create a new option under that name.

--glx-swap-method is deprecated in favor of the new option --use-damage.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-12 00:35:47 +00:00
Yuxuan Shui
cebe1b18d6 vsync: choose vsync method automatically
Choose the best vsync method for the user, instead of asking them to
frustratingly try every one of the options to see what works.

With this commit, the `vsync` option will take only a boolean value.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 15:00:56 +00:00
Yuxuan Shui
e7de44260b Deprecate --vsync-aggressive
Original developer's word in man page: "Reported to work pretty terribly".

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-10 13:59:22 +00:00
Yuxuan Shui
d0fd21e167 Drop support for Composite < 0.2
Rational: current workaround for Composite < 0.2 doesn't work with the
GLX backend, it also doesn't handle window border properly. Plus,
Composite 0.2 came out more than a decade ago, it's safe to assume
everyone has it.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-05 22:14:23 +00:00
Yuxuan Shui
3707f792fb new_backend: New interface
Move more logic out of the backend. The backends are now more agnostic
to what happens in compton.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-03-03 22:18:34 +00:00
Yuxuan Shui
26214f312f x: create_picture_with_{visual, pictfmt} don't need session_t
Take xcb_connection_t and xcb_drawable_t instead.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-27 00:30:27 +00:00
Yuxuan Shui
0ceee9aad1 solid_picture and build_shadow shouldn't take session_t
Pass xcb_connection_t and xcb_drawable_t instead, which is what these
functions need.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-26 23:21:11 +00:00
Yuxuan Shui
64e08cc1e3 Fix memory leaks when using the new backends
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2019-02-20 18:21:40 +00:00