Skip to content

Commit

Permalink
wlc: bump version 0.0.2
Browse files Browse the repository at this point in the history
Removes deprecated functions.
Replaced wlc_init with wlc_init2.
  • Loading branch information
Cloudef committed Apr 15, 2016
1 parent 309ddb0 commit 62736aa
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 244 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
PROJECT(wlc VERSION 0.0.1 LANGUAGES C)
PROJECT(wlc VERSION 0.0.2 LANGUAGES C)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/CMake")

# Subprojects
Expand Down
4 changes: 2 additions & 2 deletions example/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ cb_log(enum wlc_log_type type, const char *str)
}

int
main(int argc, char *argv[])
main(void)
{
wlc_log_set_handler(cb_log);

Expand All @@ -266,7 +266,7 @@ main(int argc, char *argv[])
wlc_set_pointer_button_cb(pointer_button);
wlc_set_pointer_motion_cb(pointer_motion);

if (!wlc_init2())
if (!wlc_init())
return EXIT_FAILURE;

wlc_run();
Expand Down
142 changes: 2 additions & 140 deletions include/wlc/wlc.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,118 +120,6 @@ struct wlc_modifiers {
uint32_t leds, mods;
};

/** Interface struct for communicating with wlc.
* Deprecated, don't use directly. Instead use the wlc_set_*_cb functions below. */
__attribute__((deprecated("deprecated in favor of wlc_set_*_cb functions")))
struct wlc_interface {
struct {
/** Output was created. Return false if you want to destroy the output. (e.g. failed to allocate data related to view) */
bool (*created)(wlc_handle output);

/** Output was destroyed. */
void (*destroyed)(wlc_handle output);

/** Output got or lost focus. */
void (*focus)(wlc_handle output, bool focus);

/** Output resolution changed. */
WLC_NONULL void (*resolution)(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to);

struct {
/** Output context is created. This generally happens on startup and when current tty changes */
void (*created)(wlc_handle output);

/** Output context is destroyed */
void (*destroyed)(wlc_handle output);
} context;

struct {
/** Pre render hook. */
void (*pre)(wlc_handle output);

/** Post render hook. */
void (*post)(wlc_handle output);
} render;
} output;

struct {
/** View was created. Return false if you want to destroy the view. (e.g. failed to allocate data related to view) */
bool (*created)(wlc_handle view);

/** View was destroyed. */
void (*destroyed)(wlc_handle view);

/** View got or lost focus. */
void (*focus)(wlc_handle view, bool focus);

/** View was moved to output. */
void (*move_to_output)(wlc_handle view, wlc_handle from_output, wlc_handle to_output);

struct {
/** Request to set given geometry for view. Apply using wlc_view_set_geometry to agree. */
WLC_NONULL void (*geometry)(wlc_handle view, const struct wlc_geometry*);

/** Request to disable or enable the given state for view. Apply using wlc_view_set_state to agree. */
void (*state)(wlc_handle view, enum wlc_view_state_bit, bool toggle);

/** Request to move itself. Start a interactive move to agree. */
WLC_NONULL void (*move)(wlc_handle view, const struct wlc_point*);

/** Request to resize itself with the given edges. Start a interactive resize to agree. */
WLC_NONULL void (*resize)(wlc_handle view, uint32_t edges, const struct wlc_point*);
} request;

struct {
/** Pre render hook. */
void (*pre)(wlc_handle view);

/** Post render hook. */
void (*post)(wlc_handle view);
} render;
} view;

struct {
/** Key event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*key)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, uint32_t key, enum wlc_key_state);
} keyboard;

struct {
/** Button event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*button)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, uint32_t button, enum wlc_button_state, const struct wlc_point*);

/** Scroll event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*scroll)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, uint8_t axis_bits, double amount[2]);

/** Motion event was triggered, view handle will be zero if there was no focus. Apply with wlc_pointer_set_position to agree. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*motion)(wlc_handle view, uint32_t time, const struct wlc_point*);
} pointer;

struct {
/** Touch event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*touch)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, enum wlc_touch_type, int32_t slot, const struct wlc_point*);
} touch;

struct {
/** Compositor is ready to accept clients. */
void (*ready)(void);

/** Compositor is about to terminate */
void (*terminate)(void);
} compositor;

/**
* Experimental input api.
* libinput isn't abstracted, so no handles given.
*/
struct {
/** Input device was created. Return value does nothing. */
bool (*created)(struct libinput_device *device);

/** Input device was destroyed. */
void (*destroyed)(struct libinput_device *device);
} input;
};

/** -- Callbacks API */

/** Output was created. Return false if you want to destroy the output. (e.g. failed to allocate data related to view) */
Expand Down Expand Up @@ -328,24 +216,10 @@ void wlc_log_set_handler(void (*cb)(enum wlc_log_type type, const char *str));
*
* wlc_init's purpose is to initialize and drop privileges as soon as possible.
*
* You can pass argc and argv from main(), so wlc can rename the process it forks
* to cleanup crashed parent process and do FD passing (non-logind).
*/
__attribute__((deprecated("will be replaced with wlc_init2 in next release")))
bool wlc_init(const struct wlc_interface *interface, int argc, char *argv[]);

/**
* Initialize wlc. Returns false on failure.
*
* Avoid running unverified code before wlc_init as wlc compositor may be run with higher
* privileges on non logind systems where compositor binary needs to be suid.
*
* wlc_init's purpose is to initialize and drop privileges as soon as possible.
*
* Callbacks should be set using wlc_set_*_cb functions before calling wlc_init2,
* Callbacks should be set using wlc_set_*_cb functions before calling wlc_init,
* failing to do so will cause any callback the init may trigger to not be called.
*/
bool wlc_init2(void);
bool wlc_init(void);

/** Terminate wlc. */
void wlc_terminate(void);
Expand Down Expand Up @@ -406,10 +280,6 @@ uint32_t wlc_output_get_mask(wlc_handle output);
/** Set visibility bitmask. */
void wlc_output_set_mask(wlc_handle output, uint32_t mask);

/** Get pixels. If you return true in callback, the rgba data will be not freed. Do this if you don't want to copy the buffer. */
__attribute__((deprecated("deprecated in favor of wlc_pixels_read")))
WLC_NONULL void wlc_output_get_pixels(wlc_handle output, bool (*pixels)(const struct wlc_size *size, uint8_t *rgba, void *arg), void *arg);

/** Get views in stack order. Returned array is a direct reference, careful when moving and destroying handles. */
const wlc_handle* wlc_output_get_views(wlc_handle output, size_t *out_memb);

Expand Down Expand Up @@ -522,14 +392,6 @@ void wlc_pointer_get_position(struct wlc_point *out_position);
/** Set current pointer position. */
void wlc_pointer_set_position(const struct wlc_point *position);

/** Get current pointer origin. */
__attribute__((deprecated("deprecated in favor of wlc_pointer_get_position")))
void wlc_pointer_get_origin(struct wlc_origin *out_origin);

/** Set current pointer origin. */
__attribute__((deprecated("deprecated in favor of wlc_pointer_set_position")))
void wlc_pointer_set_origin(const struct wlc_origin *new_origin);

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 0 additions & 12 deletions src/compositor/compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,18 +648,6 @@ wlc_pointer_set_position(const struct wlc_point *position)
_g_compositor->seat.pointer.pos.y = position->y;
}

WLC_API void
wlc_pointer_get_origin(struct wlc_point *out_origin)
{
wlc_pointer_get_position(out_origin);
}

WLC_API void
wlc_pointer_set_origin(const struct wlc_point *new_origin)
{
wlc_pointer_set_position(new_origin);
}

void
wlc_compositor_terminate(struct wlc_compositor *compositor)
{
Expand Down
32 changes: 0 additions & 32 deletions src/compositor/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,6 @@ repaint(struct wlc_output *output)

rendering_output = NULL;

{
size_t sz;
void *rgba;
struct wlc_geometry g = { { 0, 0 }, output->resolution };
if (output->task.pixels.cb && !chck_mul_ofsz(g.size.w, g.size.h, &sz) && (rgba = chck_calloc_of(4, sz))) {
wlc_render_read_pixels(&output->render, &output->context, WLC_RGBA8888, &g, &g, rgba);
if (!output->task.pixels.cb(&g.size, rgba, output->task.pixels.arg))
free(rgba);
memset(&output->task.pixels, 0, sizeof(output->task.pixels));
}
}

output->state.pending = true;
wlc_context_swap(&output->context, &output->bsurface);

Expand Down Expand Up @@ -826,20 +814,6 @@ wlc_output_set_mask_ptr(struct wlc_output *output, uint32_t mask)
wlc_output_schedule_repaint(output);
}

void
wlc_output_get_pixels_ptr(struct wlc_output *output, bool (*pixels)(const struct wlc_size *size, uint8_t *rgba, void *arg), void *arg)
{
assert(pixels);

if (!output)
return;

// TODO: we need real task system, not like we do right now.
output->task.pixels.cb = pixels;
output->task.pixels.arg = arg;
wlc_output_schedule_repaint(output);
}

bool
wlc_output_set_views_ptr(struct wlc_output *output, const wlc_handle *views, size_t memb)
{
Expand Down Expand Up @@ -926,12 +900,6 @@ wlc_output_set_mask(wlc_handle output, uint32_t mask)
wlc_output_set_mask_ptr(convert_from_wlc_handle(output, "output"), mask);
}

WLC_API void
wlc_output_get_pixels(wlc_handle output, bool (*pixels)(const struct wlc_size *size, uint8_t *rgba, void *arg), void *arg)
{
wlc_output_get_pixels_ptr(convert_from_wlc_handle(output, "output"), pixels, arg);
}

WLC_API const wlc_handle*
wlc_output_get_views(wlc_handle output, size_t *out_memb)
{
Expand Down
4 changes: 0 additions & 4 deletions src/compositor/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ struct wlc_output {

// FIXME: replace with better system
struct {
struct {
void *arg;
bool (*cb)(const struct wlc_size *size, uint8_t *rgba, void *userdata);
} pixels;
struct wlc_backend_surface bsurface;
bool terminate;
bool sleep;
Expand Down
110 changes: 110 additions & 0 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,116 @@
# define WLC_LOG_ATTR(x, y)
#endif

/* Interface struct for communicating with wlc. */
struct wlc_interface {
struct {
/** Output was created. Return false if you want to destroy the output. (e.g. failed to allocate data related to view) */
bool (*created)(wlc_handle output);

/** Output was destroyed. */
void (*destroyed)(wlc_handle output);

/** Output got or lost focus. */
void (*focus)(wlc_handle output, bool focus);

/** Output resolution changed. */
WLC_NONULL void (*resolution)(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to);

struct {
/** Output context is created. This generally happens on startup and when current tty changes */
void (*created)(wlc_handle output);

/** Output context is destroyed */
void (*destroyed)(wlc_handle output);
} context;

struct {
/** Pre render hook. */
void (*pre)(wlc_handle output);

/** Post render hook. */
void (*post)(wlc_handle output);
} render;
} output;

struct {
/** View was created. Return false if you want to destroy the view. (e.g. failed to allocate data related to view) */
bool (*created)(wlc_handle view);

/** View was destroyed. */
void (*destroyed)(wlc_handle view);

/** View got or lost focus. */
void (*focus)(wlc_handle view, bool focus);

/** View was moved to output. */
void (*move_to_output)(wlc_handle view, wlc_handle from_output, wlc_handle to_output);

struct {
/** Request to set given geometry for view. Apply using wlc_view_set_geometry to agree. */
WLC_NONULL void (*geometry)(wlc_handle view, const struct wlc_geometry*);

/** Request to disable or enable the given state for view. Apply using wlc_view_set_state to agree. */
void (*state)(wlc_handle view, enum wlc_view_state_bit, bool toggle);

/** Request to move itself. Start a interactive move to agree. */
WLC_NONULL void (*move)(wlc_handle view, const struct wlc_point*);

/** Request to resize itself with the given edges. Start a interactive resize to agree. */
WLC_NONULL void (*resize)(wlc_handle view, uint32_t edges, const struct wlc_point*);
} request;

struct {
/** Pre render hook. */
void (*pre)(wlc_handle view);

/** Post render hook. */
void (*post)(wlc_handle view);
} render;
} view;

struct {
/** Key event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*key)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, uint32_t key, enum wlc_key_state);
} keyboard;

struct {
/** Button event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*button)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, uint32_t button, enum wlc_button_state, const struct wlc_point*);

/** Scroll event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*scroll)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, uint8_t axis_bits, double amount[2]);

/** Motion event was triggered, view handle will be zero if there was no focus. Apply with wlc_pointer_set_position to agree. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*motion)(wlc_handle view, uint32_t time, const struct wlc_point*);
} pointer;

struct {
/** Touch event was triggered, view handle will be zero if there was no focus. Return true to prevent sending the event to clients. */
WLC_NONULL bool (*touch)(wlc_handle view, uint32_t time, const struct wlc_modifiers*, enum wlc_touch_type, int32_t slot, const struct wlc_point*);
} touch;

struct {
/** Compositor is ready to accept clients. */
void (*ready)(void);

/** Compositor is about to terminate */
void (*terminate)(void);
} compositor;

/**
* Experimental input api.
* libinput isn't abstracted, so no handles given.
*/
struct {
/** Input device was created. Return value does nothing. */
bool (*created)(struct libinput_device *device);

/** Input device was destroyed. */
void (*destroyed)(struct libinput_device *device);
} input;
};

enum wlc_connector_type {
/* used when running wlc with backend (e.g. x11) that does not use real output. */
WLC_CONNECTOR_WLC,
Expand Down
Loading

0 comments on commit 62736aa

Please sign in to comment.