Exemplo n.º 1
0
// Xft text box, optionally editable
textbox* textbox_create(Window parent, bitmap flags, short x, short y, short w, short h, char *font, char *fg, char *bg, char *text, char *prompt)
{
	textbox *tb = allocate_clear(sizeof(textbox));

	tb->flags = flags;
	tb->parent = parent;

	tb->x = x; tb->y = y; tb->w = MAX(1, w); tb->h = MAX(1, h);
	tb->window = XCreateSimpleWindow(display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, color_get(bg));

	// need to preload the font to calc line height
	textbox_font(tb, font, fg, bg);

	tb->prompt = strdup(prompt ? prompt: "");
	textbox_text(tb, text ? text: "");

	// auto height/width modes get handled here
	textbox_moveresize(tb, tb->x, tb->y, tb->w, tb->h);

	// edit mode controls
	if (tb->flags & TB_EDITABLE)
	{
		tb->xim = XOpenIM(display, NULL, NULL, NULL);
		tb->xic = XCreateIC(tb->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, tb->window, XNFocusWindow, tb->window, NULL);
	}

	return tb;
}
Exemplo n.º 2
0
// an X screen. may have multiple monitors, xinerama, etc
void
setup_screen()
{
	int i;
	Window w;
	supporting = XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, 0, 0);
	unsigned long pid = getpid();

	// EWMH
	XChangeProperty(display, root, netatoms[_NET_SUPPORTED], XA_ATOM, 32,
	    PropModeReplace, (unsigned char *) netatoms, NETATOMS);

	// ewmh supporting wm
	XChangeProperty(display, root, netatoms[_NET_SUPPORTING_WM_CHECK],
	    XA_WINDOW, 32, PropModeReplace, (unsigned char *) &supporting, 1);
	XChangeProperty(display, supporting,
	    netatoms[_NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, PropModeReplace,
	    (unsigned char *) &supporting, 1);
	XChangeProperty(display, supporting, netatoms[_NET_WM_NAME], XA_STRING,
	    8, PropModeReplace, (const unsigned char *) "GoomwWM", 6);
	XChangeProperty(display, supporting, netatoms[_NET_WM_PID],
	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &pid, 1);

	// become the window manager here
	XSelectInput(display, root,
	    StructureNotifyMask | SubstructureRedirectMask |
	    SubstructureNotifyMask);

	// setup any existing windows
	winlist *l = window_children();
	winlist_ascend(l, i, w) {
		wincache *cache = allocate_clear(sizeof(wincache));
		winlist_append(windows, w, cache);
		client *c = client_create(w);
		if (c && c->manage && (c->visible
			|| client_get_wm_state(c) == IconicState)) {
			window_select(c->window);
			winlist_append(c->
			    visible ? windows_activated : windows_shaded,
			    c->window, NULL);
			client_full_review(c);
		}
	}