mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
focus: add basic follow mouse support
This commit is contained in:
parent
892e93dd84
commit
00db22e44f
5 changed files with 40 additions and 0 deletions
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
struct rcxml {
|
struct rcxml {
|
||||||
bool xdg_shell_server_side_deco;
|
bool xdg_shell_server_side_deco;
|
||||||
|
bool focus_follow_mouse;
|
||||||
|
bool raise_on_focus;
|
||||||
char *theme_name;
|
char *theme_name;
|
||||||
int corner_radius;
|
int corner_radius;
|
||||||
char *font_name_activewindow;
|
char *font_name_activewindow;
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,7 @@ void view_for_each_surface(struct view *view,
|
||||||
void view_for_each_popup_surface(struct view *view,
|
void view_for_each_popup_surface(struct view *view,
|
||||||
wlr_surface_iterator_func_t iterator, void *data);
|
wlr_surface_iterator_func_t iterator, void *data);
|
||||||
|
|
||||||
|
void desktop_set_focus_view_only(struct seat *seat, struct view *view);
|
||||||
void desktop_focus_view(struct seat *seat, struct view *view);
|
void desktop_focus_view(struct seat *seat, struct view *view);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,11 @@ entry(xmlNode *node, char *nodename, char *content)
|
||||||
fill_font(nodename, content, font_place);
|
fill_font(nodename, content, font_place);
|
||||||
} else if (!strcmp(nodename, "size.font.theme")) {
|
} else if (!strcmp(nodename, "size.font.theme")) {
|
||||||
fill_font(nodename, content, font_place);
|
fill_font(nodename, content, font_place);
|
||||||
|
} else if (!strcasecmp(nodename, "FollowMouse.focus")) {
|
||||||
|
rc.focus_follow_mouse = get_bool(content);
|
||||||
|
} else if (!strcasecmp(nodename, "RaisemOnFocus.focus")) {
|
||||||
|
rc.focus_follow_mouse = true;
|
||||||
|
rc.raise_on_focus = get_bool(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,15 @@ process_cursor_motion(struct server *server, uint32_t time)
|
||||||
uint32_t resize_edges = get_resize_edges(
|
uint32_t resize_edges = get_resize_edges(
|
||||||
view, server->seat.cursor->x, server->seat.cursor->y);
|
view, server->seat.cursor->x, server->seat.cursor->y);
|
||||||
switch (resize_edges) {
|
switch (resize_edges) {
|
||||||
|
case 0:
|
||||||
|
if (rc.focus_follow_mouse){
|
||||||
|
if (rc.raise_on_focus){
|
||||||
|
desktop_focus_view(&server->seat, view);
|
||||||
|
} else {
|
||||||
|
desktop_set_focus_view_only(&server->seat, view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case WLR_EDGE_TOP:
|
case WLR_EDGE_TOP:
|
||||||
cursor_name = "top_side";
|
cursor_name = "top_side";
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,25 @@ set_activated(struct wlr_surface *surface, bool activated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
desktop_set_focus_view_only(struct seat *seat, struct view *view)
|
||||||
|
{
|
||||||
|
if (!view || view->minimized || !view->mapped) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wlr_surface *prev_surface;
|
||||||
|
prev_surface = seat->seat->keyboard_state.focused_surface;
|
||||||
|
if (prev_surface == view->surface) {
|
||||||
|
/* Don't re-focus an already focused surface. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (prev_surface) {
|
||||||
|
set_activated(prev_surface, false);
|
||||||
|
}
|
||||||
|
set_activated(view->surface, true);
|
||||||
|
seat_focus_surface(seat, view->surface);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
desktop_focus_view(struct seat *seat, struct view *view)
|
desktop_focus_view(struct seat *seat, struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -85,6 +104,10 @@ desktop_focus_view(struct seat *seat, struct view *view)
|
||||||
prev_surface = seat->seat->keyboard_state.focused_surface;
|
prev_surface = seat->seat->keyboard_state.focused_surface;
|
||||||
if (prev_surface == view->surface) {
|
if (prev_surface == view->surface) {
|
||||||
/* Don't re-focus an already focused surface. */
|
/* Don't re-focus an already focused surface. */
|
||||||
|
move_to_front(view);
|
||||||
|
#if HAVE_XWAYLAND
|
||||||
|
move_xwayland_sub_views_to_front(view);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (prev_surface) {
|
if (prev_surface) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue