AtlatestRepositorysigil-wm
1
/* SPDX-License-Identifier: BSD-3-Clause2
* The backend operation is replaced before compiling the real native handler. */3
#define wlr_session_change_vt probe_change_vt4
#include "../src/c/host.c"5
#undef wlr_session_change_vt6
#include <assert.h>7
static unsigned switches,last_vt;8
bool probe_change_vt(struct wlr_session *session,unsigned vt) {9
assert(session==(struct wlr_session *)(uintptr_t)1);10
switches++;11
last_vt=vt;12
return true;13
}14
int main(void) {15
struct server server={.session=(struct wlr_session *)(uintptr_t)1};16
struct wlr_keyboard native;17
wlr_keyboard_init(&native,&synthetic_impl,"Session probe");18
struct xkb_context *context=xkb_context_new(XKB_CONTEXT_NO_FLAGS);19
struct xkb_rule_names names={.layout="us"};20
struct xkb_keymap *keymap=xkb_keymap_new_from_names(context,&names,XKB_KEYMAP_COMPILE_NO_FLAGS);21
assert(keymap && wlr_keyboard_set_keymap(&native,keymap));22
xkb_keymap_unref(keymap);23
xkb_context_unref(context);24
bridge.event_fd=eventfd(0,EFD_NONBLOCK|EFD_CLOEXEC);25
assert(bridge.event_fd>=0);26
struct keyboard owner={.server=&server,.native=&native,.id=9};27
struct wlr_keyboard_key_event event={.keycode=59,.state=WL_KEYBOARD_KEY_STATE_PRESSED};28
const int64_t selected[]={1,XKB_KEY_F1,9};29
assert(configure_session_switches(&server,selected,3));30
assert(session_key(&owner,&event) && switches==1 && last_vt==9);31
event.state=WL_KEYBOARD_KEY_STATE_RELEASED;32
assert(session_key(&owner,&event) && switches==1);33
event.state=WL_KEYBOARD_KEY_STATE_PRESSED;34
owner.is_virtual=true;35
assert(!session_key(&owner,&event) && switches==1);36
owner.is_virtual=false;37
server.session=NULL;38
assert(!session_key(&owner,&event) && switches==1);39
server.session=(struct wlr_session *)(uintptr_t)1;40
const int64_t duplicate[]={2,XKB_KEY_F1,2,XKB_KEY_F1,3};41
assert(!configure_session_switches(&server,duplicate,5));42
const int64_t invalid[]={1,XKB_KEY_F1,64};43
assert(!configure_session_switches(&server,invalid,3));44
assert(server.session_switch_count==1 && server.session_switches[0].vt==9);45
const int64_t empty[]={0};46
assert(configure_session_switches(&server,empty,1));47
assert(!session_key(&owner,&event) && switches==1);48
close(bridge.event_fd);49
wlr_keyboard_finish(&native);50
puts("SESSION_SWITCH=PASS explicit cache physical-only paired release no-session invalid atomic replacement backend stub");51
return 0;52
}