From f5bebb3e2e331327cbc82ba5aa21f111f39d8093 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Thu, 23 May 2024 14:30:55 +0100 Subject: [PATCH] plugin: add picom API headers And add a pkgconfig file so they can be found. Signed-off-by: Yuxuan Shui --- include/meson.build | 3 + include/picom/api.h | 14 + include/picom/backend.h | 485 +++++++++++++++++++++++++++++++++ include/picom/meson.build | 8 + {src => include/picom}/types.h | 11 +- meson.build | 9 + src/api.c | 24 ++ src/backend/backend.c | 11 +- src/backend/backend.h | 459 +------------------------------ src/backend/dummy/dummy.c | 3 +- src/backend/gl/gl_common.c | 4 +- src/backend/xrender/xrender.c | 3 +- src/c2.c | 1 + src/common.h | 9 +- src/config.c | 2 +- src/config.h | 11 +- src/config_libconfig.c | 1 + src/dbus.c | 6 +- src/diagnostic.c | 1 + src/event.c | 3 +- src/log.h | 1 + src/meson.build | 4 +- src/options.h | 4 +- src/picom.c | 7 +- src/picom.h | 8 +- src/region.h | 4 +- src/render.c | 5 +- src/renderer/command_builder.h | 6 +- src/renderer/damage.h | 2 +- src/renderer/layout.c | 3 +- src/renderer/layout.h | 5 +- src/renderer/renderer.h | 3 +- src/utils.h | 4 +- src/win.c | 7 +- src/win.h | 7 +- src/x.h | 15 - 36 files changed, 611 insertions(+), 542 deletions(-) create mode 100644 include/meson.build create mode 100644 include/picom/api.h create mode 100644 include/picom/backend.h create mode 100644 include/picom/meson.build rename {src => include/picom}/types.h (94%) create mode 100644 src/api.c diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 00000000..419437e7 --- /dev/null +++ b/include/meson.build @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) Yuxuan Shui +subdirs('picom') diff --git a/include/picom/api.h b/include/picom/api.h new file mode 100644 index 00000000..70e4a006 --- /dev/null +++ b/include/picom/api.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright (c) Yuxuan Shui + +#pragma once + +#include + +#define PICOM_API_MAJOR (0UL) +#define PICOM_API_MINOR (1UL) + +struct picom_api {}; + +const struct picom_api * +picom_api_get_interfaces(uint64_t major, uint64_t minor, const char *context); diff --git a/include/picom/backend.h b/include/picom/backend.h new file mode 100644 index 00000000..92c975c0 --- /dev/null +++ b/include/picom/backend.h @@ -0,0 +1,485 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright (c) Yuxuan Shui + +#pragma once + +#include +#include +#include + +#include "types.h" + +#define PICOM_BACKEND_MAJOR (1UL) +#define PICOM_BACKEND_MINOR (0UL) +#define PICOM_BACKEND_MAKE_VERSION(major, minor) ((major) * 1000 + (minor)) + +typedef pixman_region32_t region_t; + +struct xvisual_info { + /// Bit depth of the red component + int red_size; + /// Bit depth of the green component + int green_size; + /// Bit depth of the blue component + int blue_size; + /// Bit depth of the alpha component + int alpha_size; + /// The depth of X visual + int visual_depth; + + xcb_visualid_t visual; +}; + +typedef struct session session_t; +struct managed_win; + +struct ev_loop; +struct backend_operations; + +typedef struct backend_base { + struct backend_operations *ops; + struct x_connection *c; + struct ev_loop *loop; + + /// Whether the backend can accept new render request at the moment + bool busy; + // ... +} backend_t; + +// This mimics OpenGL's ARB_robustness extension, which enables detection of GPU context +// resets. +// See: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_robustness.txt, section +// 2.6 "Graphics Reset Recovery". +enum device_status { + DEVICE_STATUS_NORMAL, + DEVICE_STATUS_RESETTING, +}; + +enum shader_attributes { + // Whether the shader needs to be render regardless of whether the window is + // updated. + SHADER_ATTRIBUTE_ANIMATED = 1, +}; + +struct gaussian_blur_args { + int size; + double deviation; +}; + +struct box_blur_args { + int size; +}; + +struct kernel_blur_args { + struct conv **kernels; + int kernel_count; +}; + +struct dual_kawase_blur_args { + int size; + int strength; +}; + +typedef struct image_handle { + // Intentionally left blank +} *image_handle; + +/// A mask for various backend operations. +/// +/// The mask is composed of both a mask region and a mask image. The resulting mask +/// is the intersection of the two. The mask image can be modified by the `corner_radius` +/// and `inverted` properties. Note these properties have no effect on the mask region. +struct backend_mask_image { + /// Mask image, can be NULL. + /// + /// Mask image must be an image that was created with the + /// `BACKEND_IMAGE_FORMAT_MASK` format. Using an image with a wrong format as mask + /// is undefined behavior. + image_handle image; + /// Corner radius of the mask image, the corners of the mask image will be + /// rounded. + double corner_radius; + /// Origin of the mask image, in the source image's coordinate. + ivec2 origin; + /// Whether the mask image should be inverted. + bool inverted; +}; + +struct backend_blur_args { + /// The blur context + void *blur_context; + /// The source mask for the blur operation, may be NULL. Only parts of the source + /// image covered by the mask should participate in the blur operation. + const struct backend_mask_image *source_mask; + /// Region of the target image that will be covered by the blur operation, in the + /// source image's coordinate. + const region_t *target_mask; + /// Source image + image_handle source_image; + /// Opacity of the blurred image + double opacity; +}; + +struct backend_blit_args { + /// Source image, can be NULL. + image_handle source_image; + /// Mask for the source image. may be NULL. Only contents covered by the mask + /// should participate in the blit operation. This applies to the source image + /// before it's scaled. + const struct backend_mask_image *source_mask; + /// Mask for the target image. Only regions of the target image covered by this + /// mask should be modified. This is the target's coordinate system. + const region_t *target_mask; + /// Custom shader for this blit operation. + void *shader; + /// Opacity of the source image. + double opacity; + /// Dim level of the source image. + double dim; + /// Brightness limit of the source image. Source image + /// will be normalized so that the maximum brightness is + /// this value. + double max_brightness; + /// Scale factor for the horizontal and vertical direction (X for horizontal, + /// Y for vertical). + vec2 scale; + /// Corner radius of the source image BEFORE scaling. The corners of + /// the source image will be rounded. + double corner_radius; + /// Effective size of the source image BEFORE scaling, set where the corners + /// of the image are. + ivec2 effective_size; + /// Border width of the source image BEFORE scaling. This is used with + /// `corner_radius` to create a border for the rounded corners. + /// Setting this has no effect if `corner_radius` is 0. + int border_width; + /// Whether the source image should be inverted. + bool color_inverted; +}; + +enum backend_image_format { + /// A format that can be used for normal rendering, and binding + /// X pixmaps. + /// Images created with `bind_pixmap` have this format automatically. + BACKEND_IMAGE_FORMAT_PIXMAP, + /// Like `BACKEND_IMAGE_FORMAT_PIXMAP`, but the image has a higher + /// precision. Support is optional. + BACKEND_IMAGE_FORMAT_PIXMAP_HIGH, + /// A format that can be used for masks. + BACKEND_IMAGE_FORMAT_MASK, +}; + +enum backend_image_capability { + /// Image can be sampled from. This is required for `blit` and `blur` source + /// images. All images except the back buffer should have this capability. + /// Note that `copy_area` should work without this capability, this is so that + /// blurring the back buffer could be done. + BACKEND_IMAGE_CAP_SRC = 1 << 0, + /// Image can be rendered to. This is required for target images of any operation. + /// All images except bound X pixmaps should have this capability. + BACKEND_IMAGE_CAP_DST = 1 << 1, +}; + +enum backend_command_op { + BACKEND_COMMAND_INVALID = -1, + BACKEND_COMMAND_BLIT, + BACKEND_COMMAND_BLUR, + BACKEND_COMMAND_COPY_AREA, +}; + +/// Symbolic references used as render command source images. The actual `image_handle` +/// will later be filled in by the renderer using this symbolic reference. +enum backend_command_source { + BACKEND_COMMAND_SOURCE_WINDOW, + BACKEND_COMMAND_SOURCE_SHADOW, + BACKEND_COMMAND_SOURCE_BACKGROUND, +}; + +// TODO(yshui) might need better names + +struct backend_command { + enum backend_command_op op; + ivec2 origin; + enum backend_command_source source; + union { + struct { + struct backend_blit_args blit; + /// Region of the screen that will be covered by this blit + /// operations, in screen coordinates. + region_t opaque_region; + }; + struct { + image_handle source_image; + const region_t *region; + } copy_area; + struct backend_blur_args blur; + }; + /// Source mask for the operation. + /// If the `source_mask` of the operation's argument points to this, a mask image + /// will be created for the operation for the renderer. + struct backend_mask_image source_mask; + /// Target mask for the operation. + region_t target_mask; +}; + +enum backend_quirk { + /// Backend cannot do blur quickly. The compositor will avoid using blur to create + /// shadows on this backend + BACKEND_QUIRK_SLOW_BLUR = 1 << 0, +}; + +struct backend_operations { + // =========== Initialization =========== + + /// Initialize the backend, prepare for rendering to the target window. + backend_t *(*init)(session_t *, xcb_window_t) __attribute__((nonnull(1))); + void (*deinit)(backend_t *backend_data) __attribute__((nonnull(1))); + + /// Called when rendering will be stopped for an unknown amount of + /// time (e.g. when screen is unredirected). Free some resources. + /// + /// Optional, not yet used + void (*pause)(backend_t *backend_data, session_t *ps); + + /// Called before rendering is resumed + /// + /// Optional, not yet used + void (*resume)(backend_t *backend_data, session_t *ps); + + /// Called when root window size changed. All existing image data ever + /// returned by this backend should remain valid after this call + /// returns. + /// + /// Optional + void (*root_change)(backend_t *backend_data, session_t *ps); + + // =========== Rendering ============ + + /// Called before when a new frame starts. + /// + /// Optional + void (*prepare)(backend_t *backend_data, const region_t *reg_damage); + + /// Multiply the alpha channel of the target image by a given value. + /// + /// @param backend_data backend data + /// @param target an image handle, cannot be NULL. + /// @param alpha the alpha value to multiply + /// @param region the region to apply the alpha, in the target image's + /// coordinate. + bool (*apply_alpha)(struct backend_base *backend_data, image_handle target, + double alpha, const region_t *region) + __attribute__((nonnull(1, 2, 4))); + + /// Copy pixels from a source image on to the target image. + /// + /// Some effects may be applied. If the region specified by the mask + /// contains parts that are outside the source image, the source image + /// will be repeated to fit. + /// + /// Source and target MUST NOT be the same image. + /// + /// @param backend_data backend data + /// @param origin the origin of the operation, in the target image's + /// coordinate. + /// @param target an image handle, cannot be NULL. + /// @param args arguments for blit + /// @return whether the operation is successful + bool (*blit)(struct backend_base *backend_data, ivec2 origin, image_handle target, + const struct backend_blit_args *args) __attribute__((nonnull(1, 3, 4))); + + /// Blur a given region of a source image and store the result in the + /// target image. + /// + /// The blur operation might access pixels outside the mask region, the + /// amount of pixels accessed can be queried with `get_blur_size`. If + /// pixels outside the source image are accessed, the result will be + /// clamped to the edge of the source image. + /// + /// Source and target may be the same image. + /// + /// @param backend_data backend data + /// @param origin the origin of the operation, in the target image's + /// coordinate. + /// @param target an image handle, cannot be NULL. + /// @param args argument for blur + /// @return whether the operation is successful + bool (*blur)(struct backend_base *backend_data, ivec2 origin, image_handle target, + const struct backend_blur_args *args) __attribute__((nonnull(1, 3, 4))); + + /// Direct copy of pixels from a source image on to the target image. + /// This is a simpler version of `blit`, without any effects. Note unlike `blit`, + /// if `region` tries to sample from outside the source image, instead of + /// repeating, the result will be clamped to the edge of the source image. + /// Blending should not be applied for the copy. + /// + /// Source and target MUST NOT be the same image. + /// + /// @param backend_data backend data + /// @param origin the origin of the operation, in the target image's + /// coordinate. + /// @param target an image handle, cannot be NULL. + /// @param source an image handle, cannot be NULL. + /// @param region the region to copy, in the target image's coordinate. + /// @return whether the operation is successful + bool (*copy_area)(struct backend_base *backend_data, ivec2 origin, + image_handle target, image_handle source, const region_t *region) + __attribute__((nonnull(1, 3, 4, 5))); + + /// Similar to `copy_area`, but is specialized for copying from a higher + /// precision format to a lower precision format. It has 2 major differences from + /// `copy_area`: + /// + /// 1. This function _may_ use dithering when copying from a higher precision + /// format to a lower precision format. But this is not required. + /// 2. This function only needs to support copying from an image with the SRC + /// capability. Unlike `copy_area`, which supports copying from any image. + /// + /// It's perfectly legal to have this pointing to the same function as + /// `copy_area`, if the backend doesn't support dithering. + /// + /// @param backend_data backend data + /// @param origin the origin of the operation, in the target image's + /// coordinate. + /// @param target an image handle, cannot be NULL. + /// @param source an image handle, cannot be NULL. + /// @param region the region to copy, in the target image's coordinate. + /// @return whether the operation is successful + bool (*copy_area_quantize)(struct backend_base *backend_data, ivec2 origin, + image_handle target, image_handle source, + const region_t *region) + __attribute__((nonnull(1, 3, 4, 5))); + + /// Initialize an image with a given color value. If the image has a mask format, + /// only the alpha channel of the color is used. + /// + /// @param backend_data backend data + /// @param target an image handle, cannot be NULL. + /// @param color the color to fill the image with + /// @return whether the operation is successful + bool (*clear)(struct backend_base *backend_data, image_handle target, + struct color color) __attribute__((nonnull(1, 2))); + + /// Present the back buffer to the target window. Ideally the backend should keep + /// track of the region of the back buffer that has been updated, and use relevant + /// mechanism (when possible) to present only the updated region. + bool (*present)(struct backend_base *backend_data) __attribute__((nonnull(1))); + + // ============ Resource management =========== + + /// Create a shader object from a shader source. + /// + /// Optional + void *(*create_shader)(backend_t *backend_data, const char *source) + __attribute__((nonnull(1, 2))); + + /// Free a shader object. + /// + /// Required if create_shader is present. + void (*destroy_shader)(backend_t *backend_data, void *shader) + __attribute__((nonnull(1, 2))); + + /// Create a new, uninitialized image with the given format and size. + /// + /// @param backend_data backend data + /// @param format the format of the image + /// @param size the size of the image + image_handle (*new_image)(struct backend_base *backend_data, + enum backend_image_format format, ivec2 size) + __attribute__((nonnull(1))); + + /// Bind a X pixmap to the backend's internal image data structure. + /// + /// @param backend_data backend data + /// @param pixmap X pixmap to bind + /// @param fmt information of the pixmap's visual + /// @return backend specific image handle for the pixmap. May be + /// NULL. + image_handle (*bind_pixmap)(struct backend_base *backend_data, xcb_pixmap_t pixmap, + struct xvisual_info fmt) __attribute__((nonnull(1))); + + /// Acquire the image handle of the back buffer. + /// + /// @param backend_data backend data + image_handle (*back_buffer)(struct backend_base *backend_data); + + /// Free resources associated with an image data structure. Releasing the image + /// returned by `back_buffer` should be a no-op. + /// + /// @param image the image to be released, cannot be NULL. + /// @return if this image is created by `bind_pixmap`, the X pixmap; 0 + /// otherwise. + xcb_pixmap_t (*release_image)(struct backend_base *backend_data, image_handle image) + __attribute__((nonnull(1, 2))); + + // =========== Query =========== + + /// Get backend quirks + /// @return a bitmask of `enum backend_quirk`. + uint32_t (*quirks)(struct backend_base *backend_data) __attribute__((nonnull(1))); + + /// Check if an optional image format is supported by the backend. + bool (*is_format_supported)(struct backend_base *backend_data, + enum backend_image_format format) + __attribute__((nonnull(1))); + + /// Return the capabilities of an image. + uint32_t (*image_capabilities)(struct backend_base *backend_data, image_handle image) + __attribute__((nonnull(1, 2))); + + /// Get the attributes of a shader. + /// + /// Optional, Returns a bitmask of attributes, see `shader_attributes`. + uint64_t (*get_shader_attributes)(backend_t *backend_data, void *shader) + __attribute__((nonnull(1, 2))); + + /// Get the age of the buffer content we are currently rendering on top + /// of. The buffer that has just been `present`ed has a buffer age of 1. + /// Every time `present` is called, buffers get older. Return -1 if the + /// buffer is empty. + /// + /// Optional + int (*buffer_age)(backend_t *backend_data); + + /// Get the render time of the last frame. If the render is still in progress, + /// returns false. The time is returned in `ts`. Frames are delimited by the + /// present() calls. i.e. after a present() call, last_render_time() should start + /// reporting the time of the just presented frame. + /// + /// Optional, if not available, the most conservative estimation will be used. + bool (*last_render_time)(backend_t *backend_data, struct timespec *ts); + + /// The maximum number buffer_age might return. + int max_buffer_age; + + // =========== Post-processing ============ + /// Create a blur context that can be used to call `blur` for images with a + /// specific format. + void *(*create_blur_context)(backend_t *base, enum blur_method, + enum backend_image_format format, void *args); + /// Destroy a blur context + void (*destroy_blur_context)(backend_t *base, void *ctx); + /// Get how many pixels outside of the blur area is needed for blur + void (*get_blur_size)(void *blur_context, int *width, int *height); + + // =========== Misc ============ + /// Return the driver that is been used by the backend + enum driver (*detect_driver)(backend_t *backend_data); + + void (*diagnostics)(backend_t *backend_data); + + enum device_status (*device_status)(backend_t *backend_data); +}; + +/// Register a new backend, `major` and `minor` should be the version of the picom backend +/// interface. You should just pass `PICOM_BACKEND_MAJOR` and `PICOM_BACKEND_MINOR` here. +/// `name` is the name of the backend, `init` is the function to initialize the backend, +/// `can_present` should be true if the backend can present the back buffer to the screen, +/// false otherwise (e.g. if the backend does off screen rendering, etc.) +bool backend_register(uint64_t major, uint64_t minor, const char *name, + struct backend_base *(*init)(session_t *ps, xcb_window_t target), + bool can_present); + +/// Define a backend entry point. (Note constructor priority 202 is used here because 1xx +/// is reversed by test.h, and 201 is used for logging initialization.) +#define BACKEND_ENTRYPOINT(func) static void __attribute__((constructor(202))) func(void) diff --git a/include/picom/meson.build b/include/picom/meson.build new file mode 100644 index 00000000..71727c41 --- /dev/null +++ b/include/picom/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) Yuxuan Shui + +api_headers = [ + 'api.h' + 'backend.h' +] +install_headers(api_headers, subdir: 'picom') diff --git a/src/types.h b/include/picom/types.h similarity index 94% rename from src/types.h rename to include/picom/types.h index 1566aa8e..8412fb16 100644 --- a/src/types.h +++ b/include/picom/types.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -// Copyright (c) 2018 Yuxuan Shui +// Copyright (c) Yuxuan Shui #pragma once @@ -10,6 +10,15 @@ #include #include +enum blur_method { + BLUR_METHOD_NONE = 0, + BLUR_METHOD_KERNEL, + BLUR_METHOD_BOX, + BLUR_METHOD_GAUSSIAN, + BLUR_METHOD_DUAL_KAWASE, + BLUR_METHOD_INVALID, +}; + /// Enumeration type to represent switches. typedef enum { OFF = 0, // false diff --git a/meson.build b/meson.build index 65c07802..408900e2 100644 --- a/meson.build +++ b/meson.build @@ -84,6 +84,15 @@ install_data('bin/picom-trans', install_dir: get_option('bindir')) install_data('picom.desktop', install_dir: 'share/applications') install_data('picom.desktop', install_dir: get_option('sysconfdir') / 'xdg' / 'autostart') +pkgconf = import('pkgconfig') + +picom_pc = pkgconf.generate( + name: 'picom-api', + description: 'picom API headers', + requires: [ 'pixman-1', 'xcb' ], + subdirs: 'picom', +) + if get_option('compton') install_data('compton.desktop', install_dir: 'share/applications') install_data('media/icons/48x48/compton.png', diff --git a/src/api.c b/src/api.c new file mode 100644 index 00000000..7005efef --- /dev/null +++ b/src/api.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright (c) Yuxuan Shui + +#include + +#include +#include + +#include "compiler.h" +#include "log.h" + +static struct picom_api picom_api; + +PICOM_PUBLIC_API const struct picom_api * +picom_api_get_interfaces(uint64_t major, uint64_t minor, const char *context) { + if (major != PICOM_API_MAJOR || minor > PICOM_API_MINOR) { + log_error("Cannot provide API interfaces to %s, because the requested" + "version %" PRIu64 ".%" PRIu64 " is incompatible with our " + "%lu.%lu", + context, major, minor, PICOM_API_MAJOR, PICOM_API_MINOR); + return NULL; + } + return &picom_api; +} diff --git a/src/backend/backend.c b/src/backend/backend.c index 059b6974..a584f803 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -4,13 +4,14 @@ #include #include +#include + #include "backend/backend.h" #include "common.h" #include "compiler.h" #include "config.h" #include "log.h" #include "region.h" -#include "types.h" #include "win.h" #include "x.h" @@ -21,10 +22,10 @@ static struct backend_info { bool can_present; } *backend_registry = NULL; -bool PICOM_PUBLIC_API backend_register(uint64_t major, uint64_t minor, const char *name, - struct backend_base *(*init)(session_t *ps, - xcb_window_t target), - bool can_present) { +PICOM_PUBLIC_API bool +backend_register(uint64_t major, uint64_t minor, const char *name, + struct backend_base *(*init)(session_t *ps, xcb_window_t target), + bool can_present) { if (major != PICOM_BACKEND_MAJOR) { log_error("Backend %s has incompatible major version %" PRIu64 ", expected %lu", diff --git a/src/backend/backend.h b/src/backend/backend.h index 307a9c85..32c037c9 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -5,468 +5,13 @@ #include -#include "compiler.h" -#include "config.h" -#include "driver.h" -#include "kernel.h" -#include "region.h" -#include "types.h" -#include "x.h" +#include -#define PICOM_BACKEND_MAJOR (1UL) -#define PICOM_BACKEND_MINOR (0UL) -#define PICOM_BACKEND_MAKE_VERSION(major, minor) ((major) * 1000 + (minor)) +#include "log.h" -typedef struct session session_t; -struct managed_win; - -struct ev_loop; -struct backend_operations; - -typedef struct backend_base { - struct backend_operations *ops; - struct x_connection *c; - struct ev_loop *loop; - - /// Whether the backend can accept new render request at the moment - bool busy; - // ... -} backend_t; - -typedef void (*backend_ready_callback_t)(void *); - -// This mimics OpenGL's ARB_robustness extension, which enables detection of GPU context -// resets. -// See: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_robustness.txt, section -// 2.6 "Graphics Reset Recovery". -enum device_status { - DEVICE_STATUS_NORMAL, - DEVICE_STATUS_RESETTING, -}; - -enum shader_attributes { - // Whether the shader needs to be render regardless of whether the window is - // updated. - SHADER_ATTRIBUTE_ANIMATED = 1, -}; - -struct gaussian_blur_args { - int size; - double deviation; -}; - -struct box_blur_args { - int size; -}; - -struct kernel_blur_args { - struct conv **kernels; - int kernel_count; -}; - -struct dual_kawase_blur_args { - int size; - int strength; -}; - -typedef struct image_handle { - // Intentionally left blank -} *image_handle; - -/// A mask for various backend operations. -/// -/// The mask is composed of both a mask region and a mask image. The resulting mask -/// is the intersection of the two. The mask image can be modified by the `corner_radius` -/// and `inverted` properties. Note these properties have no effect on the mask region. -struct backend_mask_image { - /// Mask image, can be NULL. - /// - /// Mask image must be an image that was created with the - /// `BACKEND_IMAGE_FORMAT_MASK` format. Using an image with a wrong format as mask - /// is undefined behavior. - image_handle image; - /// Corner radius of the mask image, the corners of the mask image will be - /// rounded. - double corner_radius; - /// Origin of the mask image, in the source image's coordinate. - ivec2 origin; - /// Whether the mask image should be inverted. - bool inverted; -}; - -struct backend_blur_args { - /// The blur context - void *blur_context; - /// The source mask for the blur operation, may be NULL. Only parts of the source - /// image covered by the mask should participate in the blur operation. - const struct backend_mask_image *source_mask; - /// Region of the target image that will be covered by the blur operation, in the - /// source image's coordinate. - const region_t *target_mask; - /// Source image - image_handle source_image; - /// Opacity of the blurred image - double opacity; -}; - -struct backend_blit_args { - /// Source image, can be NULL. - image_handle source_image; - /// Mask for the source image. may be NULL. Only contents covered by the mask - /// should participate in the blit operation. This applies to the source image - /// before it's scaled. - const struct backend_mask_image *source_mask; - /// Mask for the target image. Only regions of the target image covered by this - /// mask should be modified. This is the target's coordinate system. - const region_t *target_mask; - /// Custom shader for this blit operation. - void *shader; - /// Opacity of the source image. - double opacity; - /// Dim level of the source image. - double dim; - /// Brightness limit of the source image. Source image - /// will be normalized so that the maximum brightness is - /// this value. - double max_brightness; - /// Scale factor for the horizontal and vertical direction (X for horizontal, - /// Y for vertical). - vec2 scale; - /// Corner radius of the source image BEFORE scaling. The corners of - /// the source image will be rounded. - double corner_radius; - /// Effective size of the source image BEFORE scaling, set where the corners - /// of the image are. - ivec2 effective_size; - /// Border width of the source image BEFORE scaling. This is used with - /// `corner_radius` to create a border for the rounded corners. - /// Setting this has no effect if `corner_radius` is 0. - int border_width; - /// Whether the source image should be inverted. - bool color_inverted; -}; - -enum backend_image_format { - /// A format that can be used for normal rendering, and binding - /// X pixmaps. - /// Images created with `bind_pixmap` have this format automatically. - BACKEND_IMAGE_FORMAT_PIXMAP, - /// Like `BACKEND_IMAGE_FORMAT_PIXMAP`, but the image has a higher - /// precision. Support is optional. - BACKEND_IMAGE_FORMAT_PIXMAP_HIGH, - /// A format that can be used for masks. - BACKEND_IMAGE_FORMAT_MASK, -}; - -enum backend_image_capability { - /// Image can be sampled from. This is required for `blit` and `blur` source - /// images. All images except the back buffer should have this capability. - /// Note that `copy_area` should work without this capability, this is so that - /// blurring the back buffer could be done. - BACKEND_IMAGE_CAP_SRC = 1 << 0, - /// Image can be rendered to. This is required for target images of any operation. - /// All images except bound X pixmaps should have this capability. - BACKEND_IMAGE_CAP_DST = 1 << 1, -}; - -enum backend_command_op { - BACKEND_COMMAND_INVALID = -1, - BACKEND_COMMAND_BLIT, - BACKEND_COMMAND_BLUR, - BACKEND_COMMAND_COPY_AREA, -}; - -/// Symbolic references used as render command source images. The actual `image_handle` -/// will later be filled in by the renderer using this symbolic reference. -enum backend_command_source { - BACKEND_COMMAND_SOURCE_WINDOW, - BACKEND_COMMAND_SOURCE_SHADOW, - BACKEND_COMMAND_SOURCE_BACKGROUND, -}; - -// TODO(yshui) might need better names - -struct backend_command { - enum backend_command_op op; - ivec2 origin; - enum backend_command_source source; - union { - struct { - struct backend_blit_args blit; - /// Region of the screen that will be covered by this blit - /// operations, in screen coordinates. - region_t opaque_region; - }; - struct { - image_handle source_image; - const region_t *region; - } copy_area; - struct backend_blur_args blur; - }; - /// Source mask for the operation. - /// If the `source_mask` of the operation's argument points to this, a mask image - /// will be created for the operation for the renderer. - struct backend_mask_image source_mask; - /// Target mask for the operation. - region_t target_mask; -}; - -enum backend_quirk { - /// Backend cannot do blur quickly. The compositor will avoid using blur to create - /// shadows on this backend - BACKEND_QUIRK_SLOW_BLUR = 1 << 0, -}; - -struct backend_operations { - // =========== Initialization =========== - - /// Initialize the backend, prepare for rendering to the target window. - backend_t *(*init)(session_t *, xcb_window_t)attr_nonnull(1); - void (*deinit)(backend_t *backend_data) attr_nonnull(1); - - /// Called when rendering will be stopped for an unknown amount of - /// time (e.g. when screen is unredirected). Free some resources. - /// - /// Optional, not yet used - void (*pause)(backend_t *backend_data, session_t *ps); - - /// Called before rendering is resumed - /// - /// Optional, not yet used - void (*resume)(backend_t *backend_data, session_t *ps); - - /// Called when root window size changed. All existing image data ever - /// returned by this backend should remain valid after this call - /// returns. - /// - /// Optional - void (*root_change)(backend_t *backend_data, session_t *ps); - - // =========== Rendering ============ - - /// Called before when a new frame starts. - /// - /// Optional - void (*prepare)(backend_t *backend_data, const region_t *reg_damage); - - /// Multiply the alpha channel of the target image by a given value. - /// - /// @param backend_data backend data - /// @param target an image handle, cannot be NULL. - /// @param alpha the alpha value to multiply - /// @param region the region to apply the alpha, in the target image's - /// coordinate. - bool (*apply_alpha)(struct backend_base *backend_data, image_handle target, - double alpha, const region_t *region) attr_nonnull(1, 2, 4); - - /// Copy pixels from a source image on to the target image. - /// - /// Some effects may be applied. If the region specified by the mask - /// contains parts that are outside the source image, the source image - /// will be repeated to fit. - /// - /// Source and target MUST NOT be the same image. - /// - /// @param backend_data backend data - /// @param origin the origin of the operation, in the target image's - /// coordinate. - /// @param target an image handle, cannot be NULL. - /// @param args arguments for blit - /// @return whether the operation is successful - bool (*blit)(struct backend_base *backend_data, ivec2 origin, image_handle target, - const struct backend_blit_args *args) attr_nonnull(1, 3, 4); - - /// Blur a given region of a source image and store the result in the - /// target image. - /// - /// The blur operation might access pixels outside the mask region, the - /// amount of pixels accessed can be queried with `get_blur_size`. If - /// pixels outside the source image are accessed, the result will be - /// clamped to the edge of the source image. - /// - /// Source and target may be the same image. - /// - /// @param backend_data backend data - /// @param origin the origin of the operation, in the target image's - /// coordinate. - /// @param target an image handle, cannot be NULL. - /// @param args argument for blur - /// @return whether the operation is successful - bool (*blur)(struct backend_base *backend_data, ivec2 origin, image_handle target, - const struct backend_blur_args *args) attr_nonnull(1, 3, 4); - - /// Direct copy of pixels from a source image on to the target image. - /// This is a simpler version of `blit`, without any effects. Note unlike `blit`, - /// if `region` tries to sample from outside the source image, instead of - /// repeating, the result will be clamped to the edge of the source image. - /// Blending should not be applied for the copy. - /// - /// Source and target MUST NOT be the same image. - /// - /// @param backend_data backend data - /// @param origin the origin of the operation, in the target image's - /// coordinate. - /// @param target an image handle, cannot be NULL. - /// @param source an image handle, cannot be NULL. - /// @param region the region to copy, in the target image's coordinate. - /// @return whether the operation is successful - bool (*copy_area)(struct backend_base *backend_data, ivec2 origin, - image_handle target, image_handle source, const region_t *region) - attr_nonnull(1, 3, 4, 5); - - /// Similar to `copy_area`, but is specialized for copying from a higher - /// precision format to a lower precision format. It has 2 major differences from - /// `copy_area`: - /// - /// 1. This function _may_ use dithering when copying from a higher precision - /// format to a lower precision format. But this is not required. - /// 2. This function only needs to support copying from an image with the SRC - /// capability. Unlike `copy_area`, which supports copying from any image. - /// - /// It's perfectly legal to have this pointing to the same function as - /// `copy_area`, if the backend doesn't support dithering. - /// - /// @param backend_data backend data - /// @param origin the origin of the operation, in the target image's - /// coordinate. - /// @param target an image handle, cannot be NULL. - /// @param source an image handle, cannot be NULL. - /// @param region the region to copy, in the target image's coordinate. - /// @return whether the operation is successful - bool (*copy_area_quantize)(struct backend_base *backend_data, ivec2 origin, - image_handle target, image_handle source, - const region_t *region) attr_nonnull(1, 3, 4, 5); - - /// Initialize an image with a given color value. If the image has a mask format, - /// only the alpha channel of the color is used. - /// - /// @param backend_data backend data - /// @param target an image handle, cannot be NULL. - /// @param color the color to fill the image with - /// @return whether the operation is successful - bool (*clear)(struct backend_base *backend_data, image_handle target, - struct color color) attr_nonnull(1, 2); - - /// Present the back buffer to the target window. Ideally the backend should keep - /// track of the region of the back buffer that has been updated, and use relevant - /// mechanism (when possible) to present only the updated region. - bool (*present)(struct backend_base *backend_data) attr_nonnull(1); - - // ============ Resource management =========== - - /// Create a shader object from a shader source. - /// - /// Optional - void *(*create_shader)(backend_t *backend_data, const char *source)attr_nonnull(1, 2); - - /// Free a shader object. - /// - /// Required if create_shader is present. - void (*destroy_shader)(backend_t *backend_data, void *shader) attr_nonnull(1, 2); - - /// Create a new, uninitialized image with the given format and size. - /// - /// @param backend_data backend data - /// @param format the format of the image - /// @param size the size of the image - image_handle (*new_image)(struct backend_base *backend_data, - enum backend_image_format format, ivec2 size) - attr_nonnull(1); - - /// Bind a X pixmap to the backend's internal image data structure. - /// - /// @param backend_data backend data - /// @param pixmap X pixmap to bind - /// @param fmt information of the pixmap's visual - /// @return backend specific image handle for the pixmap. May be - /// NULL. - image_handle (*bind_pixmap)(struct backend_base *backend_data, xcb_pixmap_t pixmap, - struct xvisual_info fmt) attr_nonnull(1); - - /// Acquire the image handle of the back buffer. - /// - /// @param backend_data backend data - image_handle (*back_buffer)(struct backend_base *backend_data); - - /// Free resources associated with an image data structure. Releasing the image - /// returned by `back_buffer` should be a no-op. - /// - /// @param image the image to be released, cannot be NULL. - /// @return if this image is created by `bind_pixmap`, the X pixmap; 0 - /// otherwise. - xcb_pixmap_t (*release_image)(struct backend_base *backend_data, image_handle image) - attr_nonnull(1, 2); - - // =========== Query =========== - - /// Get backend quirks - /// @return a bitmask of `enum backend_quirk`. - uint32_t (*quirks)(struct backend_base *backend_data) attr_nonnull(1); - - /// Check if an optional image format is supported by the backend. - bool (*is_format_supported)(struct backend_base *backend_data, - enum backend_image_format format) attr_nonnull(1); - - /// Return the capabilities of an image. - uint32_t (*image_capabilities)(struct backend_base *backend_data, image_handle image) - attr_nonnull(1, 2); - - /// Get the attributes of a shader. - /// - /// Optional, Returns a bitmask of attributes, see `shader_attributes`. - uint64_t (*get_shader_attributes)(backend_t *backend_data, void *shader) - attr_nonnull(1, 2); - - /// Get the age of the buffer content we are currently rendering on top - /// of. The buffer that has just been `present`ed has a buffer age of 1. - /// Every time `present` is called, buffers get older. Return -1 if the - /// buffer is empty. - /// - /// Optional - int (*buffer_age)(backend_t *backend_data); - - /// Get the render time of the last frame. If the render is still in progress, - /// returns false. The time is returned in `ts`. Frames are delimited by the - /// present() calls. i.e. after a present() call, last_render_time() should start - /// reporting the time of the just presented frame. - /// - /// Optional, if not available, the most conservative estimation will be used. - bool (*last_render_time)(backend_t *backend_data, struct timespec *ts); - - /// The maximum number buffer_age might return. - int max_buffer_age; - - // =========== Post-processing ============ - /// Create a blur context that can be used to call `blur` for images with a - /// specific format. - void *(*create_blur_context)(backend_t *base, enum blur_method, - enum backend_image_format format, void *args); - /// Destroy a blur context - void (*destroy_blur_context)(backend_t *base, void *ctx); - /// Get how many pixels outside of the blur area is needed for blur - void (*get_blur_size)(void *blur_context, int *width, int *height); - - // =========== Misc ============ - /// Return the driver that is been used by the backend - enum driver (*detect_driver)(backend_t *backend_data); - - void (*diagnostics)(backend_t *backend_data); - - enum device_status (*device_status)(backend_t *backend_data); -}; -struct backend_info; bool backend_execute(struct backend_base *backend, image_handle target, unsigned ncmds, const struct backend_command cmds[ncmds]); -/// Register a new backend, `major` and `minor` should be the version of the picom backend -/// interface. You should just pass `PICOM_BACKEND_MAJOR` and `PICOM_BACKEND_MINOR` here. -/// `name` is the name of the backend, `init` is the function to initialize the backend, -/// `can_present` should be true if the backend can present the back buffer to the screen, -/// false otherwise (e.g. if the backend does off screen rendering, etc.) -bool PICOM_PUBLIC_API backend_register(uint64_t major, uint64_t minor, const char *name, - struct backend_base *(*init)(session_t *ps, - xcb_window_t target), - bool can_present); struct backend_info *backend_find(const char *name); struct backend_base * backend_init(struct backend_info *info, session_t *ps, xcb_window_t target); diff --git a/src/backend/dummy/dummy.c b/src/backend/dummy/dummy.c index 210e6ad2..b79e9efb 100644 --- a/src/backend/dummy/dummy.c +++ b/src/backend/dummy/dummy.c @@ -1,6 +1,8 @@ #include #include +#include + #include "backend/backend.h" #include "backend/backend_common.h" #include "common.h" @@ -8,7 +10,6 @@ #include "config.h" #include "log.h" #include "region.h" -#include "types.h" #include "uthash_extra.h" #include "utils.h" #include "x.h" diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index e9ab9f3c..328c2861 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -9,13 +9,13 @@ #include #include // for xcb_render_fixed_t, XXX -#include "backend/backend.h" +#include + #include "common.h" #include "compiler.h" #include "config.h" #include "log.h" #include "region.h" -#include "types.h" #include "utils.h" #include "backend/backend_common.h" diff --git a/src/backend/xrender/xrender.c b/src/backend/xrender/xrender.c index 0269218f..043c1bde 100644 --- a/src/backend/xrender/xrender.c +++ b/src/backend/xrender/xrender.c @@ -12,6 +12,8 @@ #include #include +#include + #include "backend/backend.h" #include "backend/backend_common.h" #include "backend/driver.h" @@ -22,7 +24,6 @@ #include "log.h" #include "picom.h" #include "region.h" -#include "types.h" #include "utils.h" #include "win.h" #include "x.h" diff --git a/src/c2.c b/src/c2.c index 0b8996ab..8030f921 100644 --- a/src/c2.c +++ b/src/c2.c @@ -36,6 +36,7 @@ #include "log.h" #include "string_utils.h" #include "test.h" +#include "uthash_extra.h" #include "utils.h" #include "win.h" #include "x.h" diff --git a/src/common.h b/src/common.h index f7baecf2..13f76608 100644 --- a/src/common.h +++ b/src/common.h @@ -40,7 +40,9 @@ #include #include -#include "uthash_extra.h" +#include +#include + #ifdef CONFIG_OPENGL #include "backend/gl/glx.h" #endif @@ -51,16 +53,11 @@ #endif // FIXME This list of includes should get shorter -#include "backend/backend.h" #include "backend/driver.h" -#include "compiler.h" #include "config.h" -#include "list.h" #include "region.h" #include "render.h" #include "statistics.h" -#include "types.h" -#include "utils.h" #include "win_defs.h" #include "x.h" diff --git a/src/config.c b/src/config.c index c14257d9..bd6ac186 100644 --- a/src/config.c +++ b/src/config.c @@ -16,13 +16,13 @@ #include #include // for xcb_render_fixed_t, XXX +#include #include #include "common.h" #include "kernel.h" #include "log.h" #include "string_utils.h" -#include "types.h" #include "config.h" diff --git a/src/config.h b/src/config.h index 729c4016..9c0723c8 100644 --- a/src/config.h +++ b/src/config.h @@ -16,12 +16,12 @@ #include #include +#include #include "compiler.h" #include "kernel.h" #include "list.h" #include "log.h" -#include "types.h" #include "win_defs.h" typedef struct session session_t; @@ -58,15 +58,6 @@ typedef struct win_option { bool clip_shadow_above; } win_option_t; -enum blur_method { - BLUR_METHOD_NONE = 0, - BLUR_METHOD_KERNEL, - BLUR_METHOD_BOX, - BLUR_METHOD_GAUSSIAN, - BLUR_METHOD_DUAL_KAWASE, - BLUR_METHOD_INVALID, -}; - typedef struct _c2_lptr c2_lptr_t; enum vblank_scheduler_type { diff --git a/src/config_libconfig.c b/src/config_libconfig.c index 143a5661..643eda31 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -10,6 +10,7 @@ #include #include +#include "backend/backend.h" #include "c2.h" #include "common.h" #include "config.h" diff --git a/src/dbus.c b/src/dbus.c index 55b8939e..f09080fc 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -20,15 +20,15 @@ #include #include +#include + +#include "backend/backend.h" #include "common.h" #include "compiler.h" #include "config.h" #include "list.h" #include "log.h" #include "string_utils.h" -#include "transition.h" -#include "types.h" -#include "uthash_extra.h" #include "utils.h" #include "win.h" #include "win_defs.h" diff --git a/src/diagnostic.c b/src/diagnostic.c index 0595859a..aec78b05 100644 --- a/src/diagnostic.c +++ b/src/diagnostic.c @@ -5,6 +5,7 @@ #include #include +#include "backend/backend.h" #include "backend/driver.h" #include "common.h" #include "config.h" diff --git a/src/event.c b/src/event.c index d7b193bc..d461e3fe 100644 --- a/src/event.c +++ b/src/event.c @@ -11,6 +11,8 @@ #include #include +#include + #include "atom.h" #include "c2.h" #include "common.h" @@ -20,7 +22,6 @@ #include "log.h" #include "picom.h" #include "region.h" -#include "types.h" #include "utils.h" #include "win.h" #include "win_defs.h" diff --git a/src/log.h b/src/log.h index e7c6c06c..3e20f611 100644 --- a/src/log.h +++ b/src/log.h @@ -3,6 +3,7 @@ #pragma once #include +#include #include #include "compiler.h" diff --git a/src/meson.build b/src/meson.build index 7904c31b..18982939 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,8 +11,8 @@ srcs = [ files('picom.c', 'win.c', 'c2.c', 'x.c', 'config.c', 'vsync.c', 'utils. 'diagnostic.c', 'string_utils.c', 'render.c', 'kernel.c', 'log.c', 'options.c', 'event.c', 'cache.c', 'atom.c', 'file_watch.c', 'statistics.c', 'vblank.c', 'transition.c', 'wm.c', 'renderer/layout.c', 'renderer/command_builder.c', - 'renderer/renderer.c', 'renderer/damage.c', 'config_libconfig.c', 'inspect.c', 'script.c') ] -picom_inc = include_directories('.') + 'renderer/renderer.c', 'renderer/damage.c', 'config_libconfig.c', 'inspect.c', 'script.c', 'api.c') ] +picom_inc = include_directories(['.', '../include']) cflags = [] diff --git a/src/options.h b/src/options.h index d3c43759..91b7c0ca 100644 --- a/src/options.h +++ b/src/options.h @@ -7,10 +7,10 @@ #include #include // for xcb_render_fixed_t +#include + #include "compiler.h" #include "config.h" -#include "types.h" -#include "win.h" // for wintype_t typedef struct session session_t; diff --git a/src/picom.c b/src/picom.c index 6a22ab58..c840190d 100644 --- a/src/picom.c +++ b/src/picom.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -38,17 +38,15 @@ #include #include -#include +#include #include #include "common.h" #include "compiler.h" #include "config.h" -#include "err.h" #include "inspect.h" #include "kernel.h" #include "picom.h" -#include "transition.h" #include "win_defs.h" #include "wm.h" #ifdef CONFIG_OPENGL @@ -70,7 +68,6 @@ #include "renderer/layout.h" #include "renderer/renderer.h" #include "statistics.h" -#include "types.h" #include "uthash_extra.h" #include "utils.h" #include "vblank.h" diff --git a/src/picom.h b/src/picom.h index e83cf4d1..269b9ce4 100644 --- a/src/picom.h +++ b/src/picom.h @@ -6,22 +6,20 @@ // === Includes === +#include #include #include #include #include -#include -#include "backend/backend.h" +#include + #include "c2.h" #include "common.h" -#include "compiler.h" #include "config.h" #include "log.h" // XXX clean up #include "region.h" #include "render.h" -#include "types.h" -#include "utils.h" #include "win.h" #include "x.h" diff --git a/src/region.h b/src/region.h index c0d07215..838c71f0 100644 --- a/src/region.h +++ b/src/region.h @@ -2,12 +2,12 @@ // Copyright (c) 2018 Yuxuan Shui #pragma once #include -#include #include #include +#include + #include "log.h" -#include "types.h" #include "utils.h" typedef struct pixman_region32 pixman_region32_t; diff --git a/src/render.c b/src/render.c index 17a05b96..10a79a1d 100644 --- a/src/render.c +++ b/src/render.c @@ -10,9 +10,10 @@ #include #include +#include + #include "common.h" #include "options.h" -#include "transition.h" #ifdef CONFIG_OPENGL #include "backend/gl/glx.h" @@ -29,13 +30,11 @@ #include "kernel.h" #include "log.h" #include "region.h" -#include "types.h" #include "utils.h" #include "vsync.h" #include "win.h" #include "x.h" -#include "backend/backend.h" #include "backend/backend_common.h" #include "render.h" diff --git a/src/renderer/command_builder.h b/src/renderer/command_builder.h index 4672f315..a33bb985 100644 --- a/src/renderer/command_builder.h +++ b/src/renderer/command_builder.h @@ -2,11 +2,13 @@ // Copyright (c) Yuxuan Shui #pragma once -#include "backend/backend.h" -#include "types.h" +#include struct command_builder; +struct backend_command; struct layout; +struct x_monitors; +struct win_option; struct command_builder *command_builder_new(void); void command_builder_free(struct command_builder *); diff --git a/src/renderer/damage.h b/src/renderer/damage.h index 6be5d076..5111cbcc 100644 --- a/src/renderer/damage.h +++ b/src/renderer/damage.h @@ -1,6 +1,6 @@ #pragma once -#include "types.h" +#include typedef struct pixman_region32 region_t; struct layout; diff --git a/src/renderer/layout.c b/src/renderer/layout.c index fed6e856..1c74299e 100644 --- a/src/renderer/layout.c +++ b/src/renderer/layout.c @@ -3,11 +3,12 @@ #include #include +#include + #include "command_builder.h" #include "common.h" #include "list.h" #include "region.h" -#include "types.h" #include "utils.h" #include "win.h" #include "wm.h" diff --git a/src/renderer/layout.h b/src/renderer/layout.h index 00fdaa15..c50a975e 100644 --- a/src/renderer/layout.h +++ b/src/renderer/layout.h @@ -4,9 +4,10 @@ #include #include #include -#include "backend/backend.h" + +#include + #include "region.h" -#include "types.h" struct layer_key { /// Window generation, (see `struct wm::generation` for explanation of what a diff --git a/src/renderer/renderer.h b/src/renderer/renderer.h index 7354b998..3a4b6556 100644 --- a/src/renderer/renderer.h +++ b/src/renderer/renderer.h @@ -4,7 +4,8 @@ #pragma once #include #include -#include "types.h" + +#include struct renderer; struct layout_manager; diff --git a/src/utils.h b/src/utils.h index 280f4c79..115ab353 100644 --- a/src/utils.h +++ b/src/utils.h @@ -2,9 +2,7 @@ // Copyright (c) 2018 Yuxuan Shui #pragma once #include -#include #include -#include #include #include #include @@ -12,13 +10,13 @@ #include #include +#include #include #include #include "compiler.h" #include "log.h" -#include "types.h" #define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) diff --git a/src/win.c b/src/win.c index 69b27937..b935f64f 100644 --- a/src/win.c +++ b/src/win.c @@ -15,8 +15,9 @@ #include #include +#include + #include "atom.h" -#include "backend/backend.h" #include "c2.h" #include "common.h" #include "compiler.h" @@ -27,10 +28,6 @@ #include "picom.h" #include "region.h" #include "render.h" -#include "string_utils.h" -#include "transition.h" -#include "types.h" -#include "uthash_extra.h" #include "utils.h" #include "win_defs.h" #include "wm.h" diff --git a/src/win.h b/src/win.h index 1f2fe88a..19ee1c86 100644 --- a/src/win.h +++ b/src/win.h @@ -7,9 +7,8 @@ #include #include -#include - -#include "uthash_extra.h" +#include +#include #include "c2.h" #include "compiler.h" @@ -17,8 +16,6 @@ #include "region.h" #include "render.h" #include "script.h" -#include "transition.h" -#include "types.h" #include "utils.h" #include "win_defs.h" #include "x.h" diff --git a/src/x.h b/src/x.h index 3a7b0fd9..3a15d6d0 100644 --- a/src/x.h +++ b/src/x.h @@ -43,21 +43,6 @@ typedef struct winprop_info { uint32_t length; } winprop_info_t; -struct xvisual_info { - /// Bit depth of the red component - int red_size; - /// Bit depth of the green component - int green_size; - /// Bit depth of the blue component - int blue_size; - /// Bit depth of the alpha component - int alpha_size; - /// The depth of X visual - int visual_depth; - - xcb_visualid_t visual; -}; - enum pending_reply_action { PENDING_REPLY_ACTION_IGNORE, PENDING_REPLY_ACTION_ABORT,