mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01:00
Merge branch 'wlroots' into feature/input
This commit is contained in:
commit
a949d7de5a
6 changed files with 57 additions and 6 deletions
|
@ -105,7 +105,7 @@ struct output_config {
|
||||||
int width, height;
|
int width, height;
|
||||||
float refresh_rate;
|
float refresh_rate;
|
||||||
int x, y;
|
int x, y;
|
||||||
int scale;
|
float scale;
|
||||||
int32_t transform;
|
int32_t transform;
|
||||||
|
|
||||||
char *background;
|
char *background;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
json_object *ipc_json_get_version();
|
json_object *ipc_json_get_version();
|
||||||
|
|
||||||
|
json_object *ipc_json_describe_container(swayc_t *c);
|
||||||
json_object *ipc_json_describe_container_recursive(swayc_t *c);
|
json_object *ipc_json_describe_container_recursive(swayc_t *c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -144,7 +144,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
char *end;
|
char *end;
|
||||||
output->scale = strtol(argv[i], &end, 10);
|
output->scale = strtof(argv[i], &end);
|
||||||
if (*end) {
|
if (*end) {
|
||||||
error = cmd_results_new(CMD_INVALID, "output",
|
error = cmd_results_new(CMD_INVALID, "output",
|
||||||
"Invalid scale.");
|
"Invalid scale.");
|
||||||
|
@ -278,7 +278,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
|
sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz "
|
||||||
"position %d,%d scale %d transform %d) (bg %s %s)",
|
"position %d,%d scale %f transform %d) (bg %s %s)",
|
||||||
output->name, output->enabled, output->width, output->height,
|
output->name, output->enabled, output->width, output->height,
|
||||||
output->refresh_rate, output->x, output->y, output->scale,
|
output->refresh_rate, output->x, output->y, output->scale,
|
||||||
output->transform, output->background, output->background_option);
|
output->transform, output->background, output->background_option);
|
||||||
|
|
|
@ -111,7 +111,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||||
set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
|
set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
|
||||||
}
|
}
|
||||||
if (oc && oc->scale > 0) {
|
if (oc && oc->scale > 0) {
|
||||||
sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale);
|
sway_log(L_DEBUG, "Set %s scale to %f", oc->name, oc->scale);
|
||||||
wlr_output_set_scale(wlr_output, oc->scale);
|
wlr_output_set_scale(wlr_output, oc->scale);
|
||||||
}
|
}
|
||||||
if (oc && oc->transform >= 0) {
|
if (oc && oc->transform >= 0) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sway/ipc-json.h"
|
#include "sway/ipc-json.h"
|
||||||
#include "sway/container.h"
|
#include "sway/container.h"
|
||||||
|
#include "sway/output.h"
|
||||||
#include <wlr/types/wlr_box.h>
|
#include <wlr/types/wlr_box.h>
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
|
|
||||||
|
@ -38,10 +39,43 @@ static void ipc_json_describe_root(swayc_t *root, json_object *object) {
|
||||||
json_object_object_add(object, "layout", json_object_new_string("splith"));
|
json_object_object_add(object, "layout", json_object_new_string("splith"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipc_json_describe_output(swayc_t *output, json_object *object) {
|
static const char *ipc_json_get_output_transform(enum wl_output_transform transform) {
|
||||||
|
switch (transform) {
|
||||||
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
||||||
|
return "normal";
|
||||||
|
case WL_OUTPUT_TRANSFORM_90:
|
||||||
|
return "90";
|
||||||
|
case WL_OUTPUT_TRANSFORM_180:
|
||||||
|
return "180";
|
||||||
|
case WL_OUTPUT_TRANSFORM_270:
|
||||||
|
return "270";
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
||||||
|
return "flipped";
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
||||||
|
return "flipped-90";
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
||||||
|
return "flipped-180";
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
||||||
|
return "flipped-270";
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ipc_json_describe_output(swayc_t *container, json_object *object) {
|
||||||
|
struct wlr_output *wlr_output = container->sway_output->wlr_output;
|
||||||
json_object_object_add(object, "type", json_object_new_string("output"));
|
json_object_object_add(object, "type", json_object_new_string("output"));
|
||||||
|
json_object_object_add(object, "active", json_object_new_boolean(true));
|
||||||
|
json_object_object_add(object, "primary", json_object_new_boolean(false));
|
||||||
|
json_object_object_add(object, "layout", json_object_new_string("output"));
|
||||||
|
json_object_object_add(object, "make", json_object_new_string(wlr_output->make));
|
||||||
|
json_object_object_add(object, "model", json_object_new_string(wlr_output->model));
|
||||||
|
json_object_object_add(object, "serial", json_object_new_string(wlr_output->serial));
|
||||||
|
json_object_object_add(object, "scale", json_object_new_double(wlr_output->scale));
|
||||||
|
json_object_object_add(object, "refresh", json_object_new_int(wlr_output->refresh));
|
||||||
|
json_object_object_add(object, "transform",
|
||||||
|
json_object_new_string(ipc_json_get_output_transform(wlr_output->transform)));
|
||||||
json_object_object_add(object, "current_workspace",
|
json_object_object_add(object, "current_workspace",
|
||||||
(output->focused) ? json_object_new_string(output->focused->name) : NULL);
|
(container->focused) ? json_object_new_string(container->focused->name) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {
|
static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {
|
||||||
|
|
|
@ -343,6 +343,22 @@ void ipc_client_handle_command(struct ipc_client *client) {
|
||||||
goto exit_cleanup;
|
goto exit_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case IPC_GET_OUTPUTS:
|
||||||
|
{
|
||||||
|
json_object *outputs = json_object_new_array();
|
||||||
|
for (int i = 0; i < root_container.children->length; ++i) {
|
||||||
|
swayc_t *container = root_container.children->items[i];
|
||||||
|
if (container->type == C_OUTPUT) {
|
||||||
|
json_object_array_add(outputs,
|
||||||
|
ipc_json_describe_container(container));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const char *json_string = json_object_to_json_string(outputs);
|
||||||
|
ipc_send_reply(client, json_string, (uint32_t) strlen(json_string));
|
||||||
|
json_object_put(outputs); // free
|
||||||
|
goto exit_cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
case IPC_GET_TREE:
|
case IPC_GET_TREE:
|
||||||
{
|
{
|
||||||
json_object *tree =
|
json_object *tree =
|
||||||
|
|
Loading…
Reference in a new issue