Exemplo n.º 1
0
gboolean
meta_begin_modal_for_plugin (MetaCompositor   *compositor,
                             MetaPlugin       *plugin,
                             MetaModalOptions  options,
                             guint32           timestamp)
{
  /* To some extent this duplicates code in meta_display_begin_grab_op(), but there
   * are significant differences in how we handle grabs that make it difficult to
   * merge the two.
   */
  MetaDisplay *display = compositor->display;

  if (is_modal (display) || display->grab_op != META_GRAB_OP_NONE)
    return FALSE;

  /* XXX: why is this needed? */
  XIUngrabDevice (display->xdisplay,
                  META_VIRTUAL_CORE_POINTER_ID,
                  timestamp);
  XSync (display->xdisplay, False);

  if (!grab_devices (options, timestamp))
    return FALSE;

  display->grab_op = META_GRAB_OP_COMPOSITOR;
  display->event_route = META_EVENT_ROUTE_COMPOSITOR_GRAB;
  display->grab_window = NULL;
  display->grab_have_pointer = TRUE;
  display->grab_have_keyboard = TRUE;

  g_signal_emit_by_name (display, "grab-op-begin",
                         meta_plugin_get_screen (plugin),
                         display->grab_window, display->grab_op);

  if (meta_is_wayland_compositor ())
    {
      meta_display_sync_wayland_input_focus (display);
      meta_display_cancel_touch (display);
    }

  return TRUE;
}
Exemplo n.º 2
0
/**
 * Shows the popup window, and grab the focus.
 *
 * @param window a PopupWindow instance.
 */
void
popup_window_show(PopupWindow *window)
{
	GtkWidget *popup_window = window->popup_window;
	GtkWidget *vol_scale = window->vol_scale;

	/* Update window elements at first */
	update_mute_check(GTK_TOGGLE_BUTTON(window->mute_check),
	                  G_CALLBACK(on_mute_check_toggled), window,
	                  audio_is_muted(window->audio));
	update_volume_slider(window->vol_scale_adj,
	                     audio_get_volume(window->audio));

	/* Show the window */
	gtk_widget_show_now(popup_window);

	/* Give focus to volume scale */
	gtk_widget_grab_focus(vol_scale);

	/* Grab mouse and keyboard */
	grab_devices(popup_window);
}