AtlatestRepositorysigil-wm
1
/* SPDX-License-Identifier: BSD-3-Clause2
* Explicit session escape cache and copied activation provenance. */3
static bool configure_session_switches(struct server *s,const int64_t *words,size_t count) {4
if(count<1 || words[0]<0 || words[0]>12 || count!=1+(size_t)words[0]*2) return false;5
for(int index=0;index<words[0];index++) {6
int64_t symbol=words[1+index*2],vt=words[2+index*2];7
if(symbol<1 || symbol>UINT32_MAX || vt<1 || vt>63) return false;8
for(int previous=0;previous<index;previous++)9
if(words[1+previous*2]==symbol) return false;10
}11
for(int index=0;index<words[0];index++) {12
s->session_switches[index].symbol=words[1+index*2];13
s->session_switches[index].vt=words[2+index*2];14
}15
s->session_switch_count=words[0];16
return true;17
}18
static bool session_key(struct keyboard *keyboard,struct wlr_keyboard_key_event *event) {19
struct server *s=keyboard->server;20
if(event->keycode>=MAX_KEYS) return false;21
if(!event->state && keyboard->session_consumed[event->keycode]) {22
keyboard->session_consumed[event->keycode]=false;23
return true;24
}25
if(!s->session || keyboard->is_virtual || !event->state || !keyboard->native->xkb_state) return false;26
const xkb_keysym_t *symbols;27
int count=xkb_state_key_get_syms(keyboard->native->xkb_state,event->keycode+8,&symbols);28
for(int index=0;index<count;index++) {29
for(unsigned configured=0;configured<s->session_switch_count;configured++) {30
if(symbols[index]!=s->session_switches[configured].symbol) continue;31
keyboard->session_consumed[event->keycode]=true;32
bool applied=wlr_session_change_vt(s->session,s->session_switches[configured].vt);33
EVENT(114,keyboard->id,s->session_switches[configured].vt,applied);34
return true;35
}36
}37
return false;38
}39
static void activation_requested(struct wl_listener *listener,void *data) {40
struct server *s=wl_container_of(listener,s,activation_request);41
const struct wlr_xdg_activation_v1_request_activate_event *event=data;42
uint64_t target=window_for_surface(s,event->surface);43
if(s->stopping || !target || !event->surface->mapped) return;44
bool seat=event->token->seat==s->seat;45
EVENT(115,target,window_for_surface(s,event->token->surface),seat,46
seat ? event->token->serial : 0,s->generation);47
}