move wlr_box from /types to /util

This commit is contained in:
Simon Zeni 2021-07-01 16:36:01 -04:00 committed by Simon Ser
parent d975f35bba
commit e192d87731
35 changed files with 80 additions and 62 deletions

View file

@ -17,6 +17,7 @@
#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_output.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>

View file

@ -14,6 +14,7 @@
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_surface.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
/** /**

View file

@ -17,6 +17,7 @@
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include "cat.h" #include "cat.h"

View file

@ -14,6 +14,7 @@
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>

View file

@ -9,13 +9,13 @@
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_tablet_pad.h> #include <wlr/types/wlr_tablet_pad.h>
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>

View file

@ -8,7 +8,6 @@
#include <wlr/backend/wayland.h> #include <wlr/backend/wayland.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_pointer.h> #include <wlr/types/wlr_pointer.h>
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>

View file

@ -11,7 +11,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
/** /**

View file

@ -13,10 +13,12 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/render/dmabuf.h> #include <wlr/render/dmabuf.h>
struct wlr_box;
struct wlr_fbox;
struct wlr_renderer_impl { struct wlr_renderer_impl {
bool (*bind_buffer)(struct wlr_renderer *renderer, bool (*bind_buffer)(struct wlr_renderer *renderer,
struct wlr_buffer *buffer); struct wlr_buffer *buffer);

View file

@ -13,7 +13,6 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render/wlr_texture.h> #include <wlr/render/wlr_texture.h>
#include <wlr/types/wlr_box.h>
enum wlr_renderer_read_pixels_flags { enum wlr_renderer_read_pixels_flags {
WLR_RENDERER_READ_PIXELS_Y_INVERT = 1, WLR_RENDERER_READ_PIXELS_Y_INVERT = 1,
@ -22,6 +21,8 @@ enum wlr_renderer_read_pixels_flags {
struct wlr_renderer_impl; struct wlr_renderer_impl;
struct wlr_drm_format_set; struct wlr_drm_format_set;
struct wlr_buffer; struct wlr_buffer;
struct wlr_box;
struct wlr_fbox;
struct wlr_renderer { struct wlr_renderer {
const struct wlr_renderer_impl *impl; const struct wlr_renderer_impl *impl;

View file

@ -1,42 +1,7 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_BOX_H #ifndef WLR_TYPES_WLR_BOX_H
#define WLR_TYPES_WLR_BOX_H #define WLR_TYPES_WLR_BOX_H
#include <pixman.h> #warning "wlr_box has been moved to wlr/util/box.h"
#include <stdbool.h> #include <wlr/util/box.h>
#include <wayland-server-protocol.h>
struct wlr_box {
int x, y;
int width, height;
};
struct wlr_fbox {
double x, y;
double width, height;
};
void wlr_box_closest_point(const struct wlr_box *box, double x, double y,
double *dest_x, double *dest_y);
bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a,
const struct wlr_box *box_b);
bool wlr_box_contains_point(const struct wlr_box *box, double x, double y);
bool wlr_box_empty(const struct wlr_box *box);
/**
* Transforms a box inside a `width` x `height` box.
*/
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
enum wl_output_transform transform, int width, int height);
#endif #endif

View file

@ -10,7 +10,6 @@
#define WLR_TYPES_WLR_CURSOR_H #define WLR_TYPES_WLR_CURSOR_H
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
@ -26,6 +25,7 @@
* the screen, and so on. * the screen, and so on.
*/ */
struct wlr_box;
struct wlr_cursor_state; struct wlr_cursor_state;
struct wlr_cursor { struct wlr_cursor {

View file

@ -8,10 +8,10 @@
#ifndef WLR_TYPES_WLR_LAYER_SHELL_V1_H #ifndef WLR_TYPES_WLR_LAYER_SHELL_V1_H
#define WLR_TYPES_WLR_LAYER_SHELL_V1_H #define WLR_TYPES_WLR_LAYER_SHELL_V1_H
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_surface.h>
#include "wlr-layer-shell-unstable-v1-protocol.h" #include "wlr-layer-shell-unstable-v1-protocol.h"

View file

@ -16,8 +16,9 @@
#ifndef WLR_TYPES_WLR_MATRIX_H #ifndef WLR_TYPES_WLR_MATRIX_H
#define WLR_TYPES_WLR_MATRIX_H #define WLR_TYPES_WLR_MATRIX_H
#include <wayland-server-core.h> #include <wayland-server-protocol.h>
#include <wlr/types/wlr_box.h>
struct wlr_box;
/** Writes the identity matrix into mat */ /** Writes the identity matrix into mat */
void wlr_matrix_identity(float mat[static 9]); void wlr_matrix_identity(float mat[static 9]);

View file

@ -11,7 +11,6 @@
#include <pixman.h> #include <pixman.h>
#include <time.h> #include <time.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
/** /**
@ -21,6 +20,8 @@
*/ */
#define WLR_OUTPUT_DAMAGE_PREVIOUS_LEN 2 #define WLR_OUTPUT_DAMAGE_PREVIOUS_LEN 2
struct wlr_box;
/** /**
* Tracks damage for an output. * Tracks damage for an output.
* *

View file

@ -11,9 +11,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
struct wlr_box;
struct wlr_output_layout_state; struct wlr_output_layout_state;
/** /**

View file

@ -12,7 +12,6 @@
#include <stdint.h> #include <stdint.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <pixman.h> #include <pixman.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include "pointer-constraints-unstable-v1-protocol.h" #include "pointer-constraints-unstable-v1-protocol.h"

View file

@ -11,7 +11,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_box.h> #include <wlr/util/box.h>
struct wlr_screencopy_manager_v1 { struct wlr_screencopy_manager_v1 {
struct wl_global *global; struct wl_global *global;

View file

@ -14,8 +14,8 @@
#include <stdint.h> #include <stdint.h>
#include <time.h> #include <time.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/util/box.h>
enum wlr_surface_state_field { enum wlr_surface_state_field {
WLR_SURFACE_STATE_BUFFER = 1 << 0, WLR_SURFACE_STATE_BUFFER = 1 << 0,

View file

@ -8,9 +8,10 @@
#ifndef WLR_TYPES_WLR_XDG_SHELL_H #ifndef WLR_TYPES_WLR_XDG_SHELL_H
#define WLR_TYPES_WLR_XDG_SHELL_H #define WLR_TYPES_WLR_XDG_SHELL_H
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_seat.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/box.h>
#include "xdg-shell-protocol.h" #include "xdg-shell-protocol.h"
struct wlr_xdg_shell { struct wlr_xdg_shell {

42
include/wlr/util/box.h Normal file
View file

@ -0,0 +1,42 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_BOX_H
#define WLR_TYPES_WLR_BOX_H
#include <pixman.h>
#include <stdbool.h>
#include <wayland-server-protocol.h>
struct wlr_box {
int x, y;
int width, height;
};
struct wlr_fbox {
double x, y;
double width, height;
};
void wlr_box_closest_point(const struct wlr_box *box, double x, double y,
double *dest_x, double *dest_y);
bool wlr_box_intersection(struct wlr_box *dest, const struct wlr_box *box_a,
const struct wlr_box *box_b);
bool wlr_box_contains_point(const struct wlr_box *box, double x, double y);
bool wlr_box_empty(const struct wlr_box *box);
/**
* Transforms a box inside a `width` x `height` box.
*/
void wlr_box_transform(struct wlr_box *dest, const struct wlr_box *box,
enum wl_output_transform transform, int width, int height);
#endif

View file

@ -15,6 +15,7 @@
#include <wlr/types/wlr_drm.h> #include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "render/egl.h" #include "render/egl.h"
#include "render/gles2.h" #include "render/gles2.h"

View file

@ -5,6 +5,7 @@
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "render/pixman.h" #include "render/pixman.h"

View file

@ -5,6 +5,7 @@
#include <wlr/render/pixman.h> #include <wlr/render/pixman.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/config.h> #include <wlr/config.h>

View file

@ -16,7 +16,6 @@ wlr_files += files(
'xdg_shell/wlr_xdg_shell.c', 'xdg_shell/wlr_xdg_shell.c',
'xdg_shell/wlr_xdg_surface.c', 'xdg_shell/wlr_xdg_surface.c',
'xdg_shell/wlr_xdg_toplevel.c', 'xdg_shell/wlr_xdg_toplevel.c',
'wlr_box.c',
'wlr_buffer.c', 'wlr_buffer.c',
'wlr_compositor.c', 'wlr_compositor.c',
'wlr_cursor.c', 'wlr_cursor.c',

View file

@ -10,6 +10,7 @@
#include <wlr/types/wlr_pointer.h> #include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_touch.h> #include <wlr/types/wlr_touch.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h" #include "util/signal.h"

View file

@ -2,8 +2,8 @@
#include <string.h> #include <string.h>
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/util/box.h>
void wlr_matrix_identity(float mat[static 9]) { void wlr_matrix_identity(float mat[static 9]) {
static const float identity[9] = { static const float identity[9] = {

View file

@ -9,11 +9,11 @@
#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_output.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_surface.h> #include <wlr/types/wlr_surface.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>
#include "backend/backend.h" #include "backend/backend.h"

View file

@ -2,9 +2,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output_damage.h> #include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/util/box.h>
#include "util/signal.h" #include "util/signal.h"
static void output_handle_destroy(struct wl_listener *listener, void *data) { static void output_handle_destroy(struct wl_listener *listener, void *data) {

View file

@ -2,9 +2,9 @@
#include <float.h> #include <float.h>
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h" #include "util/signal.h"

View file

@ -4,9 +4,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_pointer_constraints_v1.h> #include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_region.h> #include <wlr/types/wlr_region.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h" #include "util/signal.h"

View file

@ -7,6 +7,7 @@
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_screencopy_v1.h> #include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "wlr-screencopy-unstable-v1-protocol.h" #include "wlr-screencopy-unstable-v1-protocol.h"
#include "render/pixel_format.h" #include "render/pixel_format.h"

View file

@ -1,6 +1,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "types/wlr_xdg_shell.h" #include "types/wlr_xdg_shell.h"
#include "util/signal.h" #include "util/signal.h"

View file

@ -2,8 +2,7 @@
#include <math.h> #include <math.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server-protocol.h> #include <wlr/util/box.h>
#include <wlr/types/wlr_box.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
void wlr_box_closest_point(const struct wlr_box *box, double x, double y, void wlr_box_closest_point(const struct wlr_box *box, double x, double y,

View file

@ -1,5 +1,6 @@
wlr_files += files( wlr_files += files(
'array.c', 'array.c',
'box.c',
'global.c', 'global.c',
'log.c', 'log.c',
'region.c', 'region.c',

View file

@ -2,7 +2,6 @@
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <wlr/types/wlr_box.h>
#include <wlr/util/region.h> #include <wlr/util/region.h>
void wlr_region_scale(pixman_region32_t *dst, pixman_region32_t *src, void wlr_region_scale(pixman_region32_t *dst, pixman_region32_t *src,