Exemple #1
0
static inline bool unregister_hotkey(obs_hotkey_id id)
{
	if (id >= obs->hotkeys.next_id)
		return false;

	size_t idx;
	if (!find_id(id, &idx))
		return false;

	obs_hotkey_t *hotkey = &obs->hotkeys.hotkeys.array[idx];

	hotkey_signal("hotkey_unregister", hotkey);

	release_registerer(hotkey);

	bfree(hotkey->name);
	bfree(hotkey->description);

	if (hotkey->registerer_type == OBS_HOTKEY_REGISTERER_SOURCE)
		obs_weak_source_release(hotkey->registerer);

	da_erase(obs->hotkeys.hotkeys, idx);
	remove_bindings(id);

	return obs->hotkeys.hotkeys.num >= idx;
}
Exemple #2
0
/* nap_exit: cleans up and leaves */
void nap_exit (int really_quit, char *reason, char *format, ...)
{
	if (dead == 1) {
		kill_all_threads();
		exit(1);
	}
	else if (dead == 2) {
		kill_all_threads();
		_exit(1);
	}
	else if (dead == 3) {
		kill_all_threads();
		kill(getpid(), SIGKILL);
	}
	dead++;

	set_lastlog_size(NULL, NULL, 0);
	set_history_size(NULL, NULL, 0);

	if (really_quit)
	{
		kill_all_threads();
		say("Signon time  :    %s", my_ctime(start_time));
		say("Signoff time :    %s", my_ctime(now));
		say("Total uptime :    %s", convert_time(now - start_time));
	}
	do_hook(EXIT_LIST, "%s", reason ? reason : empty_string);
	if (reason)
		say("%s", reason);

	close_all_servers();
	close_all_sockets();
	if (term_initialized)
	{
		cursor_to_input();
		term_cr();
		term_clear_to_eol();
		term_reset();
	}

	remove_bindings();
	clear_variables();
	delete_all_windows();
	destroy_call_stack();		
	write_unfinished_list();
	
	debug_cleanup();
	fprintf(stdout, "\r");
	fflush(stdout);
	if (really_quit)
		exit(0);

	kill_all_threads();
	my_signal(SIGABRT, SIG_DFL, 0);
	kill(getpid(), SIGABRT);
	kill(getpid(), SIGQUIT);
	exit(1);
}
Exemple #3
0
void obs_hotkey_load(obs_hotkey_id id, obs_data_array_t *data)
{
	size_t idx;

	if (!lock())
		return;

	if (find_id(id, &idx)) {
		remove_bindings(id);
		load_bindings(&obs->hotkeys.hotkeys.array[idx], data);
	}
	unlock();
}
Exemple #4
0
void obs_hotkey_pair_load(obs_hotkey_pair_id id, obs_data_array_t *data0,
		obs_data_array_t *data1)
{
	if ((!data0 && !data1) || !lock())
		return;

	size_t idx;
	if (!find_pair_id(id, &idx))
		goto unlock;

	obs_hotkey_pair_t *pair = &obs->hotkeys.hotkey_pairs.array[idx];

	if (find_id(pair->id[0], &idx)) {
		remove_bindings(pair->id[0]);
		load_bindings(&obs->hotkeys.hotkeys.array[idx], data0);
	}
	if (find_id(pair->id[1], &idx)) {
		remove_bindings(pair->id[1]);
		load_bindings(&obs->hotkeys.hotkeys.array[idx], data1);
	}

unlock:
	unlock();
}
Exemple #5
0
/*
 * Update current bindings with a new value
 */
void
shortcuts_update_bindings(guint shortcut_idx, guint key, GdkModifierType mask)
{
    // first remove all existing bindings
    remove_bindings();

    // update data
    update_bindings_data(shortcut_idx, key, mask);

    // recreate all bindings
    create_bindings();

    // update configuration
    dbus_set_shortcuts(shortcutsMap);
}
Exemple #6
0
/*
 * Destroy bindings (called on exit)
 */
void
shortcuts_destroy_bindings()
{
    if (!accelerators_list)
        return;

    // remove bindings
    remove_bindings();

    // free pointers
    for (guint i = 0; accelerators_list[i].action != NULL; ++i)
        g_free(accelerators_list[i].action);

    free(accelerators_list);
    g_hash_table_destroy(shortcutsMap);
}
Exemple #7
0
void obs_hotkey_load_bindings(obs_hotkey_id id,
		obs_key_combination_t *combinations, size_t num)
{
	size_t idx;

	if (!lock())
		return;

	if (find_id(id, &idx)) {
		obs_hotkey_t *hotkey = &obs->hotkeys.hotkeys.array[idx];
		remove_bindings(id);
		for (size_t i = 0; i < num; i++)
			create_binding(hotkey, combinations[i]);

		hotkey_signal("hotkey_bindings_changed", hotkey);
	}
	unlock();
}
Exemple #8
0
/* 
 * This is where you put all the default key bindings.  This is a lot
 * simpler, just defining those you need, instead of all of them, isnt
 * it?  And it takes up so much less memory, too...
 */
void 	init_keys (void)
{
	int i;

	/*
	 * Make sure the meta map is big enough to hold all these bindings.
	 */
	remove_bindings();
	resize_metamap(40);	/* Whatever. */

	/* 
	 * All the "default" bindings are self_insert unless we bind
	 * them differently
	 */
	for (i = 1; i <= 255; i++)
		snew_key(0, i, "SELF_INSERT");

	/* "default" characters that arent self_insert */
	snew_key(0,  1, "BEGINNING_OF_LINE");		/* ^A */
	snew_key(0,  2, "BOLD");			/* ^B */
	snew_key(0,  4, "DELETE_CHARACTER");		/* ^D */
	snew_key(0,  5, "CHANGE_TO_SPLIT");		/* ^E */
	snew_key(0,  6, "WHOLEFT");			/* ^F */
	snew_key(0,  8, "BACKSPACE");			/* ^H (delete) */

	snew_key(0,  9, "TAB_COMPLETION");		/* ^I (tab) */
	snew_key(0, 10, "SEND_LINE");			/* ^J (enter) */
	snew_key(0, 11, "JOIN_LAST_INVITE");		/* ^K */
	snew_key(0, 12, "REFRESH_SCREEN");		/* ^L (linefeed) */
	snew_key(0, 13, "SEND_LINE");			/* ^M (return) */
	snew_key(0, 14, "QUOTE_CHARACTER");		/* ^N */
	snew_key(0, 15, "IGNORE_NICK");			/* ^O */
	snew_key(0, 16, "BACKWARD_HISTORY");		/* ^P */

	snew_key(0, 17, "QUOTE_CHARACTER");		/* ^Q */
	snew_key(0, 18, "NICK_COMPLETION");		/* ^R */
	snew_key(0, 19, "TOGGLE_STOP_SCREEN");		/* ^S */
	snew_key(0, 20, "TRANSPOSE_CHARACTERS");	/* ^T */
	snew_key(0, 21, "ERASE_LINE");			/* ^U */
	snew_key(0, 22, "REVERSE");			/* ^V */
	snew_key(0, 23, "META2_CHARACTER");		/* ^W */
	snew_key(0, 24, "SWITCH_CHANNELS");		/* ^X */

	snew_key(0, 25, "YANK_FROM_CUTBUFFER");		/* ^Y */
#ifdef ALLOW_STOP_IRC
#ifndef PUBLIC_ACCESS
	snew_key(0, 26, "STOP_IRC");			/* ^Z */
#endif
#endif
	snew_key(0, 27, "META1_CHARACTER");		/* ^[ (escape) */
	snew_key(0, 29, "AUTOREPLY");			/* ^] */
	snew_key(0, 31, "UNDERLINE");			/* ^_ */

	snew_key(0, 127, "BACKSPACE");			/* ^? (delete) */

	/* 
	 * european keyboards (and probably others) use the eigth bit
	 * for extended characters.  Having these keys bound by default
	 * causes them lots of grief, so unless you really want to use
	 * these, they are commented out.
	 */
#ifdef EMACS_KEYBINDS
	snew_key(0, 188, "SCROLL_START");
	snew_key(0, 190, "SCROLL_END");
	snew_key(0, 226, "BACKWARD_WORD");
	snew_key(0, 228, "DELETE_NEXT_WORD");
	snew_key(0, 229, "SCROLL_END");
	snew_key(0, 230, "FORWARD_WORD");
	snew_key(0, 232, "DELETE_PREVIOUS_WORD");
	snew_key(0, 255, "DELETE_PREVIOUS_WORD");
#endif

	/* meta 1 characters */
	snew_key(1,  27, "COMMAND_COMPLETION");
	snew_key(1,  46, "CLEAR_SCREEN");
	snew_key(1,  60, "SCROLL_START");
	snew_key(1,  62, "SCROLL_END");
	snew_key(1,  79, "META2_CHARACTER");
	snew_key(1,  91, "META2_CHARACTER");
	snew_key(1,  98, "BACKWARD_WORD");
	snew_key(1, 100, "DELETE_NEXT_WORD");
	snew_key(1, 101, "SCROLL_END");
	snew_key(1, 102, "FORWARD_WORD");
	snew_key(1, 104, "DELETE_PREVIOUS_WORD");
	snew_key(1, 110, "SCROLL_FORWARD");
	snew_key(1, 112, "SCROLL_BACKWARD");
	snew_key(1, 127, "DELETE_PREVIOUS_WORD");

	snew_key(1, '1', "WINDOW_SWAP_1");
	snew_key(1, '2', "WINDOW_SWAP_2");
	snew_key(1, '3', "WINDOW_SWAP_3");
	snew_key(1, '4', "WINDOW_SWAP_4");
	snew_key(1, '5', "WINDOW_SWAP_5");
	snew_key(1, '6', "WINDOW_SWAP_6");
	snew_key(1, '7', "WINDOW_SWAP_7");
	snew_key(1, '8', "WINDOW_SWAP_8");
	snew_key(1, '9', "WINDOW_SWAP_9");
	snew_key(1, '0', "WINDOW_SWAP_10");

	/* meta 2 characters */
#ifdef ALLOW_STOP_IRC
#ifndef PUBLIC_ACCESS
	snew_key(2,  26, "STOP_IRC");
#endif
#endif

	snew_key(2, 110, "SWAP_NEXT_WINDOW");
	snew_key(2, 112, "PREVIOUS_WINDOW");

#ifdef __EMX__
	/* meta 3 characters */
	snew_key(2, '[', "META3_CHARACTER");
	snew_key(2, '1', "META3_CHARACTER");

    snew_key(1, 71, "NEW_BEGINNING_OF_LINE");
    snew_key(1, 83, "TOGGLE_CLOAK");
    snew_key(1, 79, "NEW_SCROLL_END");
    snew_key(1, 73, "NEW_SCROLL_BACKWARD");
    snew_key(1, 81, "NEW_SCROLL_FORWARD");

	snew_key(2, '?', "WINDOW_HELP");
	snew_key(2, '+', "WINDOW_GROW_ONE");
	snew_key(2, '-', "WINDOW_SHRINK_ONE");
	snew_key(2, 'm', "WINDOW_MOVE");
	snew_key(2, 'l', "WINDOW_LIST");
	snew_key(2, 'k', "WINDOW_KILL");
	snew_key(2, 'b', "WINDOW_BALANCE");
	snew_key(2, 'h', "WINDOW_HIDE");
		
	snew_key(2, '[', "META3_CHARACTER");
	snew_key(2, '1', "META3_CHARACTER");

#else /* __EMX__ */
	snew_key(2, '?', "WINDOW_HELP");
	snew_key(2, '+', "WINDOW_GROW_ONE");
	snew_key(2, '-', "WINDOW_SHRINK_ONE");
	snew_key(2, 'm', "WINDOW_MOVE");
	snew_key(2, 'l', "WINDOW_LIST");
	snew_key(2, 'k', "WINDOW_KILL");
	snew_key(2, 'b', "WINDOW_BALANCE");
	snew_key(2, 'h', "WINDOW_HIDE");
	snew_key(2, '[', "META3_CHARACTER");
	snew_key(2,  70, "SCROLL_START");	/* Freebsd home */
	snew_key(2,  71, "SCROLL_FORWARD");	/* Freebsd pgdown */
	snew_key(2,  72, "SCROLL_END");		/* Freebsd end */
	snew_key(2,  73, "SCROLL_BACKWARD");	/* Freebsd pgup */
	snew_key(2, '1', "META32_CHARACTER");
	snew_key(2, '4', "META33_CHARACTER");
	snew_key(2, '5', "META30_CHARACTER");
	snew_key(2, '6', "META31_CHARACTER");
#endif

	/* meta 4 characters -- vi key mappings */
	snew_key(4,   8, "BACKWARD_CHARACTER");
	snew_key(4,  32, "FORWARD_CHARACTER");
	snew_key(4,  65, "META4");
	snew_key(4,  72, "BACKWARD_CHARACTER");
	snew_key(4,  73, "META4");
	snew_key(4,  74, "FORWARD_HISTORY");
	snew_key(4,  75, "BACKWARD_HISTORY");
	snew_key(4,  76, "FORWARD_CHARACTER");
	snew_key(4,  88, "DELETE_CHARACTER");
	snew_key(4,  97, "META4");
	snew_key(4, 104, "BACKWARD_CHARACTER");
	snew_key(4, 105, "META4");
	snew_key(4, 106, "FORWARD_HISTORY");
	snew_key(4, 107, "BACKWARD_HISTORY");
	snew_key(4, 108, "FORWARD_CHARACTER");
	snew_key(4, 120, "DELETE_CHARACTER");

	/* I used 30-something to keep them out of others' way */
	snew_key(30, '~', "SCROLL_BACKWARD");
	snew_key(31, '~', "SCROLL_FORWARD");
	snew_key(32, '~', "SCROLL_START");
	snew_key(33, '~', "SCROLL_END");
}