int mouse_unbind_all() { g_list_free_full(g_mouse_binds, mouse_binding_free); g_mouse_binds = NULL; HSClient* client = get_current_client(); if (client) { grab_client_buttons(client, true); } return 0; }
int mouse_bind_command(int argc, char** argv, GString* output) { if (argc < 3) { return HERBST_NEED_MORE_ARGS; } unsigned int modifiers = 0; char* string = argv[1]; if (!string2modifiers(string, &modifiers)) { g_string_append_printf(output, "%s: Modifier \"%s\" does not exist\n", argv[0], string); return HERBST_INVALID_ARGUMENT; } // last one is the mouse button const char* last_token = strlasttoken(string, KEY_COMBI_SEPARATORS); unsigned int button = string2button(last_token); if (button == 0) { g_string_append_printf(output, "%s: Unknown mouse button \"%s\"\n", argv[0], last_token); return HERBST_INVALID_ARGUMENT; } MouseFunction function = string2mousefunction(argv[2]); if (!function) { g_string_append_printf(output, "%s: Unknown mouse action \"%s\"\n", argv[0], argv[2]); return HERBST_INVALID_ARGUMENT; } // actually create a binding MouseBinding* mb = g_new(MouseBinding, 1); mb->button = button; mb->modifiers = modifiers; mb->action = function; mb->argc = argc - 3; mb->argv = argv_duplicate(argc - 3, argv + 3);; g_mouse_binds = g_list_prepend(g_mouse_binds, mb); HSClient* client = get_current_client(); if (client) { grab_client_buttons(client, true); } return 0; }
int client_set_property_command(int argc, char** argv) { char* action = (argc > 1) ? argv[1] : "toggle"; HSClient* client = get_current_client(); if (!client) { // nothing to do return 0; } struct { char* name; void (*func)(HSClient*, bool); bool* value; } properties[] = { { "fullscreen", client_set_fullscreen, &client->fullscreen }, { "pseudotile", client_set_pseudotile, &client->pseudotile }, }; // find the property int i; for (i = 0; i < LENGTH(properties); i++) { if (!strcmp(properties[i].name, argv[0])) { break; } } if (i >= LENGTH(properties)) { return HERBST_INVALID_ARGUMENT; } // if found, then change it bool old_value = *(properties[i].value); bool state = string_to_bool(action, *(properties[i].value)); if (state != old_value) { properties[i].func(client, state); } return 0; }
ETERM *space_subscribe_box(ETERM *fromp, ETERM *argp) { // get the args ETERM *space_refp = erl_element(1, argp); ETERM *subscriber_pidp = erl_element(2, argp); ETERM *bounding_boxp = erl_element(3, argp); ETERM *leftp = erl_element(1, bounding_boxp); ETERM *bottomp = erl_element(2, bounding_boxp); ETERM *rightp = erl_element(3, bounding_boxp); ETERM *topp = erl_element(4, bounding_boxp); erlmunk_space *s; int space_id = ERL_REF_NUMBER(space_refp); HASH_FIND_INT(erlmunk_spaces, &space_id, s); erlmunk_client *client = get_current_client(); space_add_subscriber(s, client, erl_copy_term(subscriber_pidp), ERL_FLOAT_VALUE(leftp), ERL_FLOAT_VALUE(bottomp), ERL_FLOAT_VALUE(rightp), ERL_FLOAT_VALUE(topp)); // DEBUGF(("space_subscribe_box(client fd: %d) has succeeded", // client->fd)); return NULL; }
ETERM *space_subscribe_collision(ETERM *fromp, ETERM *argp) { // get the args ETERM *space_refp = erl_element(1, argp); ETERM *typeap = erl_element(2, argp); ETERM *typebp = erl_element(3, argp); ETERM *pidp = erl_element(4, argp); erlmunk_space *s; int space_id = ERL_REF_NUMBER(space_refp); HASH_FIND_INT(erlmunk_spaces, &space_id, s); erlmunk_subscriber *subscriber = (erlmunk_subscriber *) malloc(sizeof(erlmunk_subscriber)); subscriber->client = get_current_client(); subscriber->from = erl_copy_term(pidp); cpCollisionHandler *handler = cpSpaceAddCollisionHandler(s->space, ERL_INT_VALUE(typeap), ERL_INT_VALUE(typebp)); handler->beginFunc = handle_collision; handler->userData = subscriber; return NULL; }
void client_update_title(HSClient* client) { GString* new_name = window_property_to_g_string(g_display, client->window, g_netatom[NetWmName]); if (!new_name) { char* ch_new_name = NULL; /* if ewmh name isn't set, then fall back to WM_NAME */ if (0 != XFetchName(g_display, client->window, &ch_new_name)) { new_name = g_string_new(ch_new_name); XFree(ch_new_name); } else { new_name = g_string_new(""); HSDebug("no title for window %lx found, using \"\"\n", client->window); } } bool changed = (0 != strcmp(client->title->str, new_name->str)); g_string_free(client->title, true); client->title = new_name; if (changed && get_current_client() == client) { char buf[STRING_BUF_SIZE]; snprintf(buf, STRING_BUF_SIZE, "0x%lx", client->window); hook_emit_list("window_title_changed", buf, client->title->str, NULL); } }