GdkFilterReturn 
client_event_filter (GdkXEvent *xevent,
		     GdkEvent  *event,
		     gpointer   data)
{
  if (xsettings_client_process_event (client, (XEvent *)xevent))
    return GDK_FILTER_REMOVE;
  else
    return GDK_FILTER_CONTINUE;
}
示例#2
0
static GdkFilterReturn
gdk_xsettings_client_event_filter (GdkXEvent *xevent,
				   GdkEvent  *event,
				   gpointer   data)
{
  GdkX11Screen *screen = data;

  if (xsettings_client_process_event (screen->xsettings_client, (XEvent *)xevent))
    return GDK_FILTER_REMOVE;
  else
    return GDK_FILTER_CONTINUE;
}
示例#3
0
void
mbdesktop_main(MBDesktop *mb)
{
  XEvent ev;
  Atom workarea_atom = XInternAtom(mb->dpy, "_NET_WORKAREA",False);
  MBDesktopModuleslist  *module_current = NULL;

#ifdef USE_DNOTIFY
  sigset_t block_sigset;
  sigemptyset(&block_sigset);
  sigaddset(&block_sigset, SIGRTMIN); /* XXX should also add stuff 
					 like a HUP etc .. */
#endif

  mbdesktop_view_paint(mb, True);
  XFlush(mb->dpy);

  while (1)
    {
	  if (WantReload) 	/* Triggered by dnotify signals etc */
	    {
	      mbdesktop_item_folder_contents_free(mb, mb->top_head_item);

	      mb->current_folder_item = mb->top_head_item;

	      modules_unload(mb);  /* XXX more eficient way ?  */

	      modules_init(mb);

	      mb->kbd_focus_item = mb->current_head_item 
		= mb->scroll_offset_item = mb->top_head_item->item_child;

	      mbdesktop_view_paint(mb, False);

	      WantReload = False;

	      XSync(mb->dpy, False);
	    }

	  XNextEvent(mb->dpy, &ev);

#ifdef USE_DNOTIFY 		/* Block dnotify signal */
	  sigprocmask(SIG_BLOCK, &block_sigset, NULL); 
#endif

#ifdef USE_XSETTINGS
	  if (mb->xsettings_client != NULL)
	    xsettings_client_process_event(mb->xsettings_client, &ev);
#endif
	  switch (ev.type) 
	    {
	    case MappingNotify:
	      XRefreshKeyboardMapping(&ev.xmapping);
	      break;

	    case FocusIn:
	      mb->have_focus = True;
	      mbdesktop_view_paint(mb, True);
	      break;

	    case FocusOut:
	      mbdesktop_view_paint(mb, True);
	      mb->have_focus = False;
	      break;

	    case Expose:
	      if (ev.xexpose.count > 0) 
		mbdesktop_view_paint(mb, True);
	      break;
	    case PropertyNotify:
	      if (ev.xproperty.atom == workarea_atom)
		{
		  int wx, wy, ww, wh;
		  if (mbdesktop_get_workarea(mb, &wx, &wy, &ww, &wh))
		    {
		      if (mb->workarea_x != wx 
			  || mb->workarea_y != wy
			  || mb->workarea_width != ww 
			  || mb->workarea_height != wh)
			mbdesktop_view_configure(mb);
		    }
		}
	      else if (ev.xproperty.atom == mb->atom_mb_theme)
		{
		  if (mbdesktop_get_theme_via_root_prop(mb))
		    mbdesktop_switch_theme (mb, NULL );
		}
	      break;
	      /*
	    case ConfigureRequest:
	      mbdesktop_win_plugin_configure_request(mb, 
						     &ev.xconfigurerequest);
	      break;
	      */
	    case ConfigureNotify:
	      
	      if ( ev.xconfigure.width != mb->desktop_width
		   || ev.xconfigure.height != mb->desktop_height)
		{
		  mb->desktop_width = ev.xconfigure.width;
		  mb->desktop_height = ev.xconfigure.height;
		  mbdesktop_view_configure(mb);
		}
	      break;
	    case ButtonPress:
	      handle_button_event(mb, &ev.xbutton);
	      break;
	    case KeyPress:
	      handle_key_event(mb, &ev.xkey);
	      break;
	    }

	  module_current = mb->modules;
	  while (module_current != NULL)
	    {
	      if (module_current->module_handle->mod_xevent)
		module_current->module_handle->mod_xevent(mb, module_current->module_handle, &ev);
	      module_current = module_current->next;
	    }
	  
	  /*
	  if (mb->current_folder_item 
	      && mb->current_folder_item->module_handle
	      && mb->current_folder_item->module_handle->folder_xevent)
	    {
	      mb->current_folder_item->module_handle->folder_xevent(mb, mb->current_folder_item, &ev);
	    }
	  */
#ifdef USE_DNOTIFY 		/* Unblock dnotify signal */
	  sigprocmask(SIG_UNBLOCK, &block_sigset, NULL); 
#endif

    }

}
示例#4
0
void event_property_notify(XEvent* e) {
    int i;
    Task* tsk;
    Window win = e->xproperty.window;
    Atom at = e->xproperty.atom;

    if (xsettings_client) xsettings_client_process_event(xsettings_client, e);
    if (win == server.root_win) {
        if (!server.got_root_win) {
            XSelectInput(server.dsp, server.root_win,
                         PropertyChangeMask | StructureNotifyMask);
            server.got_root_win = 1;
        }

        // Change name of desktops
        else if (at == server.atom._NET_DESKTOP_NAMES) {
            if (!taskbarname_enabled) return;
            GSList* l, *list = server_get_name_of_desktop();
            gchar* name;
            Taskbar* tskbar;
            for (i = 0; i < nb_panel; i++) {
                l = list;
                for (uint8_t j = 0; j < panel1[i].desktop_count; j++) {
                    if (l) {
                        name = g_strdup(l->data);
                        l = l->next;
                    } else
                        name = g_strdup_printf("%d", j + 1);
                    tskbar = &panel1[i].taskbar[j];
                    if (strcmp(name, tskbar->bar_name.name) != 0) {
                        g_free(tskbar->bar_name.name);
                        tskbar->bar_name.name = name;
                        tskbar->bar_name.area.resize = 1;
                    } else
                        g_free(name);
                }
            }
            for (l = list; l; l = l->next) g_free(l->data);
            g_slist_free(list);
            panel_refresh = 1;
        }
        // Change number of desktops
        else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
            if (!taskbar_enabled) return;
            server.nb_desktop = server_get_number_of_desktop();
            if (server.nb_desktop <= server.desktop) {
                server.desktop = server.nb_desktop - 1;
            }
            cleanup_taskbar();
            init_taskbar();
            for (i = 0; i < nb_panel; i++) {
                init_taskbar_panel(&panel1[i]);
                set_panel_items_order(&panel1[i]);
                visible_taskbar(&panel1[i]);
                panel1[i].area.resize = 1;
            }
            task_refresh_tasklist();
            active_task();
            panel_refresh = 1;
        }
        // Change desktop
        else if (at == server.atom._NET_CURRENT_DESKTOP) {
            if (!taskbar_enabled) return;
            int old_desktop = server.desktop;
            server.desktop = server_get_current_desktop();
            for (i = 0; i < nb_panel; i++) {
                Panel* panel = &panel1[i];
                set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL);
                set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE);
                // check ALLDESKTOP task => resize taskbar
                Taskbar* tskbar;
                Task* tsk;
                GSList* l;
                if (server.nb_desktop > old_desktop) {
                    tskbar = &panel->taskbar[old_desktop];
                    l = tskbar->area.list;
                    if (taskbarname_enabled) l = l->next;
                    for (; l; l = l->next) {
                        tsk = l->data;
                        if (tsk->desktop == ALLDESKTOP) {
                            tsk->area.on_screen = 0;
                            tskbar->area.resize = 1;
                            panel_refresh = 1;
                        }
                    }
                }
                tskbar = &panel->taskbar[server.desktop];
                l = tskbar->area.list;
                if (taskbarname_enabled) l = l->next;
                for (; l; l = l->next) {
                    tsk = l->data;
                    if (tsk->desktop == ALLDESKTOP) {
                        tsk->area.on_screen = 1;
                        tskbar->area.resize = 1;
                    }
                }
            }
        }
        // Window list
        else if (at == server.atom._NET_CLIENT_LIST) {
            task_refresh_tasklist();
            panel_refresh = 1;
        }
        // Change active
        else if (at == server.atom._NET_ACTIVE_WINDOW) {
            active_task();
            panel_refresh = 1;
        } else if (at == server.atom._XROOTPMAP_ID ||
                   at == server.atom._XROOTMAP_ID) {
            // change Wallpaper
            for (i = 0; i < nb_panel; i++) {
                set_panel_background(&panel1[i]);
            }
            panel_refresh = 1;
        }
    } else {
        tsk = task_get_task(win);
        if (!tsk) {
            if (at != server.atom._NET_WM_STATE)
                return;
            else {
                // xfce4 sends _NET_WM_STATE after minimized to tray, so we need to
                // check if window is mapped
                // if it is mapped and not set as skip_taskbar, we must add it to our
                // task list
                XWindowAttributes wa;
                XGetWindowAttributes(server.dsp, win, &wa);
                if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) {
                    if ((tsk = add_task(win)))
                        panel_refresh = 1;
                    else
                        return;
                } else
                    return;
            }
        }

        // Window title changed
        if (at == server.atom._NET_WM_VISIBLE_NAME ||
                at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
            if (get_title(tsk)) {
                if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) {
                    tooltip_copy_text((Area*)tsk);
                    tooltip_update();
                }
                panel_refresh = 1;
            }
        }
        // Demand attention
        else if (at == server.atom._NET_WM_STATE) {
            if (window_is_urgent(win)) {
                add_urgent(tsk);
            }
            if (window_is_skip_taskbar(win)) {
                remove_task(tsk);
                panel_refresh = 1;
            }
        } else if (at == server.atom.WM_STATE) {
            // Iconic state
            int state = (task_active && tsk->win == task_active->win ? TASK_ACTIVE
                         : TASK_NORMAL);
            if (window_is_iconified(win)) state = TASK_ICONIFIED;
            set_task_state(tsk, state);
            panel_refresh = 1;
        }
        // Window icon changed
        else if (at == server.atom._NET_WM_ICON) {
            get_icon(tsk);
            panel_refresh = 1;
        }
        // Window desktop changed
        else if (at == server.atom._NET_WM_DESKTOP) {
            uint32_t desktop = window_get_desktop(win);
            // bug in windowmaker : send unecessary 'desktop changed' when focus
            // changed
            if (desktop != tsk->desktop) {
                remove_task(tsk);
                tsk = add_task(win);
                active_task();
                panel_refresh = 1;
            }
        } else if (at == server.atom.WM_HINTS) {
            XWMHints* wmhints = XGetWMHints(server.dsp, win);
            if (wmhints && wmhints->flags & XUrgencyHint) {
                add_urgent(tsk);
            }
            XFree(wmhints);
        }

        if (!server.got_root_win)
            server.root_win = RootWindow(server.dsp, server.screen);
    }
}