Ejemplo n.º 1
0
static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
{
	gint mode = e->xfocus.mode;
	gint detail = e->xfocus.detail;
	Window win = e->xany.window;
	if(e->type == FocusIn) {
		if(mode == NotifyGrab)
			return FALSE;
		if(mode == NotifyUngrab)
			return FALSE;
		if(win == DefaultRootWindow(t_display)) {
			if(in_client_only)
				return FALSE;
			else if(detail == NotifyPointerRoot || detail == NotifyDetailNone || detail == NotifyInferior
				|| detail == NotifyNonlinear)
				return TRUE;
			else
				return FALSE;
		}
		if(in_client_only) {
			struct wm_window *w = window_find(e->xfocus.window);
			if(!w || !WINDOW_IS_CLIENT(w))
				return FALSE;
		} else {
			if(detail == NotifyInferior)
				return TRUE;
		}
		if(detail == NotifyVirtual)
			return TRUE;
		if(detail == NotifyNonlinearVirtual)
			return TRUE;
		return FALSE;
	} else {
		g_assert(e->type == FocusOut);
		if(mode == NotifyGrab)
			return FALSE;
		if(mode == NotifyUngrab)
			return FALSE;
		if(win == DefaultRootWindow(t_display))
			return FALSE;
		if(detail == NotifyVirtual)
			return TRUE;
		if(detail == NotifyNonlinearVirtual)
			return TRUE;
		return FALSE;
	}
}
Ejemplo n.º 2
0
PyObject *ekg_cmd_window_get(PyObject * self, PyObject * pyargs)
{
	char * name = NULL;
	window_t *w;

	if (!PyArg_ParseTuple(pyargs, "s", &name))
		return NULL;

	debug("[python] checking for window '%s'\n", name);

	w = window_find(name);
	if (!w) {
		Py_RETURN_NONE;
	} else {
		debug("[python] Building object for window '%s'\n", name);
		return (PyObject *)python_build_window_w(w);
	}
}
Ejemplo n.º 3
0
void window_manage_all(void)
{
    guint i, j, nchild;
    Window w, *children;
    XWMHints *wmhints;
    XWindowAttributes attrib;

    if (!XQueryTree(obt_display, RootWindow(obt_display, ob_screen),
                    &w, &w, &children, &nchild)) {
        ob_debug("XQueryTree failed in window_manage_all");
        nchild = 0;
    }

    /* remove all icon windows from the list */
    for (i = 0; i < nchild; i++) {
        if (children[i] == None) continue;
        wmhints = XGetWMHints(obt_display, children[i]);
        if (wmhints) {
            if ((wmhints->flags & IconWindowHint) &&
                (wmhints->icon_window != children[i]))
                for (j = 0; j < nchild; j++)
                    if (children[j] == wmhints->icon_window) {
                        /* XXX watch the window though */
                        children[j] = None;
                        break;
                    }
            XFree(wmhints);
        }
    }

    for (i = 0; i < nchild; ++i) {
        if (children[i] == None) continue;
        if (window_find(children[i])) continue; /* skip our own windows */
        if (XGetWindowAttributes(obt_display, children[i], &attrib)) {
            if (attrib.map_state == IsUnmapped)
                ;
            else
                window_manage(children[i]);
        }
    }

    if (children) XFree(children);
}
Ejemplo n.º 4
0
PyObject *ekg_cmd_window_new(PyObject * self, PyObject * pyargs)
{
	char * name = NULL;
	window_t *w;

	if (!PyArg_ParseTuple(pyargs, "s", &name))
		return NULL;

	debug("[python] checking for window '%s'\n", name);

	w = window_find(name);
	if (w) {
		PyErr_SetString(PyExc_RuntimeError, _("Window with this name already exists"));
		return NULL;
	}

	debug("[python] Building object for window '%s'\n", name);
	w = window_new(name, window_current->session, 0);
	return (PyObject *)python_build_window_w(w);
}
Ejemplo n.º 5
0
void window_manage_all(void)
{
	guint i, j, nchild;
	Window w, *children;
	XWMHints *wmhints;
	XWindowAttributes attrib;
	if(!XQueryTree(t_display, DefaultRootWindow(t_display), &w, &w, &children, &nchild)) {
		wm_debug("XQueryTree failed in window_manage_all");
		nchild = 0;
	}
	for(i = 0; i < nchild; i++) {
		if(children[i] == None)
			continue;
		wmhints = XGetWMHints(t_display, children[i]);
		if(wmhints) {
			if((wmhints->flags & IconWindowHint) && (wmhints->icon_window != children[i]))
				for(j = 0; j < nchild; j++)
					if(children[j] == wmhints->icon_window) {
						children[j] = None;
						break;
					}
			XFree(wmhints);
		}
	}
	for(i = 0; i < nchild; ++i) {
		if(children[i] == None)
			continue;
		if(window_find(children[i]))
			continue;
		if(XGetWindowAttributes(t_display, children[i], &attrib)) {
			if(attrib.map_state == IsUnmapped);
			else
				window_manage(children[i]);
		}
	}
	if(children)
		XFree(children);
}
Ejemplo n.º 6
0
/**
 * Retrieves and processes single X event.
 */
static int process_event(int slice)
{
	xevent_t e;
	struct timeval tv = { 0, slice * 1000 };

	if (!options.abort_wait && xhandler_get_xevent_timed(&e.ev, &tv)) {
		if (e.ev.type == xhandler.damage_event_num + XDamageNotify) {
			XDamageNotifyEvent *dev = &e.dev;
			int xpos = dev->area.x + dev->geometry.x;
			int ypos = dev->area.y + dev->geometry.y;
			/* check if the damage are is in the monitoring area */
			if (xpos + dev->area.width >= options.interested_damage_rect.x && xpos <= (options.interested_damage_rect.x
					+ options.interested_damage_rect.width) && ypos + dev->area.height >= options.interested_damage_rect.y &&
					ypos <= (options.interested_damage_rect.y + options.interested_damage_rect.height)) {
				if (!match_exclude_rules(dev)) {
					window_t* win = window_find(dev->drawable);
					report_add_message(dev->timestamp, "Got damage event %dx%d+%d+%d from 0x%lx (%s)\n", dev->area.width,
							dev->area.height, xpos, ypos, dev->drawable,
							win && win->application ? win->application->name : "unknown");

					if (response.last_action_time) {
						window_t* win = window_find(dev->drawable);
						if (win && win->application) {
							application_register_damage(win->application, dev);
						}
					}
				}
			}
			XDamageSubtract(xhandler.display, dev->damage, None, None);
		} else if (e.ev.type == CreateNotify) {
			/* check new windows if we have to monitor them */
			XCreateWindowEvent* ev = &e.cev;
			/* TODO: Check if we really must monitor only main windows.
			 Probably done to avoid double reporting. We could avoid that by
			 going through monitored window list, checking if this window
			 is in the parent chain of any monitored window. If so, remove the child.
			 Might be expensive though, but worth a try.
			 */
			if (ev->parent == DefaultRootWindow(xhandler.display)) {
				window_t* win = window_try_monitor(ev->window);
				if (win) {
					Time start = xhandler_get_server_time();
					report_add_message(start, "Created window 0x%lx (%s)\n", ev->window,
							win->application ? win->application->name : "unknown");
				}
			}
		} else if (e.ev.type == UnmapNotify) {
			XUnmapEvent* ev = &e.uev;
			window_t* win = window_find(ev->window);
			if (win) {
				Time start = xhandler_get_server_time();
				report_add_message(start, "Unmapped window 0x%lx (%s)\n", ev->window,
						win->application ? win->application->name : "unknown");
			}
		} else if (e.ev.type == MapNotify) {
			XMapEvent* ev = &e.mev;
			window_t* win = window_find(ev->window);
			if (win) {
				Time start = xhandler_get_server_time();
				report_add_message(start, "Mapped window 0x%lx (%s)\n", ev->window,
						win->application ? win->application->name : "unknown");
			}
		} else if (e.ev.type == DestroyNotify) {
			XDestroyWindowEvent* ev = (XDestroyWindowEvent*) &e.dstev;
			window_t* win = window_find(ev->window);
			if (win) {
				Time start = xhandler_get_server_time();
				report_add_message(start, "Destroyed window 0x%lx (%s)\n", ev->window,
						win->application ? win->application->name : "unknown");
				window_remove(win);
			}
		} else {
			/* remove to avoid reporting unwanted even types ?
			 with window creation monitoring there are more unhandled event types */
			/* fprintf(stderr, "Got unwanted event type %d\n", e.type); */
		}
		return e.ev.type;
	}
	return 0;
}