feat: Add support for window layers and pledges
Recently added in the upstream API.
This commit is contained in:
parent
9cd8883850
commit
c8a30d2580
25
README.md
25
README.md
@ -80,6 +80,31 @@ wind_set_handler(&client, event_handler, NULL);
|
||||
wind_check_for_messages(&client);
|
||||
```
|
||||
|
||||
Using special system features:
|
||||
```
|
||||
wind_client_t client;
|
||||
// Use WIND_SYSTEM_SOCKET_PATH instead of WIND_SOCKET_PATH (the calling process needs to be in the wsys group).
|
||||
wind_connect(&client, WIND_SYSTEM_SOCKET_PATH, 0);
|
||||
|
||||
// You must pledge the functionality you're going to use.
|
||||
wind_pledge(&client, wind_ExtendedLayers);
|
||||
|
||||
wind_window_t window;
|
||||
struct wind_rect rect = {
|
||||
.pos = {0, 0},
|
||||
.width = 640,
|
||||
.height = 320
|
||||
};
|
||||
|
||||
wind_create_window(&client, &window, rect);
|
||||
// Using the ExtendedLayers system functionality, move this window to the "System" layer (above all other windows).
|
||||
wind_set_layer(&client, &window, wind_System);
|
||||
|
||||
// Now that we're done, relinquish the pledges.
|
||||
wind_pledge(&client, 0);
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
libwind is free and open-source software under the [BSD-2-Clause License](LICENSE).
|
||||
|
19
src/wind.c
19
src/wind.c
@ -256,13 +256,22 @@ int wind_get_screen_dimensions(wind_client_t* client, struct wind_rect* rect)
|
||||
return result;
|
||||
}
|
||||
|
||||
int wind_set_special_window_attributes(wind_client_t* client, wind_window_t* window,
|
||||
enum wind_window_attributes attributes)
|
||||
int wind_set_window_layer(wind_client_t* client, wind_window_t* window,
|
||||
enum wind_layer layer)
|
||||
{
|
||||
struct wind_set_special_window_attributes_request request = {
|
||||
struct wind_set_window_layer_request request = {
|
||||
.window = window->id,
|
||||
.attributes = attributes,
|
||||
.layer = layer,
|
||||
};
|
||||
|
||||
return wind_send_request(client, wind_SetSpecialWindowAttributes, &request, sizeof request);
|
||||
return wind_send_request(client, wind_SetWindowLayer, &request, sizeof request);
|
||||
}
|
||||
|
||||
int wind_pledge(wind_client_t* client, int16_t pledges)
|
||||
{
|
||||
struct wind_update_pledge_request request = {
|
||||
.pledges = pledges,
|
||||
};
|
||||
|
||||
return wind_send_request(client, wind_UpdatePledge, &request, sizeof request);
|
||||
}
|
29
src/wind.h
29
src/wind.h
@ -43,7 +43,8 @@ enum wind_server_message
|
||||
wind_CloseWindow,
|
||||
wind_GetScreenRect,
|
||||
wind_SetTitlebarHeight,
|
||||
wind_SetSpecialWindowAttributes,
|
||||
wind_SetWindowLayer,
|
||||
wind_UpdatePledge,
|
||||
};
|
||||
|
||||
enum wind_client_message
|
||||
@ -95,15 +96,29 @@ struct wind_set_titlebar_height_request
|
||||
int height;
|
||||
};
|
||||
|
||||
enum wind_window_attributes
|
||||
enum wind_layer
|
||||
{
|
||||
wind_UNFOCUSEABLE = 1,
|
||||
wind_Background,
|
||||
wind_Global,
|
||||
wind_GlobalTop,
|
||||
wind_System,
|
||||
wind_Lock,
|
||||
};
|
||||
|
||||
struct wind_set_special_window_attributes_request
|
||||
struct wind_set_window_layer_request
|
||||
{
|
||||
int window;
|
||||
enum wind_window_attributes attributes;
|
||||
uint8_t layer; // enum wind_layer
|
||||
};
|
||||
|
||||
enum wind_pledge
|
||||
{
|
||||
wind_ExtendedLayers = 1,
|
||||
};
|
||||
|
||||
struct wind_update_pledge_request
|
||||
{
|
||||
int16_t pledges;
|
||||
};
|
||||
|
||||
struct wind_create_window_response
|
||||
@ -291,6 +306,7 @@ struct wind_key_event_request
|
||||
};
|
||||
|
||||
#define WIND_SOCKET_PATH "/tmp/wind.sock"
|
||||
#define WIND_SYSTEM_SOCKET_PATH "/tmp/wsys.sock"
|
||||
|
||||
int wind_connect(wind_client_t* client, const char* path, int blocking);
|
||||
int wind_send_request(wind_client_t* client, uint8_t request_id, const void* request, size_t request_size);
|
||||
@ -312,6 +328,7 @@ int wind_set_titlebar_height(wind_client_t* client, wind_window_t* window, int h
|
||||
|
||||
int wind_get_screen_dimensions(wind_client_t* client, struct wind_rect* rect);
|
||||
|
||||
int wind_set_special_window_attributes(wind_client_t* client, wind_window_t* window, enum wind_window_attributes attributes);
|
||||
int wind_set_window_layer(wind_client_t* client, wind_window_t* window, enum wind_layer layer);
|
||||
int wind_pledge(wind_client_t* client, int16_t pledges);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user