Lines Matching refs:b
18 #define CONST_MAX5(a, b, c, d, e) CONST_MAX(CONST_MAX(a, b), CONST_MAX(CONST_MAX(c, d), e)) argument
33 Button *b; in button_new() local
38 b = new0(Button, 1); in button_new()
39 if (!b) in button_new()
42 b->name = strdup(name); in button_new()
43 if (!b->name) in button_new()
44 return mfree(b); in button_new()
46 if (hashmap_put(m->buttons, b->name, b) < 0) { in button_new()
47 free(b->name); in button_new()
48 return mfree(b); in button_new()
51 b->manager = m; in button_new()
52 b->fd = -1; in button_new()
54 return b; in button_new()
57 void button_free(Button *b) { in button_free() argument
58 assert(b); in button_free()
60 hashmap_remove(b->manager->buttons, b->name); in button_free()
62 sd_event_source_unref(b->io_event_source); in button_free()
63 sd_event_source_unref(b->check_event_source); in button_free()
65 asynchronous_close(b->fd); in button_free()
67 free(b->name); in button_free()
68 free(b->seat); in button_free()
69 free(b); in button_free()
72 int button_set_seat(Button *b, const char *sn) { in button_set_seat() argument
73 assert(b); in button_set_seat()
75 return free_and_strdup(&b->seat, sn); in button_set_seat()
96 Button *b = userdata; in button_recheck() local
98 assert(b); in button_recheck()
99 assert(b->lid_closed); in button_recheck()
101 button_lid_switch_handle_action(b->manager, false); in button_recheck()
105 static int button_install_check_event_source(Button *b) { in button_install_check_event_source() argument
107 assert(b); in button_install_check_event_source()
111 if (b->check_event_source) in button_install_check_event_source()
114 r = sd_event_add_post(b->manager->event, &b->check_event_source, button_recheck, b); in button_install_check_event_source()
118 return sd_event_source_set_priority(b->check_event_source, SD_EVENT_PRIORITY_IDLE+1); in button_install_check_event_source()
205 Button *b = userdata; in button_dispatch() local
210 assert(fd == b->fd); in button_dispatch()
211 assert(b); in button_dispatch()
213 l = read(b->fd, &ev, sizeof(ev)); in button_dispatch()
225 …if (b->manager->handle_power_key_long_press != HANDLE_IGNORE && b->manager->handle_power_key_long_… in button_dispatch()
227 …start_long_press(b->manager, &b->manager->power_key_long_press_event_source, long_press_of_power_k… in button_dispatch()
232 …manager_handle_action(b->manager, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manag… in button_dispatch()
242 …if (b->manager->handle_reboot_key_long_press != HANDLE_IGNORE && b->manager->handle_reboot_key_lon… in button_dispatch()
244 …start_long_press(b->manager, &b->manager->reboot_key_long_press_event_source, long_press_of_reboot… in button_dispatch()
249 …manager_handle_action(b->manager, INHIBIT_HANDLE_REBOOT_KEY, b->manager->handle_reboot_key, b->man… in button_dispatch()
260 …if (b->manager->handle_suspend_key_long_press != HANDLE_IGNORE && b->manager->handle_suspend_key_l… in button_dispatch()
262 …start_long_press(b->manager, &b->manager->suspend_key_long_press_event_source, long_press_of_suspe… in button_dispatch()
267 …manager_handle_action(b->manager, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->m… in button_dispatch()
272 …if (b->manager->handle_hibernate_key_long_press != HANDLE_IGNORE && b->manager->handle_hibernate_k… in button_dispatch()
274 …start_long_press(b->manager, &b->manager->hibernate_key_long_press_event_source, long_press_of_hib… in button_dispatch()
279 …manager_handle_action(b->manager, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, … in button_dispatch()
290 if (b->manager->power_key_long_press_event_source) { in button_dispatch()
299 …b->manager->power_key_long_press_event_source = sd_event_source_unref(b->manager->power_key_long_p… in button_dispatch()
301 …manager_handle_action(b->manager, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manag… in button_dispatch()
306 if (b->manager->reboot_key_long_press_event_source) { in button_dispatch()
311 …b->manager->reboot_key_long_press_event_source = sd_event_source_unref(b->manager->reboot_key_long… in button_dispatch()
313 …manager_handle_action(b->manager, INHIBIT_HANDLE_REBOOT_KEY, b->manager->handle_reboot_key, b->man… in button_dispatch()
318 if (b->manager->suspend_key_long_press_event_source) { in button_dispatch()
323 …b->manager->suspend_key_long_press_event_source = sd_event_source_unref(b->manager->suspend_key_lo… in button_dispatch()
325 …manager_handle_action(b->manager, INHIBIT_HANDLE_SUSPEND_KEY, b->manager->handle_suspend_key, b->m… in button_dispatch()
329 if (b->manager->hibernate_key_long_press_event_source) { in button_dispatch()
334 …b->manager->hibernate_key_long_press_event_source = sd_event_source_unref(b->manager->hibernate_ke… in button_dispatch()
336 …manager_handle_action(b->manager, INHIBIT_HANDLE_HIBERNATE_KEY, b->manager->handle_hibernate_key, … in button_dispatch()
348 b->lid_closed = true; in button_dispatch()
349 button_lid_switch_handle_action(b->manager, true); in button_dispatch()
350 button_install_check_event_source(b); in button_dispatch()
357 b->docked = true; in button_dispatch()
367 b->lid_closed = false; in button_dispatch()
368 b->check_event_source = sd_event_source_unref(b->check_event_source); in button_dispatch()
375 b->docked = false; in button_dispatch()
472 int button_open(Button *b) { in button_open() argument
478 assert(b); in button_open()
480 b->fd = asynchronous_close(b->fd); in button_open()
482 p = strjoina("/dev/input/", b->name); in button_open()
498 (void) button_set_mask(b->name, fd); in button_open()
500 b->io_event_source = sd_event_source_unref(b->io_event_source); in button_open()
501 … r = sd_event_add_io(b->manager->event, &b->io_event_source, fd, EPOLLIN, button_dispatch, b); in button_open()
505 b->fd = TAKE_FD(fd); in button_open()
510 int button_check_switches(Button *b) { in button_check_switches() argument
512 assert(b); in button_check_switches()
514 if (b->fd < 0) in button_check_switches()
517 if (ioctl(b->fd, EVIOCGSW(sizeof(switches)), switches) < 0) in button_check_switches()
520 b->lid_closed = bitset_get(switches, SW_LID); in button_check_switches()
521 b->docked = bitset_get(switches, SW_DOCK); in button_check_switches()
523 if (b->lid_closed) in button_check_switches()
524 button_install_check_event_source(b); in button_check_switches()