mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 14:45:58 +01:00
Spawn views on last active output
This commit is contained in:
parent
c1eff3d3af
commit
1e0e73efaa
5 changed files with 24 additions and 8 deletions
|
@ -1,8 +1,6 @@
|
|||
#ifndef _ROOTSTON_SEAT_H
|
||||
#define _ROOTSTON_SEAT_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
|
||||
#include "rootston/input.h"
|
||||
#include "rootston/keyboard.h"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef WLR_TYPES_WLR_SEAT_H
|
||||
#define WLR_TYPES_WLR_SEAT_H
|
||||
|
||||
#include <time.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
|
@ -109,6 +109,7 @@ struct wlr_seat {
|
|||
struct wl_list clients;
|
||||
char *name;
|
||||
uint32_t capabilities;
|
||||
struct timespec last_event;
|
||||
|
||||
struct wlr_data_device *data_device; // TODO needed?
|
||||
struct wlr_data_source *selection_source;
|
||||
|
|
|
@ -165,9 +165,22 @@ bool view_center(struct roots_view *view) {
|
|||
view_get_box(view, &box);
|
||||
|
||||
struct roots_desktop *desktop = view->desktop;
|
||||
struct roots_input *input = desktop->server->input;
|
||||
struct roots_seat *seat = NULL, *_seat;
|
||||
wl_list_for_each(_seat, &input->seats, link) {
|
||||
if (!seat || (seat->seat->last_event.tv_sec > _seat->seat->last_event.tv_sec &&
|
||||
seat->seat->last_event.tv_nsec > _seat->seat->last_event.tv_nsec)) {
|
||||
seat = _seat;
|
||||
}
|
||||
}
|
||||
if (!seat) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wlr_output *output =
|
||||
wlr_output_layout_get_center_output(desktop->layout);
|
||||
wlr_output_layout_output_at(desktop->layout,
|
||||
seat->cursor->cursor->x,
|
||||
seat->cursor->cursor->y);
|
||||
if (!output) {
|
||||
// empty layout
|
||||
return false;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#include <wayland-server.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "rootston/xcursor.h"
|
||||
#include "rootston/input.h"
|
||||
#include "rootston/seat.h"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
|
@ -574,12 +575,14 @@ void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
|
|||
|
||||
void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time,
|
||||
double sx, double sy) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
||||
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
|
||||
grab->interface->motion(grab, time, sx, sy);
|
||||
}
|
||||
|
||||
uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
|
||||
uint32_t time, uint32_t button, uint32_t state) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
||||
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
if (wlr_seat->pointer_state.button_count == 0) {
|
||||
wlr_seat->pointer_state.grab_button = button;
|
||||
|
@ -602,6 +605,7 @@ uint32_t wlr_seat_pointer_notify_button(struct wlr_seat *wlr_seat,
|
|||
|
||||
void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||
enum wlr_axis_orientation orientation, double value) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &wlr_seat->last_event);
|
||||
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
|
||||
grab->interface->axis(grab, time, orientation, value);
|
||||
}
|
||||
|
@ -804,12 +808,14 @@ void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) {
|
|||
}
|
||||
|
||||
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
||||
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
||||
grab->interface->modifiers(grab);
|
||||
}
|
||||
|
||||
void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
||||
uint32_t key, uint32_t state) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
||||
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
||||
grab->interface->key(grab, time, key, state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue