mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 01:41:30 +00:00
Merge pull request #34 from taiyu-len/master
fixed fullscreen & focusing
This commit is contained in:
commit
2732c40813
|
@ -286,6 +286,14 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
|
||||||
swayc_t *container = get_focused_container(&root_container);
|
swayc_t *container = get_focused_container(&root_container);
|
||||||
bool current = (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) > 0;
|
bool current = (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) > 0;
|
||||||
wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current);
|
wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current);
|
||||||
|
//Resize workspace if going from fullscreen -> notfullscreen
|
||||||
|
//otherwise just resize container
|
||||||
|
if (current) {
|
||||||
|
while (container->type != C_WORKSPACE) {
|
||||||
|
container = container->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Only resize container when going into fullscreen
|
||||||
arrange_windows(container, -1, -1);
|
arrange_windows(container, -1, -1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,15 +28,19 @@ static bool pointer_test(swayc_t *view, void *_origin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void focus_pointer(void) {
|
swayc_t *focus_pointer(void) {
|
||||||
swayc_t *focused = find_container(&root_container, pointer_test, &mouse_origin);
|
swayc_t *focused = get_focused_container(&root_container);
|
||||||
if (focused) {
|
if (!(wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN)) {
|
||||||
sway_log(L_DEBUG, "Switching focus to %p", focused);
|
swayc_t *pointer = find_container(&root_container, pointer_test, &mouse_origin);
|
||||||
unfocus_all(&root_container);
|
if (pointer && focused != pointer) {
|
||||||
focus_view(focused);
|
unfocus_all(&root_container);
|
||||||
} else {
|
focus_view(pointer);
|
||||||
focus_view(active_workspace);
|
} else if (!focused){
|
||||||
|
focus_view(active_workspace);
|
||||||
|
}
|
||||||
|
focused = pointer;
|
||||||
}
|
}
|
||||||
|
return focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_output_created(wlc_handle output) {
|
static bool handle_output_created(wlc_handle output) {
|
||||||
|
@ -82,16 +86,21 @@ static void handle_output_focused(wlc_handle output, bool focus) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_view_created(wlc_handle handle) {
|
static bool handle_view_created(wlc_handle handle) {
|
||||||
swayc_t *container = get_focused_container(&root_container);
|
swayc_t *focused = get_focused_container(&root_container);
|
||||||
swayc_t *view = new_view(container, handle);
|
swayc_t *view = new_view(focused, handle);
|
||||||
unfocus_all(&root_container);
|
|
||||||
if (view) {
|
if (view) {
|
||||||
|
unfocus_all(&root_container);
|
||||||
focus_view(view);
|
focus_view(view);
|
||||||
arrange_windows(view->parent, -1, -1);
|
arrange_windows(view->parent, -1, -1);
|
||||||
} else { //Unmanaged view
|
} else { //Unmanaged view
|
||||||
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
||||||
wlc_view_focus(handle);
|
wlc_view_focus(handle);
|
||||||
}
|
}
|
||||||
|
if (wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) {
|
||||||
|
unfocus_all(&root_container);
|
||||||
|
focus_view(focused);
|
||||||
|
arrange_windows(focused, -1, -1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,28 +198,16 @@ static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct w
|
||||||
if (!config->focus_follows_mouse) {
|
if (!config->focus_follows_mouse) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
swayc_t *c = find_container(&root_container, pointer_test, (void *)origin);
|
focus_pointer();
|
||||||
swayc_t *focused = get_focused_container(&root_container);
|
|
||||||
if (c && c != focused) {
|
|
||||||
sway_log(L_DEBUG, "Switching focus to %p", c);
|
|
||||||
unfocus_all(&root_container);
|
|
||||||
focus_view(c);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
|
static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers,
|
||||||
uint32_t button, enum wlc_button_state state) {
|
uint32_t button, enum wlc_button_state state) {
|
||||||
|
swayc_t *focused = get_focused_container(&root_container);
|
||||||
if (state == WLC_BUTTON_STATE_PRESSED) {
|
if (state == WLC_BUTTON_STATE_PRESSED) {
|
||||||
swayc_t *c = find_container(&root_container, pointer_test, &mouse_origin);
|
swayc_t *pointer = focus_pointer();
|
||||||
swayc_t *focused = get_focused_container(&root_container);
|
return !(pointer && pointer != focused);
|
||||||
if (c && c != focused) {
|
|
||||||
sway_log(L_DEBUG, "Switching focus to %p", c);
|
|
||||||
unfocus_all(&root_container);
|
|
||||||
focus_view(c);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
extern struct wlc_interface interface;
|
extern struct wlc_interface interface;
|
||||||
|
|
||||||
//set focus to current pointer location
|
//set focus to current pointer location and return focused container
|
||||||
void focus_pointer(void);
|
swayc_t *focus_pointer(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue