forked from external/yambar
Apply "clang-format" preferences globally
This commit is contained in:
parent
d841aeeecd
commit
b85ba99980
64 changed files with 1868 additions and 2678 deletions
|
@ -1,7 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
|||
#define LOG_MODULE "foreign-toplevel"
|
||||
#define LOG_ENABLE_DBG 0
|
||||
#include "../log.h"
|
||||
#include "../plugin.h"
|
||||
#include "../particles/dynlist.h"
|
||||
#include "../plugin.h"
|
||||
|
||||
#include "wlr-foreign-toplevel-management-unstable-v1.h"
|
||||
#include "xdg-output-unstable-v1.h"
|
||||
|
@ -46,7 +46,8 @@ struct toplevel {
|
|||
tll(const struct output *) outputs;
|
||||
};
|
||||
|
||||
struct private {
|
||||
struct private
|
||||
{
|
||||
struct particle *template;
|
||||
uint32_t manager_wl_name;
|
||||
struct zwlr_foreign_toplevel_manager_v1 *manager;
|
||||
|
@ -110,7 +111,8 @@ content(struct module *mod)
|
|||
|
||||
const char *current_output = mod->bar->output_name(mod->bar);
|
||||
|
||||
tll_foreach(m->toplevels, it) {
|
||||
tll_foreach(m->toplevels, it)
|
||||
{
|
||||
const struct toplevel *top = &it->item;
|
||||
|
||||
bool show = false;
|
||||
|
@ -118,11 +120,10 @@ content(struct module *mod)
|
|||
if (m->all_monitors)
|
||||
show = true;
|
||||
else if (current_output != NULL) {
|
||||
tll_foreach(top->outputs, it2) {
|
||||
tll_foreach(top->outputs, it2)
|
||||
{
|
||||
const struct output *output = it2->item;
|
||||
if (output->name != NULL &&
|
||||
strcmp(output->name, current_output) == 0)
|
||||
{
|
||||
if (output->name != NULL && strcmp(output->name, current_output) == 0) {
|
||||
show = true;
|
||||
break;
|
||||
}
|
||||
|
@ -158,22 +159,18 @@ verify_iface_version(const char *iface, uint32_t version, uint32_t wanted)
|
|||
if (version >= wanted)
|
||||
return true;
|
||||
|
||||
LOG_ERR("%s: need interface version %u, but compositor only implements %u",
|
||||
iface, wanted, version);
|
||||
LOG_ERR("%s: need interface version %u, but compositor only implements %u", iface, wanted, version);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_logical_position(void *data,
|
||||
struct zxdg_output_v1 *xdg_output,
|
||||
int32_t x, int32_t y)
|
||||
xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, int32_t x, int32_t y)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
int32_t width, int32_t height)
|
||||
xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -183,8 +180,7 @@ xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
|
|||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
const char *name)
|
||||
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name)
|
||||
{
|
||||
struct output *output = data;
|
||||
struct module *mod = output->mod;
|
||||
|
@ -198,8 +194,7 @@ xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
|
|||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
const char *description)
|
||||
xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, const char *description)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -238,8 +233,7 @@ app_id(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, const char *a
|
|||
}
|
||||
|
||||
static void
|
||||
output_enter(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
||||
struct wl_output *wl_output)
|
||||
output_enter(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, struct wl_output *wl_output)
|
||||
{
|
||||
struct toplevel *top = data;
|
||||
struct module *mod = top->mod;
|
||||
|
@ -248,7 +242,8 @@ output_enter(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
|||
mtx_lock(&mod->lock);
|
||||
|
||||
const struct output *output = NULL;
|
||||
tll_foreach(m->outputs, it) {
|
||||
tll_foreach(m->outputs, it)
|
||||
{
|
||||
if (it->item.wl_output == wl_output) {
|
||||
output = &it->item;
|
||||
break;
|
||||
|
@ -260,7 +255,8 @@ output_enter(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
|||
goto out;
|
||||
}
|
||||
|
||||
tll_foreach(top->outputs, it) {
|
||||
tll_foreach(top->outputs, it)
|
||||
{
|
||||
if (it->item == output) {
|
||||
LOG_ERR("output-enter event on output we're already on");
|
||||
goto out;
|
||||
|
@ -275,8 +271,7 @@ out:
|
|||
}
|
||||
|
||||
static void
|
||||
output_leave(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
||||
struct wl_output *wl_output)
|
||||
output_leave(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, struct wl_output *wl_output)
|
||||
{
|
||||
struct toplevel *top = data;
|
||||
struct module *mod = top->mod;
|
||||
|
@ -285,7 +280,8 @@ output_leave(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
|||
mtx_lock(&mod->lock);
|
||||
|
||||
const struct output *output = NULL;
|
||||
tll_foreach(m->outputs, it) {
|
||||
tll_foreach(m->outputs, it)
|
||||
{
|
||||
if (it->item.wl_output == wl_output) {
|
||||
output = &it->item;
|
||||
break;
|
||||
|
@ -298,10 +294,10 @@ output_leave(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
|||
}
|
||||
|
||||
bool output_removed = false;
|
||||
tll_foreach(top->outputs, it) {
|
||||
tll_foreach(top->outputs, it)
|
||||
{
|
||||
if (it->item == output) {
|
||||
LOG_DBG("unmapped: %s:%s from %s",
|
||||
top->app_id, top->title, output->name);
|
||||
LOG_DBG("unmapped: %s:%s from %s", top->app_id, top->title, output->name);
|
||||
tll_remove(top->outputs, it);
|
||||
output_removed = true;
|
||||
break;
|
||||
|
@ -318,8 +314,7 @@ out:
|
|||
}
|
||||
|
||||
static void
|
||||
state(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
||||
struct wl_array *states)
|
||||
state(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, struct wl_array *states)
|
||||
{
|
||||
struct toplevel *top = data;
|
||||
|
||||
|
@ -329,12 +324,21 @@ state(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle,
|
|||
bool fullscreen = false;
|
||||
|
||||
enum zwlr_foreign_toplevel_handle_v1_state *state;
|
||||
wl_array_for_each(state, states) {
|
||||
wl_array_for_each(state, states)
|
||||
{
|
||||
switch (*state) {
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED: maximized = true; break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED: minimized = true; break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED: activated = true; break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN: fullscreen = true; break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MAXIMIZED:
|
||||
maximized = true;
|
||||
break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_MINIMIZED:
|
||||
minimized = true;
|
||||
break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED:
|
||||
activated = true;
|
||||
break;
|
||||
case ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN:
|
||||
fullscreen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +368,8 @@ closed(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle)
|
|||
struct private *m = mod->private;
|
||||
|
||||
mtx_lock(&mod->lock);
|
||||
tll_foreach(m->toplevels, it) {
|
||||
tll_foreach(m->toplevels, it)
|
||||
{
|
||||
if (it->item.handle == handle) {
|
||||
toplevel_free(top);
|
||||
tll_remove(m->toplevels, it);
|
||||
|
@ -378,9 +383,7 @@ closed(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle)
|
|||
}
|
||||
|
||||
static void
|
||||
parent(void *data,
|
||||
struct zwlr_foreign_toplevel_handle_v1 *handle,
|
||||
struct zwlr_foreign_toplevel_handle_v1 *parent)
|
||||
parent(void *data, struct zwlr_foreign_toplevel_handle_v1 *handle, struct zwlr_foreign_toplevel_handle_v1 *parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -396,9 +399,7 @@ static const struct zwlr_foreign_toplevel_handle_v1_listener toplevel_listener =
|
|||
};
|
||||
|
||||
static void
|
||||
toplevel(void *data,
|
||||
struct zwlr_foreign_toplevel_manager_v1 *manager,
|
||||
struct zwlr_foreign_toplevel_handle_v1 *handle)
|
||||
toplevel(void *data, struct zwlr_foreign_toplevel_manager_v1 *manager, struct zwlr_foreign_toplevel_handle_v1 *handle)
|
||||
{
|
||||
struct module *mod = data;
|
||||
struct private *m = mod->private;
|
||||
|
@ -412,15 +413,13 @@ toplevel(void *data,
|
|||
{
|
||||
tll_push_back(m->toplevels, toplevel);
|
||||
|
||||
zwlr_foreign_toplevel_handle_v1_add_listener(
|
||||
handle, &toplevel_listener, &tll_back(m->toplevels));
|
||||
zwlr_foreign_toplevel_handle_v1_add_listener(handle, &toplevel_listener, &tll_back(m->toplevels));
|
||||
}
|
||||
mtx_unlock(&mod->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
finished(void *data,
|
||||
struct zwlr_foreign_toplevel_manager_v1 *manager)
|
||||
finished(void *data, struct zwlr_foreign_toplevel_manager_v1 *manager)
|
||||
{
|
||||
struct module *mod = data;
|
||||
struct private *m = mod->private;
|
||||
|
@ -445,15 +444,12 @@ output_xdg_output(struct output *output)
|
|||
if (output->xdg_output != NULL)
|
||||
return;
|
||||
|
||||
output->xdg_output = zxdg_output_manager_v1_get_xdg_output(
|
||||
m->xdg_output_manager, output->wl_output);
|
||||
zxdg_output_v1_add_listener(
|
||||
output->xdg_output, &xdg_output_listener, output);
|
||||
output->xdg_output = zxdg_output_manager_v1_get_xdg_output(m->xdg_output_manager, output->wl_output);
|
||||
zxdg_output_v1_add_listener(output->xdg_output, &xdg_output_listener, output);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface, uint32_t version)
|
||||
handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
|
||||
{
|
||||
struct module *mod = data;
|
||||
struct private *m = mod->private;
|
||||
|
@ -473,8 +469,7 @@ handle_global(void *data, struct wl_registry *registry,
|
|||
struct output output = {
|
||||
.mod = mod,
|
||||
.wl_name = name,
|
||||
.wl_output = wl_registry_bind(
|
||||
registry, name, &wl_output_interface, required),
|
||||
.wl_output = wl_registry_bind(registry, name, &wl_output_interface, required),
|
||||
};
|
||||
|
||||
mtx_lock(&mod->lock);
|
||||
|
@ -488,12 +483,10 @@ handle_global(void *data, struct wl_registry *registry,
|
|||
if (!verify_iface_version(interface, version, required))
|
||||
return;
|
||||
|
||||
m->xdg_output_manager = wl_registry_bind(
|
||||
registry, name, &zxdg_output_manager_v1_interface, required);
|
||||
m->xdg_output_manager = wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, required);
|
||||
|
||||
mtx_lock(&mod->lock);
|
||||
tll_foreach(m->outputs, it)
|
||||
output_xdg_output(&it->item);
|
||||
tll_foreach(m->outputs, it) output_xdg_output(&it->item);
|
||||
mtx_unlock(&mod->lock);
|
||||
}
|
||||
}
|
||||
|
@ -506,16 +499,19 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
|
|||
|
||||
mtx_lock(&mod->lock);
|
||||
|
||||
tll_foreach(m->outputs, it) {
|
||||
tll_foreach(m->outputs, it)
|
||||
{
|
||||
const struct output *output = &it->item;
|
||||
if (output->wl_name == name) {
|
||||
|
||||
/* Loop all toplevels */
|
||||
tll_foreach(m->toplevels, it2) {
|
||||
tll_foreach(m->toplevels, it2)
|
||||
{
|
||||
|
||||
/* And remove this output from their list of tracked
|
||||
* outputs */
|
||||
tll_foreach(it2->item.outputs, it3) {
|
||||
tll_foreach(it2->item.outputs, it3)
|
||||
{
|
||||
if (it3->item == output) {
|
||||
tll_remove(it2->item.outputs, it3);
|
||||
break;
|
||||
|
@ -551,9 +547,8 @@ run(struct module *mod)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if ((registry = wl_display_get_registry(display)) == NULL ||
|
||||
wl_registry_add_listener(registry, ®istry_listener, mod) != 0)
|
||||
{
|
||||
if ((registry = wl_display_get_registry(display)) == NULL
|
||||
|| wl_registry_add_listener(registry, ®istry_listener, mod) != 0) {
|
||||
LOG_ERR("failed to get Wayland registry");
|
||||
goto out;
|
||||
}
|
||||
|
@ -561,18 +556,14 @@ run(struct module *mod)
|
|||
wl_display_roundtrip(display);
|
||||
|
||||
if (m->manager_wl_name == 0) {
|
||||
LOG_ERR(
|
||||
"compositor does not implement the foreign-toplevel-manager interface");
|
||||
LOG_ERR("compositor does not implement the foreign-toplevel-manager interface");
|
||||
goto out;
|
||||
}
|
||||
|
||||
m->manager = wl_registry_bind(
|
||||
registry, m->manager_wl_name,
|
||||
&zwlr_foreign_toplevel_manager_v1_interface,
|
||||
required_manager_interface_version);
|
||||
m->manager = wl_registry_bind(registry, m->manager_wl_name, &zwlr_foreign_toplevel_manager_v1_interface,
|
||||
required_manager_interface_version);
|
||||
|
||||
zwlr_foreign_toplevel_manager_v1_add_listener(
|
||||
m->manager, &manager_listener, mod);
|
||||
zwlr_foreign_toplevel_manager_v1_add_listener(m->manager, &manager_listener, mod);
|
||||
|
||||
while (true) {
|
||||
wl_display_flush(display);
|
||||
|
@ -606,12 +597,14 @@ run(struct module *mod)
|
|||
}
|
||||
|
||||
out:
|
||||
tll_foreach(m->toplevels, it) {
|
||||
tll_foreach(m->toplevels, it)
|
||||
{
|
||||
toplevel_free(&it->item);
|
||||
tll_remove(m->toplevels, it);
|
||||
}
|
||||
|
||||
tll_foreach(m->outputs, it) {
|
||||
tll_foreach(m->outputs, it)
|
||||
{
|
||||
output_free(&it->item);
|
||||
tll_remove(m->outputs, it);
|
||||
}
|
||||
|
@ -649,9 +642,7 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
|
|||
const struct yml_node *c = yml_get_value(node, "content");
|
||||
const struct yml_node *all_monitors = yml_get_value(node, "all-monitors");
|
||||
|
||||
return ftop_new(
|
||||
conf_to_particle(c, inherited),
|
||||
all_monitors != NULL ? yml_value_as_bool(all_monitors) : false);
|
||||
return ftop_new(conf_to_particle(c, inherited), all_monitors != NULL ? yml_value_as_bool(all_monitors) : false);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue