예제 #1
0
파일: dnd.c 프로젝트: bpeel/weston
int
weston_wm_handle_dnd_event(struct weston_wm *wm,
			   xcb_generic_event_t *event)
{
	xcb_xfixes_selection_notify_event_t *xfixes_selection_notify =
		(xcb_xfixes_selection_notify_event_t *) event;
	xcb_client_message_event_t *client_message =
		(xcb_client_message_event_t *) event;

	switch (event->response_type - wm->xfixes->first_event) {
	case XCB_XFIXES_SELECTION_NOTIFY:
		if (xfixes_selection_notify->selection != wm->atom.xdnd_selection)
			return 0;

		weston_log("XdndSelection owner: %d!\n",
			   xfixes_selection_notify->owner);

		if (xfixes_selection_notify->owner != XCB_WINDOW_NONE)
			weston_dnd_start(wm, xfixes_selection_notify->owner);
		else
			weston_dnd_stop(wm);

		return 1;
	}

	switch (EVENT_TYPE(event)) {
	case XCB_CLIENT_MESSAGE:
		if (client_message->type == wm->atom.xdnd_enter) {
			handle_enter(wm, client_message);
			return 1;
		} else if (client_message->type == wm->atom.xdnd_leave) {
			weston_log("got leave!\n");
			return 1;
		} else if (client_message->type == wm->atom.xdnd_drop) {
			weston_log("got drop!\n");
			return 1;
		} else if (client_message->type == wm->atom.xdnd_drop) {
			weston_log("got enter!\n");
			return 1;
		}
		return 0;
	}

	return 0;
}
예제 #2
0
void
menuscreen_key_handler(const char *key)
{
	MenuToken token = MENUTOKEN_NONE;
	MenuResult res;

	debug(RPT_DEBUG, "%s(\"%s\")", __FUNCTION__, key);

	if ((menu_key != NULL) && (strcmp(key, menu_key) == 0)) {
		token = MENUTOKEN_MENU;
	}
	else if ((enter_key != NULL) && (strcmp(key, enter_key) == 0)) {
		token = MENUTOKEN_ENTER;
	}
	else if ((up_key != NULL) && (strcmp(key, up_key) == 0)) {
		token = MENUTOKEN_UP;
	}
	else if ((down_key != NULL) && (strcmp(key, down_key) == 0)) {
		token = MENUTOKEN_DOWN;
	}
	else if ((left_key != NULL) && (strcmp(key, left_key) == 0)) {
		token = MENUTOKEN_LEFT;
	}
	else if ((right_key != NULL) && (strcmp(key, right_key) == 0)) {
		token = MENUTOKEN_RIGHT;
	}
	else {
		token = MENUTOKEN_OTHER;
	}

	/* Is the menu already active ? */
	if (!active_menuitem) {
		debug(RPT_DEBUG, "%s: Activating menu screen", __FUNCTION__);
		menuscreen_switch_item(menuscreen_get_main());
		return;
	}

	res = menuitem_process_input(active_menuitem, token, key, keymask);
	switch (res) {
	    case MENURESULT_ERROR:
		report(RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__);
		break;
	    case MENURESULT_NONE:
		handle_none();
		break;
	    case MENURESULT_ENTER:
		handle_enter();
		break;
	    case MENURESULT_CLOSE:
		handle_close();
		break;
	    case MENURESULT_QUIT:
		handle_quit();
		break;
	    case MENURESULT_PREDECESSOR:
		handle_predecessor();
		break;
	    case MENURESULT_SUCCESSOR:
		handle_successor();
		break;
	    default:
		assert(!"unexpected menuresult");
		break;
	}
}
예제 #3
0
/*
*	Function: init_keyboard_handler()
*	Description: This function reads from the appropriate port on the keyboard to 
*				receive the interrupts generated, parses this information, and 
*				displays the associated character on the screen.
*	inputs:	 nothing
*	outputs: nothing
*	effects: prints character to screen from scancode_map
*/
void 
keyboard_interrupt_handler() {
	cli();
	uint8_t c = 0;
	do {
		if (inb(KEYBOARD_DATA_PORT) != 0) {
			c = inb(KEYBOARD_DATA_PORT);
			if (c > 0) {
				break;
			}
		}
	} while(1);

	switch (c) {
		case LSHIFT_DOWN:
		case RSHIFT_DOWN:
			ENABLE_SHIFT();
			break;
		case LSHIFT_UP:
		case RSHIFT_UP:
			DISABLE_SHIFT();
			break;
		case CAPS_LOCK:
			TOGGLE_CAPS();
			break;
		case BACKSPACE:
			handle_backspace();
			break;
		case ENTER:
			handle_enter();
			break;
		case CTRL_DOWN:
			ctrl_state = PRESSED;
			break;
		case CTRL_UP:
			ctrl_state = UNPRESSED;
			break;
		case ALT_DOWN:
			alt_state = PRESSED;
			break;
		case ALT_UP:
			alt_state = UNPRESSED;
			break;
		case F1_KEY:
			if (alt_state == PRESSED) {
				send_eoi(KEYBOARD_IRQ_LINE);
				launch_term(TERMINAL_ONE);
			}
			break;
		case F2_KEY:
			if (alt_state == PRESSED) {
				send_eoi(KEYBOARD_IRQ_LINE);
				launch_term(TERMINAL_TWO);
			}
			break;
		case F3_KEY:
			if (alt_state == PRESSED) {
				send_eoi(KEYBOARD_IRQ_LINE);
				launch_term(TERMINAL_THREE);
			}
			break;
		default:
			handle_key_press(c);
			break;
	}
	
	send_eoi(KEYBOARD_IRQ_LINE);
	sti();
}