2018-10-03 17:14:51 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// Copyright (c)
|
2012-02-26 23:00:12 -05:00
|
|
|
|
|
|
|
// Throw everything in here.
|
2019-01-20 16:15:20 -05:00
|
|
|
// !!! DON'T !!!
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-21 23:42:39 -04:00
|
|
|
|
|
|
|
// === Includes ===
|
|
|
|
|
|
|
|
#include <locale.h>
|
2019-03-10 08:34:37 -04:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
2019-01-20 16:15:20 -05:00
|
|
|
#include <xcb/xproto.h>
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-07 22:20:01 -04:00
|
|
|
|
2018-10-25 18:31:40 -04:00
|
|
|
#include <X11/Xutil.h>
|
2019-02-09 10:52:40 -05:00
|
|
|
#include "backend/backend.h"
|
2018-08-22 08:26:42 -04:00
|
|
|
#include "c2.h"
|
2019-03-10 08:34:37 -04:00
|
|
|
#include "common.h"
|
2019-01-18 18:30:44 -05:00
|
|
|
#include "compiler.h"
|
2019-03-10 08:34:37 -04:00
|
|
|
#include "config.h"
|
|
|
|
#include "log.h" // XXX clean up
|
|
|
|
#include "region.h"
|
|
|
|
#include "render.h"
|
2019-01-18 18:30:44 -05:00
|
|
|
#include "types.h"
|
|
|
|
#include "utils.h"
|
2019-03-10 08:34:37 -04:00
|
|
|
#include "win.h"
|
|
|
|
#include "x.h"
|
2018-08-22 08:26:42 -04:00
|
|
|
|
core: delayed handling of root ConfigureNotify
Previously, root ConfigureNotify is handled immediately, by resetting
the backend, which in turn releases all the window images. This puts all
the windows into a state where they don't have images attached, which
they really should be in when the screen is redirected.
(To expand a little, a window without images should only exist if:
* It's an unmanaged window.
* Screen is unredirected.)
Normally, this kind of window could be fine, as the next render phase
will re-acquire images for them. However, if a window in this state is
destroyed with fading enabled, then the render phase won't try to
acquire images for it, causing it to go into the main rendering function
without images attached, and trigger an assertion.
This commit delays the handling of root ConfigureNotify until the render
phase. This way, the images will be immediately re-acquired after they
are released, thus prevent this problem from happening.
Also adds a testcase for this.
Fixes #357
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2020-03-31 00:01:14 -04:00
|
|
|
enum root_flags {
|
|
|
|
ROOT_FLAGS_SCREEN_CHANGE = 1, // Received RandR screen change notify, we
|
|
|
|
// use this to track refresh rate changes
|
|
|
|
ROOT_FLAGS_CONFIGURED = 2 // Received configure notify on the root window
|
|
|
|
};
|
2019-03-17 11:17:48 -04:00
|
|
|
|
2012-11-18 20:46:07 -05:00
|
|
|
// == Functions ==
|
2020-08-30 10:25:58 -04:00
|
|
|
// TODO(yshui) move static inline functions that are only used in picom.c, into picom.c
|
2012-09-11 09:57:50 -04:00
|
|
|
|
Convert XfixesRegion to pixman region
Re-did the painting logic, and document it.
It is unclear to me what is the previous painting logic. But the current
one is basically this:
1. Go through all windows top to bottom, and put visible windows (not
unmapped, opacity > 0, etc) into a linked list, from bottom to top
2. Accumulate a region of ignore on each window, which is basically the
region of screen that is obscured by all the windows above current
one.
3. Paint all the visible windows from bottom to top. Subtract the region
of ignore from the painting region. If we need to paint shadow, we
subtract the body of the window from the shadow painting region too,
because we don't want shadow behind the window.
4. region of ignore is invalidated when window stack change, an
window on top moved or changed shape, when window changed between
opaque and transparent, etc.
Notes:
It is unclear whether all the different shapes of a window (extents,
noframe, border, bounding shape, etc) are calculated correctly or not.
It is unclear if window shape related events are handled correctly or
not. Need more testing.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-29 23:56:00 -04:00
|
|
|
void add_damage(session_t *ps, const region_t *damage);
|
2018-09-08 21:29:45 -04:00
|
|
|
|
2019-03-30 05:07:21 -04:00
|
|
|
uint32_t determine_evmask(session_t *ps, xcb_window_t wid, win_evmode_t mode);
|
2012-09-16 11:12:02 -04:00
|
|
|
|
2019-03-17 09:44:26 -04:00
|
|
|
void circulate_win(session_t *ps, xcb_circulate_notify_event_t *ce);
|
|
|
|
|
|
|
|
void update_refresh_rate(session_t *ps);
|
|
|
|
|
|
|
|
void root_damaged(session_t *ps);
|
|
|
|
|
|
|
|
void cxinerama_upd_scrs(session_t *ps);
|
|
|
|
|
|
|
|
void queue_redraw(session_t *ps);
|
|
|
|
|
|
|
|
void discard_ignore(session_t *ps, unsigned long sequence);
|
|
|
|
|
2019-03-17 11:17:48 -04:00
|
|
|
void set_root_flags(session_t *ps, uint64_t flags);
|
|
|
|
|
2019-10-23 14:27:30 -04:00
|
|
|
void quit(session_t *ps);
|
2019-07-24 21:27:02 -04:00
|
|
|
|
2019-07-07 11:12:17 -04:00
|
|
|
xcb_window_t session_get_target_window(session_t *);
|
|
|
|
|
2020-03-11 15:15:26 -04:00
|
|
|
uint8_t session_redirection_mode(session_t *ps);
|
|
|
|
|
2012-12-09 21:31:24 -05:00
|
|
|
/**
|
|
|
|
* Set a <code>switch_t</code> array of all unset wintypes to true.
|
|
|
|
*/
|
2019-03-10 08:34:37 -04:00
|
|
|
static inline void wintype_arr_enable_unset(switch_t arr[]) {
|
|
|
|
wintype_t i;
|
2012-12-09 21:31:24 -05:00
|
|
|
|
2019-03-10 08:34:37 -04:00
|
|
|
for (i = 0; i < NUM_WINTYPES; ++i)
|
|
|
|
if (UNSET == arr[i])
|
|
|
|
arr[i] = ON;
|
2012-12-09 21:31:24 -05:00
|
|
|
}
|
|
|
|
|
2012-09-11 10:22:58 -04:00
|
|
|
/**
|
|
|
|
* Check if a window ID exists in an array of window IDs.
|
|
|
|
*
|
|
|
|
* @param arr the array of window IDs
|
|
|
|
* @param count amount of elements in the array
|
|
|
|
* @param wid window ID to search for
|
|
|
|
*/
|
2019-03-10 08:34:37 -04:00
|
|
|
static inline bool array_wid_exists(const xcb_window_t *arr, int count, xcb_window_t wid) {
|
|
|
|
while (count--) {
|
|
|
|
if (arr[count] == wid) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2012-09-11 10:22:58 -04:00
|
|
|
}
|
2012-09-16 11:12:02 -04:00
|
|
|
|
2012-11-18 20:46:07 -05:00
|
|
|
/**
|
Feature #16: Advanced window matching
- Add advanced window matching system, capable of matching against
arbitrary window properties as well as a series of internal
properties, with 4 additional operators (>, <, >=, <=) useful for
integer targets, and support of logical operators. The old matching
system is removed, but compatibility with the format is retained.
- As the new matching system is pretty complicated, and I have no past
experience in writing a parser, it's pretty possible that bugs are
present. It also has inferior performance, but I hope it doesn't
matter on modern CPUs.
- It's possible to disable matching system at compile time with NO_C2=1
now.
- Add ps->o.config_file to track which config file we have actually
read. Queryable via D-Bus.
- Parse -d in first pass in get_cfg() as c2 needs to query X to get
atoms during condition parsing.
- Fix a bug in wid_get_prop_adv() that 0 == rformat is not handled
correctly.
- Fix incompatibility with FreeBSD sed in dbus-examples/cdbus-driver.sh
.
- Add recipe to generate .clang_complete in Makefile, used by Vim
clang_complete plugin.
- Add DEBUG_C2 for debugging condition string parsing. DEBUG_WINMATCH is
still used for match debugging.
- Rename win_on_wdata_change() to win_on_factor_change().
- Extra malloc() failure checks. Add const to matching cache members in
session_t. Code clean-up. Documentation update.
2013-01-28 08:39:38 -05:00
|
|
|
* Destroy a condition list.
|
2012-11-18 20:46:07 -05:00
|
|
|
*/
|
2019-03-10 08:34:37 -04:00
|
|
|
static inline void free_wincondlst(c2_lptr_t **pcondlst) {
|
|
|
|
while ((*pcondlst = c2_free_lptr(*pcondlst)))
|
|
|
|
continue;
|
2013-05-09 09:47:09 -04:00
|
|
|
}
|
2012-11-18 20:46:07 -05:00
|
|
|
|
2018-12-15 16:11:41 -05:00
|
|
|
#ifndef CONFIG_OPENGL
|
2019-07-24 21:48:12 -04:00
|
|
|
static inline void free_paint_glx(session_t *ps attr_unused, paint_t *p attr_unused) {
|
2019-03-10 08:34:37 -04:00
|
|
|
}
|
2019-07-24 21:48:12 -04:00
|
|
|
static inline void
|
|
|
|
free_win_res_glx(session_t *ps attr_unused, struct managed_win *w attr_unused) {
|
2019-03-10 08:34:37 -04:00
|
|
|
}
|
2018-09-29 17:47:12 -04:00
|
|
|
#endif
|
2013-12-10 09:06:02 -05:00
|
|
|
|
2013-01-09 07:25:01 -05:00
|
|
|
/**
|
|
|
|
* Dump an drawable's info.
|
|
|
|
*/
|
2019-03-10 08:34:37 -04:00
|
|
|
static inline void dump_drawable(session_t *ps, xcb_drawable_t drawable) {
|
|
|
|
auto r = xcb_get_geometry_reply(ps->c, xcb_get_geometry(ps->c, drawable), NULL);
|
|
|
|
if (!r) {
|
|
|
|
log_trace("Drawable %#010x: Failed", drawable);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log_trace("Drawable %#010x: x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u",
|
|
|
|
drawable, r->x, r->y, r->width, r->height, r->border_width, r->depth);
|
|
|
|
free(r);
|
2012-10-30 20:54:09 -04:00
|
|
|
}
|