handle.c
// we bind on all mouse buttons on the root window to implement click-to-focus
// events are compressed, checked for a window change, then replayed through to clients
we bind on all mouse buttons on the root window to implement click-to-focus
events are compressed, checked for a window change, then replayed through to clients
we bind on all mouse buttons on the root window to implement click - to - focus events are compressed checked for a window change then replayed through to clients
void handle_buttonpress(XEvent *ev)
{
	event_log("ButtonPress", ev->xbutton.subwindow);
	int state = ev->xbutton.state & ~(LockMask|NumlockMask);
	int is_mod = prefix_mode_active || state & config_modkey ? 1:0;
	reset_lazy_caches();
	reset_cache_client();
	latest = ev->xbutton.time;
	client *c = ev->xbutton.subwindow != None ? client_create(ev->xbutton.subwindow): NULL;
	if (c && c->cache->is_ours && c->cache->app)
	{
		c = client_create(c->cache->app);
		is_mod = 1;
	}
	if (c && c->manage && !client_has_state(c, netatoms[_NET_WM_STATE_FULLSCREEN]))
	{
		if (!c->focus || !c->active) client_activate(c, RAISEDEF, WARPDEF);
		if (is_mod && ev->xbutton.button == Button1) client_raise(c, 0);
		if (is_mod)
		{
			if (prefix_mode_active) release_pointer();
			take_pointer(c->window, PointerMotionMask|ButtonReleaseMask, None);
			mouse_dragger = allocate_clear(sizeof(struct mouse_drag));
			mouse_dragger->overlay = box_create(root, BOX_OVERRIDE, c->x, c->y, c->w, c->h, config_border_blur);
			unsigned long opacity = 0xffffffff / 2;
			window_set_cardinal_prop(mouse_dragger->overlay->window, netatoms[_NET_WM_WINDOW_OPACITY], &opacity, 1);
			memcpy(&mouse_dragger->attr,   &c->xattr,    sizeof(c->xattr));
			memcpy(&mouse_dragger->button, &ev->xbutton, sizeof(ev->xbutton));
			mouse_dragger->flags = MR_UNCONSTRAIN;
			if (mouse_dragger->button.button == Button1) mouse_dragger->flags |= MR_SNAP;
			if (mouse_dragger->button.button == Button3) mouse_dragger->flags |= MR_SNAPWH;
		}
		else
		{
			XAllowEvents(display, ReplayPointer, CurrentTime);
		}
	}
	else
	{
		XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
		XAllowEvents(display, ReplayPointer, CurrentTime);
	}
	event_client_dump(c);
	ewmh_client_list();
}
void handle_buttonpress ( XEvent * ev ) { event_log ( " " , ev -> xbutton . subwindow ) ; int state = ev -> xbutton . state & ~ ( LockMask | NumlockMask ) ; int is_mod = prefix_mode_active || state & config_modkey ? 1 : 0 ; reset_lazy_caches ( ) ; reset_cache_client ( ) ; latest = ev -> xbutton . time ; client * c = ev -> xbutton . subwindow != None ? client_create ( ev -> xbutton . subwindow ) : NULL ; if ( c && c -> cache -> is_ours && c -> cache -> app ) { c = client_create ( c -> cache -> app ) ; is_mod = 1 ; } if ( c && c -> manage && ! client_has_state ( c , netatoms [ _NET_WM_STATE_FULLSCREEN ] ) ) { if ( ! c -> focus || ! c -> active ) client_activate ( c , RAISEDEF , WARPDEF ) ; if ( is_mod && ev -> xbutton . button == Button1 ) client_raise ( c , 0 ) ; if ( is_mod ) { if ( prefix_mode_active ) release_pointer ( ) ; take_pointer ( c -> window , PointerMotionMask | ButtonReleaseMask , None ) ; mouse_dragger = allocate_clear ( sizeof ( struct mouse_drag ) ) ; mouse_dragger -> overlay = box_create ( root , BOX_OVERRIDE , c -> x , c -> y , c -> w , c -> h , config_border_blur ) ; unsigned long opacity = 0xffffffff / 2 ; window_set_cardinal_prop ( mouse_dragger -> overlay -> window , netatoms [ _NET_WM_WINDOW_OPACITY ] , & opacity , 1 ) ; memcpy ( & mouse_dragger -> attr , & c -> xattr , sizeof ( c -> xattr ) ) ; memcpy ( & mouse_dragger -> button , & ev -> xbutton , sizeof ( ev -> xbutton ) ) ; mouse_dragger -> flags = MR_UNCONSTRAIN ; if ( mouse_dragger -> button . button == Button1 ) mouse_dragger -> flags |= MR_SNAP ; if ( mouse_dragger -> button . button == Button3 ) mouse_dragger -> flags |= MR_SNAPWH ; } else { XAllowEvents ( display , ReplayPointer , CurrentTime ) ; } } else { XSetInputFocus ( display , PointerRoot , RevertToPointerRoot , CurrentTime ) ; XAllowEvents ( display , ReplayPointer , CurrentTime ) ; } event_client_dump ( c ) ; ewmh_client_list ( ) ; }
we bind on all mouse buttons on the root window to implement click-to-focus
events are compressed, checked for a window change, then replayed through to clients
we bind on all mouse buttons on the root window to implement click - to - focus events are compressed checked for a window change then replayed through to clients
// all mouse button events except the wheel come here, so we can click-to-focus // turn off caps and num locks bits. dont care about their states // click was on a frame or title. switch to app window // Mod+Button1 raises a window. this might already have been raised in // client_activate(), but doing the restack again is not a big deal // moving or resizing // no map yet, see motionnotify // snap all edges by moving window // snap right and bottom edges by resizing window // events we havn't snaffled for move/resize may be relevant to the subwindow. replay them // click was on root window // events we havn't snaffled for move/resize may be relevant to the subwindow. replay them