forked from external/yambar
bar: add bar->output_name(), returns the name of the output we’re on
This commit is contained in:
parent
96a35e5304
commit
74016d7d33
5 changed files with 29 additions and 0 deletions
|
@ -14,4 +14,5 @@ struct backend {
|
|||
void (*commit)(const struct bar *bar);
|
||||
void (*refresh)(const struct bar *bar);
|
||||
void (*set_cursor)(struct bar *bar, const char *cursor);
|
||||
const char *(*output_name)(const struct bar *bar);
|
||||
};
|
||||
|
|
|
@ -162,6 +162,13 @@ set_cursor(struct bar *bar, const char *cursor)
|
|||
b->backend.iface->set_cursor(bar, cursor);
|
||||
}
|
||||
|
||||
static const char *
|
||||
output_name(const struct bar *bar)
|
||||
{
|
||||
const struct private *b = bar->private;
|
||||
return b->backend.iface->output_name(bar);
|
||||
}
|
||||
|
||||
static void
|
||||
on_mouse(struct bar *_bar, enum mouse_event event, enum mouse_button btn,
|
||||
int x, int y)
|
||||
|
@ -456,6 +463,7 @@ bar_new(const struct bar_config *config)
|
|||
bar->destroy = &destroy;
|
||||
bar->refresh = &refresh;
|
||||
bar->set_cursor = &set_cursor;
|
||||
bar->output_name = &output_name;
|
||||
|
||||
for (size_t i = 0; i < priv->left.count; i++)
|
||||
priv->left.mods[i]->bar = bar;
|
||||
|
|
|
@ -12,6 +12,8 @@ struct bar {
|
|||
|
||||
void (*refresh)(const struct bar *bar);
|
||||
void (*set_cursor)(struct bar *bar, const char *cursor);
|
||||
|
||||
const char *(*output_name)(const struct bar *bar);
|
||||
};
|
||||
|
||||
enum bar_location { BAR_TOP, BAR_BOTTOM };
|
||||
|
|
|
@ -1308,6 +1308,15 @@ set_cursor(struct bar *_bar, const char *cursor)
|
|||
update_cursor_surface(backend, seat);
|
||||
}
|
||||
|
||||
static const char *
|
||||
output_name(const struct bar *_bar)
|
||||
{
|
||||
const struct private *bar = _bar->private;
|
||||
const struct wayland_backend *backend = bar->backend.data;
|
||||
|
||||
return backend->monitor != NULL ? backend->monitor->name : NULL;
|
||||
}
|
||||
|
||||
const struct backend wayland_backend_iface = {
|
||||
.setup = &setup,
|
||||
.cleanup = &cleanup,
|
||||
|
@ -1315,4 +1324,5 @@ const struct backend wayland_backend_iface = {
|
|||
.commit = &commit,
|
||||
.refresh = &refresh,
|
||||
.set_cursor = &set_cursor,
|
||||
.output_name = &output_name,
|
||||
};
|
||||
|
|
|
@ -462,6 +462,13 @@ set_cursor(struct bar *_bar, const char *cursor)
|
|||
backend->conn, backend->win, XCB_CW_CURSOR, &backend->cursor);
|
||||
}
|
||||
|
||||
static const char *
|
||||
output_name(const struct bar *_bar)
|
||||
{
|
||||
/* Not implemented */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct backend xcb_backend_iface = {
|
||||
.setup = &setup,
|
||||
.cleanup = &cleanup,
|
||||
|
@ -469,4 +476,5 @@ const struct backend xcb_backend_iface = {
|
|||
.commit = &commit,
|
||||
.refresh = &refresh,
|
||||
.set_cursor = &set_cursor,
|
||||
.output_name = &output_name,
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue