Esempio n. 1
0
int
clientwin_handle(ClientWin *cw, XEvent *ev)
{
	if((ev->type == ButtonRelease && ev->xbutton.button == 1 && cw->mainwin->pressed == cw)) {
		if((ev->xbutton.x >= 0 && ev->xbutton.y >= 0 && ev->xbutton.x < cw->mini.width && ev->xbutton.y < cw->mini.height))
			childwin_focus(cw);
		cw->mainwin->pressed = 0;
		return 1;
	} else if(ev->type == KeyRelease) {
		if(ev->xkey.keycode == cw->mainwin->key_up)
			focus_up(cw);
		else if(ev->xkey.keycode == cw->mainwin->key_down)
			focus_down(cw);
		else if(ev->xkey.keycode == cw->mainwin->key_left)
			focus_left(cw);
		else if(ev->xkey.keycode == cw->mainwin->key_right)
			focus_right(cw);
		else if(ev->xkey.keycode == cw->mainwin->key_enter || ev->xkey.keycode == cw->mainwin->key_space) {
			childwin_focus(cw);
			return 1;
		}
	} else if(ev->type == ButtonPress && ev->xbutton.button == 1) {
		cw->mainwin->pressed = cw;
	} else if(ev->type == FocusIn) {
		cw->focused = 1;
		clientwin_render(cw);
		XFlush(cw->mainwin->dpy);
	} else if(ev->type == FocusOut) {
		cw->focused = 0;
		clientwin_render(cw);
		XFlush(cw->mainwin->dpy);
	} else if(ev->type == EnterNotify) {
		if(cw->mainwin->tooltip)
		{
			int win_title_len = 0;
			FcChar8 *win_title = wm_get_window_title(cw->mainwin->dpy, cw->client.window, &win_title_len);
			if(win_title)
			{
				tooltip_map(cw->mainwin->tooltip,
				            ev->xcrossing.x_root + 20, ev->xcrossing.y_root + 20,
				            win_title, win_title_len);
				free(win_title);
			}
		}
	} else if(ev->type == LeaveNotify) {
		if(cw->mainwin->tooltip)
			tooltip_unmap(cw->mainwin->tooltip);
	}
	return 0;
}
Esempio n. 2
0
int
clientwin_handle(ClientWin *cw, XEvent *ev) {
	MainWin *mw = cw->mainwin;
	session_t *ps = mw->ps;

	if (ev->type == ButtonRelease) {
		const unsigned button = ev->xbutton.button;
		if (cw->mainwin->pressed_mouse) {
			if (button < MAX_MOUSE_BUTTONS) {
				int ret = clientwin_action(cw,
						ps->o.bindings_miwMouse[button]);
				if (ret) {
                                    printfef("(): Quitting.");
                                    return ret;
				}
			}
		}
		else
			printfef("(): ButtonRelease %u ignored.", button);
	} else if (ev->type == KeyRelease) {
		if (cw->mainwin->pressed_key) {
			if (ev->xkey.keycode == cw->mainwin->key_up ||
					ev->xkey.keycode == cw->mainwin->key_k)
				focus_up(cw);
			else if (ev->xkey.keycode == cw->mainwin->key_down ||
					ev->xkey.keycode == cw->mainwin->key_j)
				focus_down(cw);
			else if (ev->xkey.keycode == cw->mainwin->key_left ||
					ev->xkey.keycode == cw->mainwin->key_h)
				focus_left(cw);
			else if (ev->xkey.keycode == cw->mainwin->key_right ||
					ev->xkey.keycode == cw->mainwin->key_l)
				focus_right(cw);
			else if (ev->xkey.keycode == cw->mainwin->key_enter
					|| ev->xkey.keycode == cw->mainwin->key_space) {
				childwin_focus(cw);
				return 1;
			}
			else
				report_key_unbinded(ev);
		}
		else
			report_key_ignored(ev);
	}
	else if (ev->type == ButtonPress) {
		cw->mainwin->pressed_mouse = true;
		/* if (ev->xbutton.button == 1)
			cw->mainwin->pressed = cw; */
	}
	else if (KeyPress == ev->type) {
		cw->mainwin->pressed_key = true;
	}
	else if(ev->type == FocusIn) {
		cw->focused = 1;
		clientwin_render(cw);
		XFlush(ps->dpy);
	} else if(ev->type == FocusOut) {
		cw->focused = 0;
		clientwin_render(cw);
		XFlush(ps->dpy);
	} else if(ev->type == EnterNotify) {
		XSetInputFocus(ps->dpy, cw->mini.window, RevertToParent, CurrentTime);
		if (cw->mainwin->tooltip) {
			int win_title_len = 0;
			FcChar8 *win_title = wm_get_window_title(ps, cw->wid_client, &win_title_len);
			if (win_title) {
				tooltip_map(cw->mainwin->tooltip,
						ev->xcrossing.x_root, ev->xcrossing.y_root,
						win_title, win_title_len);
				free(win_title);
			}
		}
	} else if(ev->type == LeaveNotify) {
		// XSetInputFocus(ps->dpy, mw->window, RevertToParent, CurrentTime);
		if(cw->mainwin->tooltip)
			tooltip_unmap(cw->mainwin->tooltip);
	}
	return 0;
}