2018-10-04 05:14:51 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// Copyright (c) 2011-2013, Christopher Jeffrey
|
|
|
|
// Copyright (c) 2013 Richard Grenville <pyxlcy@gmail.com>
|
2018-10-21 10:10:12 +08:00
|
|
|
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <xcb/damage.h>
|
2019-03-10 20:34:37 +08:00
|
|
|
#include <xcb/render.h>
|
|
|
|
#include <xcb/xcb.h>
|
2018-10-21 10:10:12 +08:00
|
|
|
|
|
|
|
// FIXME shouldn't need this
|
|
|
|
#ifdef CONFIG_OPENGL
|
2019-01-21 05:15:20 +08:00
|
|
|
#include <GL/gl.h>
|
2018-10-21 10:10:12 +08:00
|
|
|
#endif
|
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-30 11:56:00 +08:00
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
#include "c2.h"
|
2019-01-19 07:30:44 +08:00
|
|
|
#include "compiler.h"
|
|
|
|
#include "region.h"
|
2018-12-16 05:11:41 +08:00
|
|
|
#include "render.h"
|
2019-03-10 20:34:37 +08:00
|
|
|
#include "types.h"
|
2019-01-21 00:53:39 +08:00
|
|
|
#include "utils.h"
|
2019-03-10 20:34:37 +08:00
|
|
|
#include "x.h"
|
2018-09-07 02:17:26 +08:00
|
|
|
|
|
|
|
typedef struct session session_t;
|
2018-10-21 10:10:12 +08:00
|
|
|
typedef struct _glx_texture glx_texture_t;
|
|
|
|
|
2018-10-29 07:09:25 +08:00
|
|
|
#ifdef CONFIG_OPENGL
|
2018-10-21 10:10:12 +08:00
|
|
|
// FIXME this type should be in opengl.h
|
|
|
|
// it is very unideal for it to be here
|
|
|
|
typedef struct {
|
2019-03-10 20:34:37 +08:00
|
|
|
/// Framebuffer used for blurring.
|
|
|
|
GLuint fbo;
|
|
|
|
/// Textures used for blurring.
|
|
|
|
GLuint textures[2];
|
|
|
|
/// Width of the textures.
|
|
|
|
int width;
|
|
|
|
/// Height of the textures.
|
|
|
|
int height;
|
2018-10-21 10:10:12 +08:00
|
|
|
} glx_blur_cache_t;
|
2018-10-29 07:09:25 +08:00
|
|
|
#endif
|
2018-10-21 10:10:12 +08:00
|
|
|
|
|
|
|
typedef enum {
|
2019-03-10 20:34:37 +08:00
|
|
|
WINTYPE_UNKNOWN,
|
|
|
|
WINTYPE_DESKTOP,
|
|
|
|
WINTYPE_DOCK,
|
|
|
|
WINTYPE_TOOLBAR,
|
|
|
|
WINTYPE_MENU,
|
|
|
|
WINTYPE_UTILITY,
|
|
|
|
WINTYPE_SPLASH,
|
|
|
|
WINTYPE_DIALOG,
|
|
|
|
WINTYPE_NORMAL,
|
|
|
|
WINTYPE_DROPDOWN_MENU,
|
|
|
|
WINTYPE_POPUP_MENU,
|
|
|
|
WINTYPE_TOOLTIP,
|
|
|
|
WINTYPE_NOTIFY,
|
|
|
|
WINTYPE_COMBO,
|
|
|
|
WINTYPE_DND,
|
|
|
|
NUM_WINTYPES
|
2018-10-21 10:10:12 +08:00
|
|
|
} wintype_t;
|
|
|
|
|
|
|
|
/// Enumeration type of window painting mode.
|
|
|
|
typedef enum {
|
2019-03-10 20:34:37 +08:00
|
|
|
WMODE_TRANS, // The window body is (potentially) transparent
|
|
|
|
WMODE_FRAME_TRANS, // The window body is opaque, but the frame is not
|
|
|
|
WMODE_SOLID, // The window is opaque including the frame
|
2018-10-21 10:10:12 +08:00
|
|
|
} winmode_t;
|
|
|
|
|
2019-02-09 23:50:40 +08:00
|
|
|
/// Transition table:
|
|
|
|
/// (DESTROYED is when the win struct is destroyed and freed)
|
|
|
|
/// ('o' means in all other cases)
|
|
|
|
/// (Window is created in the UNMAPPED state)
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | |UNMAPPING|DESTROYING|MAPPING|FADING |UNMAPPED| MAPPED |DESTROYED|
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | UNMAPPING | o | Window |Window | - | Fading | - | - |
|
|
|
|
/// | | |destroyed |mapped | |finished| | |
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | DESTROYING | - | o | - | - | - | - | Fading |
|
|
|
|
/// | | | | | | | |finished |
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | MAPPING | Window | Window | o | - | - | Fading | - |
|
|
|
|
/// | |unmapped |destroyed | | | |finished| |
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | FADING | Window | Window | - | o | - | Fading | - |
|
|
|
|
/// | |unmapped |destroyed | | | |finished| |
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | UNMAPPED | - | - |Window | - | o | - | Window |
|
|
|
|
/// | | | |mapped | | | |destroyed|
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
/// | MAPPED | Window | Window | - |Opacity| - | o | - |
|
|
|
|
/// | |unmapped |destroyed | |change | | | |
|
|
|
|
/// +-------------+---------+----------+-------+-------+--------+--------+---------+
|
|
|
|
typedef enum {
|
2019-03-10 20:34:37 +08:00
|
|
|
// The window is being faded out because it's unmapped.
|
|
|
|
WSTATE_UNMAPPING,
|
|
|
|
// The window is being faded out because it's destroyed,
|
|
|
|
WSTATE_DESTROYING,
|
|
|
|
// The window is being faded in
|
|
|
|
WSTATE_MAPPING,
|
|
|
|
// Window opacity is not at the target level
|
|
|
|
WSTATE_FADING,
|
|
|
|
// The window is mapped, no fading is in progress.
|
|
|
|
WSTATE_MAPPED,
|
|
|
|
// The window is unmapped, no fading is in progress.
|
|
|
|
WSTATE_UNMAPPED,
|
2019-02-09 23:50:40 +08:00
|
|
|
} winstate_t;
|
|
|
|
|
2018-10-21 10:10:12 +08:00
|
|
|
/**
|
|
|
|
* About coordinate systems
|
|
|
|
*
|
|
|
|
* In general, X is the horizontal axis, Y is the vertical axis.
|
|
|
|
* X goes from left to right, Y goes downwards.
|
|
|
|
*
|
|
|
|
* Global: the origin is the top left corner of the Xorg screen.
|
2019-03-05 05:37:22 +08:00
|
|
|
* Local: the origin is the top left corner of the window, border is
|
|
|
|
* considered part of the window.
|
2018-10-21 10:10:12 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/// Structure representing a top-level window compton manages.
|
2018-09-07 02:17:26 +08:00
|
|
|
typedef struct win win;
|
2018-10-21 10:10:12 +08:00
|
|
|
struct win {
|
2019-03-10 20:34:37 +08:00
|
|
|
/// backend data attached to this window. Only available when
|
|
|
|
/// `state` is not UNMAPPED
|
|
|
|
void *win_image;
|
|
|
|
void *shadow_image;
|
|
|
|
/// Pointer to the next lower window in window stack.
|
|
|
|
win *next;
|
|
|
|
/// Pointer to the next higher window to paint.
|
|
|
|
win *prev_trans;
|
|
|
|
// TODO rethink reg_ignore
|
|
|
|
|
|
|
|
// Core members
|
|
|
|
/// ID of the top-level frame window.
|
|
|
|
xcb_window_t id;
|
|
|
|
/// The "mapped state" of this window, doesn't necessary
|
|
|
|
/// match X mapped state, because of fading.
|
|
|
|
winstate_t state;
|
|
|
|
/// Window attributes.
|
|
|
|
xcb_get_window_attributes_reply_t a;
|
|
|
|
xcb_get_geometry_reply_t g;
|
|
|
|
/// Xinerama screen this window is on.
|
|
|
|
int xinerama_scr;
|
|
|
|
/// Window visual pict format;
|
|
|
|
const xcb_render_pictforminfo_t *pictfmt;
|
|
|
|
/// Window painting mode.
|
|
|
|
winmode_t mode;
|
|
|
|
/// Whether the window has been damaged at least once.
|
|
|
|
bool ever_damaged;
|
|
|
|
/// Whether the window was damaged after last paint.
|
|
|
|
bool pixmap_damaged;
|
|
|
|
/// Damage of the window.
|
|
|
|
xcb_damage_damage_t damage;
|
|
|
|
/// Paint info of the window.
|
|
|
|
paint_t paint;
|
|
|
|
|
|
|
|
/// Bounding shape of the window. In local coordinates.
|
|
|
|
/// See above about coordinate systems.
|
|
|
|
region_t bounding_shape;
|
|
|
|
/// Window flags. Definitions above.
|
|
|
|
int_fast16_t flags;
|
|
|
|
/// Whether there's a pending <code>ConfigureNotify</code> happening
|
|
|
|
/// when the window is unmapped.
|
|
|
|
bool need_configure;
|
|
|
|
/// Queued <code>ConfigureNotify</code> when the window is unmapped.
|
|
|
|
xcb_configure_notify_event_t queue_configure;
|
|
|
|
/// The region of screen that will be obscured when windows above is painted,
|
|
|
|
/// in global coordinates.
|
|
|
|
/// We use this to reduce the pixels that needed to be paint when painting
|
|
|
|
/// this window and anything underneath. Depends on window frame
|
|
|
|
/// opacity state, window geometry, window mapped/unmapped state,
|
|
|
|
/// window mode of the windows above. DOES NOT INCLUDE the body of THIS WINDOW.
|
|
|
|
/// NULL means reg_ignore has not been calculated for this window.
|
|
|
|
rc_region_t *reg_ignore;
|
|
|
|
/// Whether the reg_ignore of all windows beneath this window are valid
|
|
|
|
bool reg_ignore_valid;
|
|
|
|
/// Cached width/height of the window including border.
|
|
|
|
int widthb, heightb;
|
|
|
|
/// Whether the window is bounding-shaped.
|
|
|
|
bool bounding_shaped;
|
|
|
|
/// Whether the window just have rounded corners.
|
|
|
|
bool rounded_corners;
|
|
|
|
/// Whether this window is to be painted.
|
|
|
|
bool to_paint;
|
|
|
|
/// Whether the window is painting excluded.
|
|
|
|
bool paint_excluded;
|
|
|
|
/// Whether the window is unredirect-if-possible excluded.
|
|
|
|
bool unredir_if_possible_excluded;
|
|
|
|
/// Whether this window is in open/close state.
|
|
|
|
bool in_openclose;
|
|
|
|
|
|
|
|
// Client window related members
|
|
|
|
/// ID of the top-level client window of the window.
|
|
|
|
xcb_window_t client_win;
|
|
|
|
/// Type of the window.
|
|
|
|
wintype_t window_type;
|
|
|
|
/// Whether it looks like a WM window. We consider a window WM window if
|
|
|
|
/// it does not have a decedent with WM_STATE and it is not override-
|
|
|
|
/// redirected itself.
|
|
|
|
bool wmwin;
|
|
|
|
/// Leader window ID of the window.
|
|
|
|
xcb_window_t leader;
|
|
|
|
/// Cached topmost window ID of the window.
|
|
|
|
xcb_window_t cache_leader;
|
|
|
|
|
|
|
|
// Focus-related members
|
|
|
|
/// Whether the window is to be considered focused.
|
|
|
|
bool focused;
|
|
|
|
/// Override value of window focus state. Set by D-Bus method calls.
|
|
|
|
switch_t focused_force;
|
|
|
|
|
|
|
|
// Blacklist related members
|
|
|
|
/// Name of the window.
|
|
|
|
char *name;
|
|
|
|
/// Window instance class of the window.
|
|
|
|
char *class_instance;
|
|
|
|
/// Window general class of the window.
|
|
|
|
char *class_general;
|
|
|
|
/// <code>WM_WINDOW_ROLE</code> value of the window.
|
|
|
|
char *role;
|
|
|
|
|
|
|
|
// Opacity-related members
|
|
|
|
/// Current window opacity.
|
|
|
|
double opacity;
|
|
|
|
/// Target window opacity.
|
|
|
|
double opacity_tgt;
|
|
|
|
/// true if window (or client window, for broken window managers
|
|
|
|
/// not transferring client window's _NET_WM_OPACITY value) has opacity prop
|
|
|
|
bool has_opacity_prop;
|
|
|
|
/// Cached value of opacity window attribute.
|
|
|
|
opacity_t opacity_prop;
|
|
|
|
/// true if opacity is set by some rules
|
|
|
|
bool opacity_is_set;
|
|
|
|
/// Last window opacity value we set.
|
|
|
|
double opacity_set;
|
|
|
|
|
|
|
|
// Fading-related members
|
|
|
|
/// Override value of window fade state. Set by D-Bus method calls.
|
|
|
|
switch_t fade_force;
|
|
|
|
|
|
|
|
// Frame-opacity-related members
|
|
|
|
/// Current window frame opacity. Affected by window opacity.
|
|
|
|
double frame_opacity;
|
|
|
|
/// Frame extents. Acquired from _NET_FRAME_EXTENTS.
|
|
|
|
margin_t frame_extents;
|
|
|
|
|
|
|
|
// Shadow-related members
|
|
|
|
/// Whether a window has shadow. Calculated.
|
|
|
|
bool shadow;
|
|
|
|
/// Override value of window shadow state. Set by D-Bus method calls.
|
|
|
|
switch_t shadow_force;
|
|
|
|
/// Opacity of the shadow. Affected by window opacity and frame opacity.
|
|
|
|
double shadow_opacity;
|
|
|
|
/// X offset of shadow. Affected by commandline argument.
|
|
|
|
int shadow_dx;
|
|
|
|
/// Y offset of shadow. Affected by commandline argument.
|
|
|
|
int shadow_dy;
|
|
|
|
/// Width of shadow. Affected by window size and commandline argument.
|
|
|
|
int shadow_width;
|
|
|
|
/// Height of shadow. Affected by window size and commandline argument.
|
|
|
|
int shadow_height;
|
|
|
|
/// Picture to render shadow. Affected by window size.
|
|
|
|
paint_t shadow_paint;
|
|
|
|
/// The value of _COMPTON_SHADOW attribute of the window. Below 0 for
|
|
|
|
/// none.
|
|
|
|
long prop_shadow;
|
|
|
|
|
|
|
|
// Dim-related members
|
|
|
|
/// Whether the window is to be dimmed.
|
|
|
|
bool dim;
|
|
|
|
|
|
|
|
/// Whether to invert window color.
|
|
|
|
bool invert_color;
|
|
|
|
/// Override value of window color inversion state. Set by D-Bus method
|
|
|
|
/// calls.
|
|
|
|
switch_t invert_color_force;
|
|
|
|
|
|
|
|
/// Whether to blur window background.
|
|
|
|
bool blur_background;
|
2018-10-21 10:10:12 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_OPENGL
|
2019-03-10 20:34:37 +08:00
|
|
|
/// Textures and FBO background blur use.
|
|
|
|
glx_blur_cache_t glx_blur_cache;
|
2018-10-21 10:10:12 +08:00
|
|
|
#endif
|
|
|
|
};
|
2018-09-07 02:17:26 +08:00
|
|
|
|
|
|
|
int win_get_name(session_t *ps, win *w);
|
|
|
|
int win_get_role(session_t *ps, win *w);
|
2019-02-21 22:08:08 +08:00
|
|
|
winmode_t attr_pure win_calc_mode(const win *w);
|
2018-09-07 02:17:26 +08:00
|
|
|
/**
|
|
|
|
* Set real focused state of a window.
|
|
|
|
*/
|
|
|
|
void win_set_focused(session_t *ps, win *w, bool focused);
|
2019-02-21 22:08:08 +08:00
|
|
|
bool attr_pure win_should_fade(session_t *ps, const win *w);
|
2018-09-07 02:17:26 +08:00
|
|
|
void win_update_prop_shadow_raw(session_t *ps, win *w);
|
|
|
|
void win_update_prop_shadow(session_t *ps, win *w);
|
|
|
|
void win_set_shadow(session_t *ps, win *w, bool shadow_new);
|
|
|
|
void win_determine_shadow(session_t *ps, win *w);
|
|
|
|
void win_set_invert_color(session_t *ps, win *w, bool invert_color_new);
|
|
|
|
void win_determine_invert_color(session_t *ps, win *w);
|
|
|
|
void win_set_blur_background(session_t *ps, win *w, bool blur_background_new);
|
|
|
|
void win_determine_blur_background(session_t *ps, win *w);
|
|
|
|
void win_on_wtype_change(session_t *ps, win *w);
|
|
|
|
void win_on_factor_change(session_t *ps, win *w);
|
2019-02-21 22:08:08 +08:00
|
|
|
/**
|
|
|
|
* Update cache data in struct _win that depends on window size.
|
|
|
|
*/
|
|
|
|
void win_on_win_size_change(session_t *ps, win *w);
|
|
|
|
void win_update_wintype(session_t *ps, win *w);
|
2018-12-28 04:45:38 +08:00
|
|
|
void win_mark_client(session_t *ps, win *w, xcb_window_t client);
|
2018-09-07 02:17:26 +08:00
|
|
|
void win_unmark_client(session_t *ps, win *w);
|
|
|
|
void win_recheck_client(session_t *ps, win *w);
|
2018-12-28 04:45:38 +08:00
|
|
|
xcb_window_t win_get_leader_raw(session_t *ps, win *w, int recursions);
|
2018-09-07 02:17:26 +08:00
|
|
|
bool win_get_class(session_t *ps, win *w);
|
2019-02-21 22:08:08 +08:00
|
|
|
double attr_pure win_calc_opacity_target(session_t *ps, const win *w);
|
|
|
|
bool attr_pure win_should_dim(session_t *ps, const win *w);
|
2019-02-09 23:50:40 +08:00
|
|
|
void win_update_screen(session_t *, win *);
|
|
|
|
/// Prepare window for fading because opacity target changed
|
|
|
|
void win_start_fade(session_t *, win **);
|
2018-09-07 02:17:26 +08:00
|
|
|
/**
|
|
|
|
* Reread opacity property of a window.
|
|
|
|
*/
|
|
|
|
void win_update_opacity_prop(session_t *ps, win *w);
|
|
|
|
/**
|
|
|
|
* Update leader of a window.
|
|
|
|
*/
|
|
|
|
void win_update_leader(session_t *ps, win *w);
|
|
|
|
/**
|
|
|
|
* Update focused state of a window.
|
|
|
|
*/
|
|
|
|
void win_update_focused(session_t *ps, win *w);
|
|
|
|
/**
|
|
|
|
* Retrieve the bounding shape of a window.
|
|
|
|
*/
|
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-30 11:56:00 +08:00
|
|
|
// XXX was win_border_size
|
|
|
|
void win_update_bounding_shape(session_t *ps, win *w);
|
2018-09-07 02:17:26 +08:00
|
|
|
/**
|
2018-12-22 08:33:40 +08:00
|
|
|
* Get a rectangular region in global coordinates a window (and possibly
|
|
|
|
* its shadow) occupies.
|
2018-09-07 02:17:26 +08:00
|
|
|
*
|
|
|
|
* Note w->shadow and shadow geometry must be correct before calling this
|
|
|
|
* function.
|
|
|
|
*/
|
2019-02-21 22:08:08 +08:00
|
|
|
void win_extents(const win *w, region_t *res);
|
|
|
|
region_t win_extents_by_val(const win *w);
|
2018-09-07 02:17:26 +08:00
|
|
|
/**
|
|
|
|
* Add a window to damaged area.
|
|
|
|
*
|
|
|
|
* @param ps current session
|
|
|
|
* @param w struct _win element representing the window
|
|
|
|
*/
|
|
|
|
void add_damage_from_win(session_t *ps, win *w);
|
|
|
|
/**
|
|
|
|
* Get a rectangular region a window occupies, excluding frame and shadow.
|
2018-10-13 08:17:59 +08:00
|
|
|
*
|
|
|
|
* Return region in global coordinates.
|
2018-09-07 02:17:26 +08:00
|
|
|
*/
|
2019-02-21 22:08:08 +08:00
|
|
|
void win_get_region_noframe_local(const win *w, region_t *);
|
|
|
|
region_t win_get_region_noframe_local_by_val(const win *w);
|
2019-03-05 05:37:22 +08:00
|
|
|
|
|
|
|
/// Get the region for the frame of the window
|
|
|
|
void win_get_region_frame_local(const win *w, region_t *res);
|
|
|
|
/// Get the region for the frame of the window, by value
|
|
|
|
region_t win_get_region_frame_local_by_val(const win *w);
|
2018-09-07 02:17:26 +08:00
|
|
|
/**
|
|
|
|
* Retrieve frame extents from a window.
|
|
|
|
*/
|
2019-03-10 20:34:37 +08:00
|
|
|
void win_update_frame_extents(session_t *ps, win *w, xcb_window_t client);
|
2019-02-20 08:17:23 +08:00
|
|
|
void add_win(session_t *ps, xcb_window_t id, xcb_window_t prev);
|
2019-02-09 23:50:40 +08:00
|
|
|
/// Unmap or destroy a window
|
|
|
|
void unmap_win(session_t *ps, win **, bool destroy);
|
2018-12-16 05:11:41 +08:00
|
|
|
|
2019-02-21 10:29:06 +08:00
|
|
|
void map_win(session_t *ps, win *w);
|
|
|
|
void map_win_by_id(session_t *ps, xcb_window_t id);
|
|
|
|
|
2018-12-16 05:11:41 +08:00
|
|
|
/**
|
|
|
|
* Execute fade callback of a window if fading finished.
|
|
|
|
*/
|
2019-03-10 20:34:37 +08:00
|
|
|
void win_check_fade_finished(session_t *ps, win **_w);
|
2018-12-16 05:11:41 +08:00
|
|
|
|
2018-11-04 06:38:18 +08:00
|
|
|
// Stop receiving events (except ConfigureNotify, XXX why?) from a window
|
2019-02-21 22:08:08 +08:00
|
|
|
void win_ev_stop(session_t *ps, const win *w);
|
2018-11-04 06:38:18 +08:00
|
|
|
|
2019-02-21 10:12:07 +08:00
|
|
|
/// Skip the current in progress fading of window,
|
|
|
|
/// transition the window straight to its end state
|
|
|
|
void win_skip_fading(session_t *ps, win **_w);
|
|
|
|
|
2018-09-07 02:17:26 +08:00
|
|
|
/**
|
|
|
|
* Get the leader of a window.
|
|
|
|
*
|
|
|
|
* This function updates w->cache_leader if necessary.
|
|
|
|
*/
|
2019-03-10 20:34:37 +08:00
|
|
|
static inline xcb_window_t win_get_leader(session_t *ps, win *w) {
|
|
|
|
return win_get_leader_raw(ps, w, 0);
|
2018-09-07 02:17:26 +08:00
|
|
|
}
|
2018-09-30 02:07:39 +08:00
|
|
|
|
|
|
|
/// check if window has ARGB visual
|
2019-02-21 22:08:08 +08:00
|
|
|
bool attr_pure win_has_alpha(const win *w);
|
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-30 11:56:00 +08:00
|
|
|
|
|
|
|
/// check if reg_ignore_valid is true for all windows above us
|
2019-02-21 22:08:08 +08:00
|
|
|
bool attr_pure win_is_region_ignore_valid(session_t *ps, const win *w);
|
2018-10-13 08:17:59 +08:00
|
|
|
|
2019-02-09 23:50:40 +08:00
|
|
|
/// Free all resources in a struct win
|
|
|
|
void free_win_res(session_t *ps, win *w);
|
|
|
|
|
2019-03-10 20:34:37 +08:00
|
|
|
static inline region_t win_get_bounding_shape_global_by_val(win *w) {
|
|
|
|
region_t ret;
|
|
|
|
pixman_region32_init(&ret);
|
|
|
|
pixman_region32_copy(&ret, &w->bounding_shape);
|
|
|
|
pixman_region32_translate(&ret, w->g.x, w->g.y);
|
|
|
|
return ret;
|
2018-10-13 08:17:59 +08:00
|
|
|
}
|
2018-10-21 10:10:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the extents of the frame of the given window based on EWMH
|
|
|
|
* _NET_FRAME_EXTENTS and the X window border width.
|
|
|
|
*/
|
2019-03-10 20:34:37 +08:00
|
|
|
static inline margin_t attr_pure win_calc_frame_extents(const win *w) {
|
|
|
|
margin_t result = w->frame_extents;
|
|
|
|
result.top = max_i(result.top, w->g.border_width);
|
|
|
|
result.left = max_i(result.left, w->g.border_width);
|
|
|
|
result.bottom = max_i(result.bottom, w->g.border_width);
|
|
|
|
result.right = max_i(result.right, w->g.border_width);
|
|
|
|
return result;
|
2018-10-21 10:10:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether a window has WM frames.
|
|
|
|
*/
|
2019-03-10 20:34:37 +08:00
|
|
|
static inline bool attr_pure win_has_frame(const win *w) {
|
|
|
|
return w->g.border_width || w->frame_extents.top || w->frame_extents.left ||
|
|
|
|
w->frame_extents.right || w->frame_extents.bottom;
|
2018-10-21 10:10:12 +08:00
|
|
|
}
|