Ejemplo n.º 1
0
void
meta_bell_notify (MetaDisplay *display,
		  XkbAnyEvent *xkb_ev)
{
  MetaWindow *window;
  XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent*) xkb_ev;

  window = meta_display_lookup_x_window (display, xkb_bell_event->window);
  if (!window && display->focus_window && display->focus_window->frame)
    window = display->focus_window;

  /* flash something */
  if (meta_prefs_get_visual_bell ())
    bell_visual_notify (display, window);

  if (meta_prefs_bell_is_audible ())
    {
      if (!bell_audible_notify (display, window))
        {
          /* Force a classic bell if the libcanberra bell failed. */
          XkbForceDeviceBell (display->xdisplay,
                              xkb_bell_event->device,
                              xkb_bell_event->bell_class,
                              xkb_bell_event->bell_id,
                              xkb_bell_event->percent);
        }
    }
}
Ejemplo n.º 2
0
gboolean
meta_bell_init (MetaDisplay *display)
{
  int xkb_base_error_type, xkb_opcode;

  if (!XkbQueryExtension (display->xdisplay, &xkb_opcode,
			  &display->xkb_base_event_type,
			  &xkb_base_error_type,
			  NULL, NULL))
    {
      display->xkb_base_event_type = -1;
      g_message ("could not find XKB extension.");
      return FALSE;
    }
  else
    {
      unsigned int mask = XkbBellNotifyMask;
      gboolean visual_bell_auto_reset = FALSE;
      /* TRUE if and when non-broken version is available */
      XkbSelectEvents (display->xdisplay,
		       XkbUseCoreKbd,
		       XkbBellNotifyMask,
		       XkbBellNotifyMask);
      meta_bell_set_audible (display, meta_prefs_bell_is_audible ());
      if (visual_bell_auto_reset) {
	XkbSetAutoResetControls (display->xdisplay,
				 XkbAudibleBellMask,
				 &mask,
				 &mask);
      }
      return TRUE;
    }
  return FALSE;
}
Ejemplo n.º 3
0
void
meta_bell_notify (MetaDisplay *display, 
		  XkbAnyEvent *xkb_ev)
{
  /* flash something */
  if (meta_prefs_get_visual_bell ()) 
    bell_visual_notify (display, xkb_ev);

  if (meta_prefs_bell_is_audible ()) 
    {
      XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent*) xkb_ev;

#ifdef HAVE_CANBERRA
      ca_proplist *p;
      MetaWindow *window;
      int res;

      ca_proplist_create (&p);
      ca_proplist_sets (p, CA_PROP_EVENT_ID, "bell-window-system");
      ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, _("Bell event"));
      ca_proplist_sets (p, CA_PROP_CANBERRA_CACHE_CONTROL, "permanent");

      window = meta_display_lookup_x_window (display, xkb_bell_event->window);
      if (!window && (display->focus_window) && (display->focus_window->frame))
        window = display->focus_window;

      if (window)
        { 
          ca_proplist_sets (p, CA_PROP_WINDOW_NAME, window->title);
          ca_proplist_setf (p, CA_PROP_WINDOW_X11_XID, "%lu", (unsigned long)window->xwindow);
          ca_proplist_sets (p, CA_PROP_APPLICATION_NAME, window->res_name);
          ca_proplist_setf (p, CA_PROP_APPLICATION_PROCESS_ID, "%d", window->net_wm_pid);
        }

      /* First, we try to play a real sound ... */
      res = ca_context_play_full (ca_gtk_context_get (), 1, p, NULL, NULL);

      ca_proplist_destroy (p);

      if (res != CA_SUCCESS && res != CA_ERROR_DISABLED)
#else
      if (1)
#endif /* HAVE_CANBERRA */
        {      
          /* ...and in case that failed we use the classic X11 bell. */
          XkbForceDeviceBell (display->xdisplay, 
                              xkb_bell_event->device, 
                              xkb_bell_event->bell_class, 
                              xkb_bell_event->bell_id, 
                              xkb_bell_event->percent);
        }
    }
}
Ejemplo n.º 4
0
gboolean
meta_bell_notify (MetaDisplay *display,
                  MetaWindow  *window)
{
  /* flash something */
  if (meta_prefs_get_visual_bell ())
    bell_visual_notify (display, window);

  if (meta_prefs_bell_is_audible ())
    return bell_audible_notify (display, window);

  return TRUE;
}