コード例 #1
0
ファイル: main.c プロジェクト: kinnalru/x2wintray
void property_notify(XPropertyEvent ev)
{
#define TRACE_PROPS
#if defined(DEBUG) && defined(TRACE_PROPS)
	char *atom_name;
	atom_name = XGetAtomName(tray_data.dpy, ev.atom);
	LOG_TRACE(("atom = %s\n", atom_name));
	XFree(atom_name);
#endif
	/* React on wallpaper change */
	if (ev.atom == tray_data.xa_xrootpmap_id || ev.atom == tray_data.xa_xsetroot_id) {
		if (settings.transparent) tray_update_bg(True);
		if (settings.parent_bg || settings.transparent || settings.fuzzy_edges)
			tray_refresh_window(True);
	}
#ifndef NO_NATIVE_KDE
	/* React on change of list of KDE icons */
	if (ev.atom == tray_data.xa_kde_net_system_tray_windows) {
		if (tray_data.is_active) 
			kde_icons_update();
		else 
			LOG_TRACE(("not updating KDE icons list: tray is not active\n"));
		kde_tray_update_old_icons(tray_data.dpy);
	}
#endif
	/* React on WM (re)starts */
	if (ev.atom == XInternAtom(tray_data.dpy, _NET_SUPPORTING_WM_CHECK, False)) {
#ifdef DEBUG
		ewmh_list_supported_atoms(tray_data.dpy);
#endif
		tray_set_wm_hints();
#ifndef NO_NATIVE_KDE
		kde_tray_update_fallback_mode(tray_data.dpy);
#endif
	}
	/* React on _XEMBED_INFO changes of embedded icons
	 * (currently used to track icon visibility status) */
	if (ev.atom == tray_data.xembed_data.xa_xembed_info) {
		icon_track_visibility_changes(ev.window);
	}
	if (ev.atom == tray_data.xa_net_client_list) {
		Window *windows;
		unsigned long nwindows, rc, i;
		rc = x11_get_root_winlist_prop(tray_data.dpy, 
				tray_data.xa_net_client_list,
				(unsigned char **) &windows,
				&nwindows);
		if (x11_ok() && rc) {
			tray_data.is_reparented = True;
			for(i = 0; i < nwindows; i++) 
				if (windows[i] == tray_data.tray) {
					tray_data.is_reparented = False;
					break;
				}
		}
		if (nwindows) XFree(windows);
		LOG_TRACE(("tray was %sreparented\n", tray_data.is_reparented ? "" : "not "));
	}
}
コード例 #2
0
ファイル: systray.c プロジェクト: ramonelalto/gambas
/* main() for usual operation */
static void tray_main(int argc, char **argv, Window window)
{
	X11_enable_event_filter(TRUE);
	/* Interpret those settings that need an open display */
	//interpret_settings();
#ifdef DEBUG
	ewmh_list_supported_atoms(tray_data.dpy);
#endif
	/* Create and show tray window */
	tray_create_window(argc, argv, window);
	tray_acquire_selection();
	//tray_show_window();
#ifndef NO_NATIVE_KDE
	kde_tray_init(tray_data.dpy);
#endif
	xembed_init();
#ifndef NO_NATIVE_KDE
	kde_icons_update();
#endif
}
コード例 #3
0
ファイル: main.c プロジェクト: kinnalru/x2wintray
/* main() for usual operation */
int tray_main(int argc, char **argv)
{
	XEvent		ev;
	/* Interpret those settings that need an open display */
	interpret_settings();
#ifdef DEBUG
	ewmh_list_supported_atoms(tray_data.dpy);
#endif
	/* Create and show tray window */
	tray_create_window(argc, argv);
	tray_acquire_selection();
	tray_show_window();
#ifndef NO_NATIVE_KDE
	kde_tray_init(tray_data.dpy);
#endif
	xembed_init();
#ifndef NO_NATIVE_KDE
	kde_icons_update();
#endif
	/* Main event loop */
	while ("my guitar gently wheeps") {
		/* This is ugly and extra dependency. But who cares?
		 * Rationale: we want to block unless absolutely needed.
		 * This way we ensure that stalonetray does not show up
		 * in powertop (i.e. does not eat unnecessary power and
		 * CPU cycles) 
		 * Drawback: handling of signals is very limited. XNextEvent()
		 * does not if signal occurs. This means that graceful
		 * exit on e.g. Ctrl-C cannot be implemented without hacks. */
		while (XPending(tray_data.dpy) || tray_data.scrollbars_data.scrollbar_down == -1) {
			XNextEvent(tray_data.dpy, &ev);
			xembed_handle_event(ev);
			scrollbars_handle_event(ev);
			switch (ev.type) {
			case VisibilityNotify:
				LOG_TRACE(("VisibilityNotify (0x%x, state=%d)\n", ev.xvisibility.window, ev.xvisibility.state));
				visibility_notify(ev.xvisibility);
				break;
			case Expose:
				LOG_TRACE(("Expose (0x%x)\n", ev.xexpose.window));
				expose(ev.xexpose);
				break;
			case PropertyNotify:
				LOG_TRACE(("PropertyNotify(0x%x)\n", ev.xproperty.window));
				property_notify(ev.xproperty);
				break;
			case DestroyNotify:
				LOG_TRACE(("DestroyNotify(0x%x)\n", ev.xdestroywindow.window));
				destroy_notify(ev.xdestroywindow);
				break;
			case ClientMessage:
				LOG_TRACE(("ClientMessage(from 0x%x?)\n", ev.xclient.window));
				client_message(ev.xclient);
				break;
			case ConfigureNotify:
				LOG_TRACE(("ConfigureNotify(0x%x)\n", ev.xconfigure.window));
				configure_notify(ev.xconfigure);
				break;
			case MapNotify:
				LOG_TRACE(("MapNotify(0x%x)\n", ev.xmap.window));
				map_notify(ev.xmap);
				break;
			case ReparentNotify:
				LOG_TRACE(("ReparentNotify(0x%x to 0x%x)\n", ev.xreparent.window, ev.xreparent.parent));
				reparent_notify(ev.xreparent);
				break;
			case SelectionClear:
				LOG_TRACE(("SelectionClear (0x%x has lost selection)\n", ev.xselectionclear.window));
				selection_clear(ev.xselectionclear);
				break;
			case SelectionNotify:
				LOG_TRACE(("SelectionNotify\n"));
				break;
			case SelectionRequest:
				LOG_TRACE(("SelectionRequest (from 0x%x to 0x%x)\n", ev.xselectionrequest.requestor, ev.xselectionrequest.owner));
				break;
			case UnmapNotify:
				LOG_TRACE(("UnmapNotify(0x%x)\n", ev.xunmap.window));
				unmap_notify(ev.xunmap);
				break;
			default:
#if defined(DEBUG) && defined(TRACE_EVENTS)
				LOG_TRACE(("Unhandled event: %s, serial: %d, window: 0x%x\n", x11_event_names[ev.type], ev.xany.serial, ev.xany.window));
#endif
				break;
			}
			if (tray_data.terminated) goto bailout;
			/* Perform all periodic tasks but for scrollbars */
			perform_periodic_tasks(PT_MASK_ALL & (~PT_MASK_SB));
		}
		perform_periodic_tasks(PT_MASK_ALL);
                my_usleep(500000L);
	}
bailout:
	LOG_TRACE(("Clean exit\n"));
	return 0;
}