Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#164 broadcast change messages with descriptions #168

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bba76a5
#164 write human delta to /tmp/wd.delta on all changes, WIP
alex-courtis Apr 30, 2024
c70ae5b
#164 write human delta to /tmp/wd.delta on all changes, WIP
alex-courtis Apr 30, 2024
856a5df
#164 write human delta to /tmp/wd.delta on all changes, WIP
alex-courtis May 6, 2024
2caaf4f
#164 refactor IPC operations to use their own log_cap_lines
alex-courtis May 7, 2024
a0e1861
#164 refactor server startup to use log_cap_lines
alex-courtis May 7, 2024
be9f674
valgrind suppression for evdev
alex-courtis Nov 9, 2024
709094a
#164 cap_lines free method
alex-courtis Nov 9, 2024
f7a5920
#164 print_head tests
alex-courtis Nov 10, 2024
de59ff8
#164 change messages are on one line
alex-courtis Nov 10, 2024
7873987
#164 change messages are on one line
alex-courtis Nov 10, 2024
226e809
#164 change messages are on one line
alex-courtis Nov 10, 2024
9cdc06b
#164 send delta messages for all changes
alex-courtis Nov 10, 2024
bd5de3e
#164 add environment variable WD_MESSAGE to success cmd
alex-courtis Nov 10, 2024
8611705
#164 revert to original info deltas
alex-courtis Nov 10, 2024
9f10e79
#164 revert to original info deltas
alex-courtis Nov 10, 2024
791b892
#164 render a brief change message to set as $WD_MESSAGE for the command
alex-courtis Nov 11, 2024
874b7b4
#164 render a brief change message to set as $WD_MESSAGE for the command
alex-courtis Nov 11, 2024
1672a9c
#164 render a brief change message to set as $WD_MESSAGE for the command
alex-courtis Nov 11, 2024
66b2cf4
#164 render a brief change message to set as $WD_MESSAGE for the command
alex-courtis Nov 11, 2024
af7adbf
#164 render a brief change message to set as $WD_MESSAGE for the command
alex-courtis Nov 18, 2024
b79f4ba
#164 pass sh environment variables as table
alex-courtis Nov 18, 2024
3eef178
164 alex-c-collection 1.1.1 -> 1.4.0
alex-courtis Nov 18, 2024
3f271dd
#164 WD_CHANGE_SUCCESS_MSG
alex-courtis Nov 18, 2024
926f9a9
remove /tmp/wd.deltas
alex-courtis Dec 22, 2024
426fe35
#164 alex-c-collection 1.4.0 -> 1.4.1
alex-courtis Dec 22, 2024
dd00647
#164 split the briefs
alex-courtis Dec 22, 2024
bc7faae
#164 remove unused log method
alex-courtis Dec 22, 2024
0ae9f29
#164 consistency in brief formatting
alex-courtis Dec 22, 2024
861ad68
#164 add LayoutDelta to encapsulate changes in flight
alex-courtis Dec 22, 2024
97815b2
#164 display owns layout deltas
alex-courtis Dec 23, 2024
5bc00bb
#164 iwyu
alex-courtis Dec 23, 2024
68a58ac
#164 tidy names
alex-courtis Dec 23, 2024
d215303
#164 tidy includes
alex-courtis Dec 23, 2024
4580191
#164 tidy asserts
alex-courtis Dec 23, 2024
9a86055
#164 tidy cppcheck
alex-courtis Dec 23, 2024
110b3c3
#164 attempt cmocka version upgrade
alex-courtis Dec 23, 2024
427b2c9
Revert "#164 attempt cmocka version upgrade"
alex-courtis Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .iwyu.mappings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
{ symbol: [ va_start, private, <stdarg.h>, public] },
{ symbol: [ va_end, private, <stdarg.h>, public] }
]
4 changes: 1 addition & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ man: doc/way-displays.1.pandoc
iwyu: override CC = $(IWYU) -Xiwyu --check_also="inc/*h"
iwyu: override CXX = $(IWYU) -Xiwyu --check_also="inc/marshalling.h"
iwyu: clean $(SRC_O) $(TST_O) $(EXAMPLE_O)
IWYU = include-what-you-use -Xiwyu --no_fwd_decls -Xiwyu --error=1 -Xiwyu --verbose=3
IWYU = include-what-you-use -Xiwyu --no_fwd_decls -Xiwyu --error=1 -Xiwyu --verbose=3 -Xiwyu --mapping_file=.iwyu.mappings

cppcheck: $(SRC_C) $(SRC_CXX) $(INC_H) $(EXAMPLE_C) $(TST_H) $(TST_C)
# TODO: add --check-level=exhaustive when cppcheck ~2.14 is availble for CI
# cppcheck --enable=warning,unusedFunction,performance,portability --check-level=exhaustive --suppressions-list=bld/cppcheck.supp --error-exitcode=1 $(^)
cppcheck --enable=warning,unusedFunction,performance,portability --suppressions-list=bld/cppcheck.supp --error-exitcode=1 $(^)

%-vg: VALGRIND = valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all --gen-suppressions=all --suppressions=bld/vg.supp
Expand Down
7 changes: 6 additions & 1 deletion bld/cppcheck.supp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unusedFunction:lib/col/*c
unusedFunction:tst/wrap-log.c
unusedFunction:pro/*h

unusedFunction:tst/asserts.h
unusedFunction:tst/wrap-*.c

# TODO use --check-level=exhaustive once available in CI
normalCheckLevelMaxBranches
13 changes: 12 additions & 1 deletion bld/vg.supp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
fun:main
}

{
wacom DB new
Memcheck:Leak
match-leak-kinds: reachable
fun:*alloc
...
fun:libwacom_database_new
...
obj:/usr/lib/libinput.so.10.13.0
}

{
g_object_new_valist - from evdev
Memcheck:Leak
Expand All @@ -39,7 +50,7 @@
match-leak-kinds: reachable
...
fun:evdev_device_create
fun:device_added
fun:device_added*
}

{
Expand Down
2 changes: 1 addition & 1 deletion examples/poke-server.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>

#include "process.h"
#include "sockets.h"
Expand Down
6 changes: 3 additions & 3 deletions inc/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ bool cfg_equal_user_transform_name(const void *value, const void *data);

bool cfg_equal_user_transform(const void *value, const void *data);

void cfg_user_scale_free(void *user_scale);
void cfg_user_scale_free(const void *user_scale);

void cfg_user_mode_free(void *user_mode);
void cfg_user_mode_free(const void *user_mode);

void cfg_user_transform_free(void *user_transform);
void cfg_user_transform_free(const void *user_transform);

void cfg_destroy(void);

Expand Down
22 changes: 19 additions & 3 deletions inc/displ.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@
#include <stdint.h>

// IWYU pragma: begin_keep
#include "wlr-output-management-unstable-v1.h"
#include "xdg-output-unstable-v1.h"
// IWYU pragma: end_keep

enum ConfigState {
#include "cfg.h"
#include "head.h"

enum DisplState {
IDLE = 0,
SUCCEEDED,
OUTSTANDING,
CANCELLED,
FAILED,
};

struct DisplDelta {
enum CfgElement element; // 0 for many changes, VRR_OFF indicates toggle

// only when element set
struct Head *head;

char *human;
};

struct Displ {
// global
struct wl_registry *registry;
Expand All @@ -34,11 +45,16 @@ struct Displ {
uint32_t zxdg_output_manager_version;
char *zxdg_output_manager_interface;

enum ConfigState config_state;
enum DisplState state;
struct DisplDelta delta;
};

void displ_init(void);

void displ_delta_init(enum CfgElement element, struct Head *head);

void displ_delta_destroy(void);

void displ_destroy(void);

#endif // DISPL_H
2 changes: 1 addition & 1 deletion inc/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

bool mkdir_p(char *path, mode_t mode);

bool file_write(const char *path, const char *contents);
bool file_write(const char *path, const char *contents, const char *mode);

#endif // FS_H

3 changes: 0 additions & 3 deletions inc/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ extern struct Lid *lid;

extern struct SList *cfg_file_paths;

extern struct Head *head_changing_mode;
extern struct Head *head_changing_adaptive_sync;

#endif // GLOBAL_H
2 changes: 1 addition & 1 deletion inc/head.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool head_current_adaptive_sync_not_desired(const void *head);

void head_release_mode(struct Head *head, struct Mode *mode);

void head_free(void *head);
void head_free(const void *head);

void heads_release_head(struct Head *head);

Expand Down
12 changes: 12 additions & 0 deletions inc/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#include <stddef.h>

#include "cfg.h"
#include "displ.h"
#include "head.h"
#include "slist.h"
#include "log.h"
#include "mode.h"

#define LEN_HUMAN 1024 * 64

enum InfoEvent {
ARRIVED,
DEPARTED,
Expand All @@ -35,5 +38,14 @@ void info_user_mode_string(struct UserMode *user_mode, char *buf, size_t nbuf);

void info_mode_string(struct Mode *mode, char *buf, size_t nbuf);

// LEN_HUMAN, consumer frees
char *delta_human(const enum DisplState state, const struct SList * const heads);

// LEN_HUMAN, consumer frees
char *delta_human_mode(const enum DisplState state, const struct Head * const head);

// LEN_HUMAN, consumer frees
char *delta_human_adaptive_sync(const enum DisplState state, const struct Head * const head);

#endif // INFO_H

4 changes: 2 additions & 2 deletions inc/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct IpcOperation {
int socket_client;
bool done;
int rc;
bool send_logs; // not for bad or colliding requests
bool send_state; // not for bad requests
struct SList *log_cap_lines;
};

struct IpcRequest {
Expand Down Expand Up @@ -64,7 +64,7 @@ struct SList *ipc_receive_responses(int socket_client, char **yaml);

void ipc_request_free(struct IpcRequest *request);

void ipc_response_free(void *response);
void ipc_response_free(const void *response);

void ipc_operation_free(struct IpcOperation *operation);

Expand Down
16 changes: 9 additions & 7 deletions inc/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ struct LogCapLine {
char *line;
enum LogThreshold threshold;
};
extern struct SList *log_cap_lines;


void log_set_threshold(enum LogThreshold threshold, bool cli);

void log_set_times(bool times);


void log_(enum LogThreshold threshold, const char *__restrict __format, ...);


void log_debug(const char *__restrict __format, ...);

void log_info(const char *__restrict __format, ...);
Expand All @@ -37,20 +39,20 @@ void log_error(const char *__restrict __format, ...);

void log_error_errno(const char *__restrict __format, ...);


void log_suppress_start(void);

void log_suppress_stop(void);

void log_capture_start(void);

void log_capture_stop(void);
// caller must call stop and free lines
void log_cap_lines_start(struct SList **log_cap_lines);

void log_capture_clear(void);
void log_cap_lines_stop(struct SList **log_cap_lines);

// NULL plays back log_cap_lines
void log_capture_playback(struct SList *lines);
void log_cap_lines_free(struct SList **log_cap_lines);

void log_cap_line_free(void *log_cap_line);
void log_cap_lines_playback(struct SList *log_cap_lines);

#endif // LOG_H

5 changes: 2 additions & 3 deletions inc/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdint.h>

#include "cfg.h"
#include "global.h"
#include "slist.h"
#include "wlr-output-management-unstable-v1.h"

Expand Down Expand Up @@ -48,9 +47,9 @@ struct SList *modes_res_refresh(struct SList *modes);

struct Mode *mode_init(struct Head *head, struct zwlr_output_mode_v1 *zwlr_mode, int32_t width, int32_t height, int32_t refresh_mhz, bool preferred);

void mode_free(void *mode);
void mode_free(const void *mode);

void mode_res_refresh_free(void *mode);
void mode_res_refresh_free(const void *mode);

struct Mode *mode_user_mode(struct SList *modes, struct SList *modes_failed, struct UserMode *user_mode);

Expand Down
4 changes: 3 additions & 1 deletion inc/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

#include <sys/types.h>

#include "stable.h"

char *pid_path(void);

pid_t pid_active_server(void);

void pid_file_create(void);

void spawn_sh_cmd(const char * const command);
void spawn_sh_cmd(const char * const command, const struct STable * const env);

// exit; caller should return afterwards
void wd_exit(int __status);
Expand Down
1 change: 1 addition & 0 deletions inc/sockets.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SOCKETS_H
#define SOCKETS_H

#include <stddef.h>
#include <sys/types.h>
#include <sys/un.h>

Expand Down
2 changes: 1 addition & 1 deletion lib/col/.source
Original file line number Diff line number Diff line change
@@ -1 +1 @@
git@github.com:alex-courtis/alex-c-collections.git v1.1.1
git@github.com:alex-courtis/alex-c-collections.git v1.4.1
33 changes: 33 additions & 0 deletions lib/col/inc/fn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef FN_H
#define FN_H

#include <stdbool.h>

//
// a is generally the value from the collection, b is user supplied
//
typedef bool (*fn_equals)(const void* const a, const void* const b);

// true if both NULL or strcmp(a, b) == 0
bool fn_comp_equals_strcmp(const void* const a, const void* const b);

// true if both NULL or strstr(a, b)
bool fn_comp_equals_strstr(const void* const a, const void* const b);

//
// a < b
//
typedef bool (*fn_less_than)(const void* const a, const void* const b);

//
// arbitrary test
//
typedef bool (*fn_test)(const void* const val);

//
// free
//
typedef void (*fn_free_val)(const void* const val);

#endif // FN_H

37 changes: 32 additions & 5 deletions lib/col/inc/itable.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#ifndef ITABLE_H
#define ITABLE_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include "fn.h"

/*
* Array backed integer indexed table.
* Entries preserve insertion order.
Expand Down Expand Up @@ -31,8 +34,8 @@ const struct ITable *itable_init(const size_t initial, const size_t grow);
// free table
void itable_free(const void* const tab);

// free table and vals, null free_val uses free()
void itable_free_vals(const struct ITable* const tab, void (*free_val)(const void* const val));
// free table and vals, null fn_free_val uses free()
void itable_free_vals(const struct ITable* const tab, fn_free_val);

// free iter
void itable_iter_free(const struct ITableIter* const iter);
Expand All @@ -50,9 +53,6 @@ const struct ITableIter *itable_iter(const struct ITable* const tab);
// next iterator value, NULL at end of list
const struct ITableIter *itable_next(const struct ITableIter* const iter);

// number of entries with val
size_t itable_size(const struct ITable* const tab);

/*
* Mutate
*/
Expand All @@ -63,5 +63,32 @@ const void *itable_put(const struct ITable* const tab, const uint64_t key, const
// remove key, return old val if present
const void *itable_remove(const struct ITable* const tab, const uint64_t key);

/*
* Comparison
*/

// same length, keys and vals equal in order, NULL equal compares pointers
bool itable_equal(const struct ITable* const a, const struct ITable* const b, fn_equals);

/*
* Conversion
*/

// ordered uint64_t* key pointers to table, caller frees list only
struct SList *itable_keys_slist(const struct ITable* const tab);

// ordered val pointers to table, caller frees list only
struct SList *itable_vals_slist(const struct ITable* const tab);

/*
* Info
*/

// number of entries with val
size_t itable_size(const struct ITable* const tab);

// current capacity: initial + n * grow
size_t itable_capacity(const struct ITable* const tab);

#endif // ITABLE_H

Loading
Loading