mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-03 06:46:38 -04:00
Merge branch 'DreamMaoMao:main' into workspace10
This commit is contained in:
commit
c613e34bee
21 changed files with 662 additions and 156 deletions
|
|
@ -83,6 +83,9 @@ setclient_coordinate_center(Client *c, Monitor *tm, struct wlr_box geom,
|
|||
int32_t len = 0;
|
||||
Monitor *m = tm ? tm : selmon;
|
||||
|
||||
if (!m)
|
||||
return geom;
|
||||
|
||||
uint32_t cbw = check_hit_no_border(c) ? c->bw : 0;
|
||||
|
||||
if (!c->no_force_center && m) {
|
||||
|
|
|
|||
|
|
@ -100,10 +100,6 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
|||
surface = wlr_scene_surface_try_from_buffer(
|
||||
wlr_scene_buffer_from_node(node))
|
||||
->surface;
|
||||
else if (node->type == WLR_SCENE_NODE_RECT) {
|
||||
surface = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* start from the topmost layer,
|
||||
find a sureface that can be focused by pointer,
|
||||
|
|
@ -119,6 +115,13 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
|||
l = pnode->data;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->type == WLR_SCENE_NODE_RECT) {
|
||||
if (c) {
|
||||
surface = client_surface(c);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (psurface)
|
||||
|
|
|
|||
|
|
@ -96,3 +96,81 @@ Monitor *xytomon(double x, double y) {
|
|||
struct wlr_output *o = wlr_output_layout_output_at(output_layout, x, y);
|
||||
return o ? o->data : NULL;
|
||||
}
|
||||
|
||||
Monitor *get_monitor_nearest_to(int32_t lx, int32_t ly) {
|
||||
double closest_x, closest_y;
|
||||
wlr_output_layout_closest_point(output_layout, NULL, lx, ly, &closest_x,
|
||||
&closest_y);
|
||||
|
||||
return output_from_wlr_output(
|
||||
wlr_output_layout_output_at(output_layout, closest_x, closest_y));
|
||||
}
|
||||
|
||||
bool match_monitor_spec(char *spec, Monitor *m) {
|
||||
if (!spec || !m)
|
||||
return false;
|
||||
|
||||
// if the spec does not contain a colon, treat it as a match on the monitor
|
||||
// name
|
||||
if (strchr(spec, ':') == NULL) {
|
||||
return regex_match(spec, m->wlr_output->name);
|
||||
}
|
||||
|
||||
char *spec_copy = strdup(spec);
|
||||
if (!spec_copy)
|
||||
return false;
|
||||
|
||||
char *name_rule = NULL;
|
||||
char *make_rule = NULL;
|
||||
char *model_rule = NULL;
|
||||
char *serial_rule = NULL;
|
||||
|
||||
char *token = strtok(spec_copy, "&&");
|
||||
while (token) {
|
||||
char *colon = strchr(token, ':');
|
||||
if (colon) {
|
||||
*colon = '\0';
|
||||
char *key = token;
|
||||
char *value = colon + 1;
|
||||
|
||||
if (strcmp(key, "name") == 0)
|
||||
name_rule = strdup(value);
|
||||
else if (strcmp(key, "make") == 0)
|
||||
make_rule = strdup(value);
|
||||
else if (strcmp(key, "model") == 0)
|
||||
model_rule = strdup(value);
|
||||
else if (strcmp(key, "serial") == 0)
|
||||
serial_rule = strdup(value);
|
||||
}
|
||||
token = strtok(NULL, "&&");
|
||||
}
|
||||
|
||||
bool match = true;
|
||||
|
||||
if (name_rule) {
|
||||
if (!regex_match(name_rule, m->wlr_output->name))
|
||||
match = false;
|
||||
}
|
||||
if (make_rule) {
|
||||
if (!m->wlr_output->make || strcmp(make_rule, m->wlr_output->make) != 0)
|
||||
match = false;
|
||||
}
|
||||
if (model_rule) {
|
||||
if (!m->wlr_output->model ||
|
||||
strcmp(model_rule, m->wlr_output->model) != 0)
|
||||
match = false;
|
||||
}
|
||||
if (serial_rule) {
|
||||
if (!m->wlr_output->serial ||
|
||||
strcmp(serial_rule, m->wlr_output->serial) != 0)
|
||||
match = false;
|
||||
}
|
||||
|
||||
free(spec_copy);
|
||||
free(name_rule);
|
||||
free(make_rule);
|
||||
free(model_rule);
|
||||
free(serial_rule);
|
||||
|
||||
return match;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue