コード例 #1
0
ファイル: eggtrayicon.c プロジェクト: rustyangel/claws-mail
static void
egg_tray_icon_update_manager_window (EggTrayIcon *icon)
{
    Display *xdisplay;

#if HAVE_GTK_MULTIHEAD
    xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
#else
    xdisplay = gdk_display;
#endif

    if (icon->manager_window != None)
    {
        GdkWindow *gdkwin;

#if HAVE_GTK_MULTIHEAD
        gdkwin = gdk_window_lookup_for_display (display,
                                                icon->manager_window);
#else
        gdkwin = gdk_window_lookup (icon->manager_window);
#endif

        gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

    XGrabServer (xdisplay);

    icon->manager_window = XGetSelectionOwner (xdisplay,
                           icon->selection_atom);

    if (icon->manager_window != None)
        XSelectInput (xdisplay,
                      icon->manager_window, StructureNotifyMask);

    XUngrabServer (xdisplay);
    XFlush (xdisplay);

    if (icon->manager_window != None)
    {
        GdkWindow *gdkwin;

#if HAVE_GTK_MULTIHEAD
        gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
                                                icon->manager_window);
#else
        gdkwin = gdk_window_lookup (icon->manager_window);
#endif

        gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);

        /* Send a request that we'd like to dock */
        egg_tray_icon_send_dock_request (icon);
    }
}
コード例 #2
0
ファイル: rbgdkwindow.c プロジェクト: geoffyoungs/ruby-gnome2
static VALUE
gdkwin_lookup(int argc, VALUE *argv, VALUE self)
{
    VALUE arg[2];
    GdkWindow * win = NULL;
    
    rb_scan_args(argc, argv, "11", &arg[0], &arg[1]);

    switch(argc)
    {
      case 1:
    	win = gdk_window_lookup(RVAL2GDKNATIVEWINDOW(arg[0]));
	break;
      case 2:
#if GTK_CHECK_VERSION(2,2,0)
    	win = gdk_window_lookup_for_display(RVAL2GOBJ(arg[0]), RVAL2GDKNATIVEWINDOW(arg[1])); 
#else
    	win = gdk_window_lookup(NUM2UINT(arg[1])); 
        rb_warn("Not supported in GTK+-2.0.x.");
#endif
    	break;
    }
    if (win == NULL)
        return Qnil;
    else {
        return GOBJ2RVAL(win);
    }
}
コード例 #3
0
ファイル: tray_widget.c プロジェクト: voidptr/xneur-option
static void tray_widget_update_manager_window(struct _tray_widget_icon *widget_icon, gboolean dock_if_realized)
{
	if (widget_icon->manager_window != None)
		return;

	Display *display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(GTK_WIDGET(widget_icon)));

	XGrabServer(display);
  
	widget_icon->manager_window = XGetSelectionOwner(display, widget_icon->selection_atom);

	if (widget_icon->manager_window != None)
		XSelectInput(display, widget_icon->manager_window, StructureNotifyMask | PropertyChangeMask);

	XUngrabServer(display);
	XFlush(display);
  
	if (widget_icon->manager_window == None)
		return;

	GdkWindow *gdk_window = gdk_window_lookup_for_display(gtk_widget_get_display(GTK_WIDGET(widget_icon)), widget_icon->manager_window);

	gdk_window_add_filter(gdk_window, tray_widget_filter, widget_icon);

	if (dock_if_realized && GTK_WIDGET_REALIZED(widget_icon))
		tray_widget_send_dock_request(widget_icon);

	tray_widget_get_orientation_property(widget_icon);
}
コード例 #4
0
static void
egg_tray_icon_unrealize (GtkWidget *widget)
{
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkWindow *root_window;

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

#if GTK_CHECK_VERSION(2,1,0)
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
                                              icon->manager_window);
#else
      gdkwin = gdk_window_lookup (icon->manager_window);
#endif

      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

#if GTK_CHECK_VERSION(2,1,0)
  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
#else
  root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
#endif

  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
コード例 #5
0
ファイル: eggtrayicon.c プロジェクト: Bluehorn/wxPython
static void
egg_tray_icon_unrealize (GtkWidget *widget)
{
#ifdef GDK_WINDOWING_X11
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkWindow *root_window;

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
                                              icon->manager_window);

      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));

  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
#endif
}
コード例 #6
0
ファイル: glue.c プロジェクト: rswarbrick/clg
GdkWindow *clg_gdk_cairo_surface_get_window (cairo_surface_t *surface)
{
  /* If 'surface_info_key' had been public we would have had a
     portable way to find the GdkWindow of a Cairo surface. */
  
#ifdef GDK_WINDOWING_X11
  g_return_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_XLIB);
  
  Display* display = cairo_xlib_surface_get_display (surface);
  if (display) {
    Drawable window = cairo_xlib_surface_get_drawable (surface);
    if (window)
      return gdk_window_lookup_for_display (window, display);
  }

  return NULL;
#elif defined (G_OS_WIN32)
  HDC hdc = (HDC)cairo_win32_surface_get_dc (surface);
  if (hdc)
    return gdk_window_lookup ((GdkNativeWindow)hdc);
  else
    return NULL;
#else
  return NULL;
#endif
}
コード例 #7
0
ファイル: rbgdkwindow.c プロジェクト: Vasfed/ruby-gnome2
static VALUE
rg_s_lookup(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE arg[2];
    GdkWindow * win = NULL;

    rb_scan_args(argc, argv, "11", &arg[0], &arg[1]);

    switch(argc)
    {
      case 1:
        win = gdk_window_lookup(RVAL2GDKNATIVEWINDOW(arg[0]));
        break;
      case 2:
        win = gdk_window_lookup_for_display(RVAL2GOBJ(arg[0]), RVAL2GDKNATIVEWINDOW(arg[1]));
        break;
    default:
        break;
    }
    if (win == NULL)
        return Qnil;
    else {
        return GOBJ2RVAL(win);
    }
}
コード例 #8
0
static void really_make_transient(GtkWidget *window, ALLEGRO_DISPLAY_XGLX *glx)
{
   GdkDisplay *gdk = gdk_drawable_get_display(GDK_DRAWABLE(window->window));
   GdkWindow *parent = gdk_window_lookup_for_display(gdk, glx->window);
   if (!parent)
      parent = gdk_window_foreign_new_for_display(gdk, glx->window);
   gdk_window_set_transient_for(window->window, parent);
}
コード例 #9
0
ファイル: tray_widget.c プロジェクト: voidptr/xneur-option
static void tray_widget_manager_window_destroyed(struct _tray_widget_icon *widget_icon)
{
	g_return_if_fail(widget_icon->manager_window != None);

	GdkWindow *gdk_window = gdk_window_lookup_for_display(gtk_widget_get_display(GTK_WIDGET(widget_icon)), widget_icon->manager_window);

	gdk_window_remove_filter(gdk_window, tray_widget_filter, widget_icon);

	widget_icon->manager_window = None;

	tray_widget_update_manager_window(widget_icon, TRUE);
}
コード例 #10
0
ファイル: tray_widget.c プロジェクト: voidptr/xneur-option
static void tray_widget_unrealize(GtkWidget *widget)
{
	struct _tray_widget_icon *widget_icon = TRAY_WIDGET_ICON(widget);

	if (widget_icon->manager_window != None)
	{
		GdkWindow *gdk_window = gdk_window_lookup_for_display(gtk_widget_get_display(widget), widget_icon->manager_window);
		gdk_window_remove_filter(gdk_window, tray_widget_filter, widget_icon);
	}

	GdkWindow *gdk_window = gdk_screen_get_root_window(gtk_widget_get_screen(widget));
	gdk_window_remove_filter(gdk_window, tray_widget_filter, widget_icon);

	if (GTK_WIDGET_CLASS(parent_class)->unrealize)
		(* GTK_WIDGET_CLASS(parent_class)->unrealize)(widget);
}
コード例 #11
0
ファイル: eggtrayicon.c プロジェクト: Bluehorn/wxPython
static void
egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
{
  GdkWindow *gdkwin;
  
  g_return_if_fail (icon->manager_window != None);

  gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
					  icon->manager_window);
      
  gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);

  icon->manager_window = None;

  egg_tray_icon_update_manager_window (icon, TRUE);
}
コード例 #12
0
ファイル: eggtrayicon.cpp プロジェクト: gogonkt/gcin
static void
egg_tray_icon_update_manager_window (EggTrayIcon *icon,
				     gboolean     dock_if_realized)
{
  Display *xdisplay;

  if (icon->manager_window != None)
    return;

#if GTK_CHECK_VERSION(2,1,0)
  xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
#else
  xdisplay = gdk_display;
#endif

  XGrabServer (xdisplay);

  icon->manager_window = XGetSelectionOwner (xdisplay,
					     icon->selection_atom);

  if (icon->manager_window != None)
    XSelectInput (xdisplay,
		  icon->manager_window, StructureNotifyMask|PropertyChangeMask);

  XUngrabServer (xdisplay);
  XFlush (xdisplay);

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

#if GTK_CHECK_VERSION(2,1,0)
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
					      icon->manager_window);
#else
      gdkwin = gdk_window_lookup (icon->manager_window);
#endif

      gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);

      if (dock_if_realized && GTK_WIDGET_REALIZED (GTK_WIDGET (icon)))
	egg_tray_icon_send_dock_request (icon);

      egg_tray_icon_get_orientation_property (icon);
    }
}
コード例 #13
0
ファイル: ui.c プロジェクト: fatman2021/marco
static gboolean
maybe_redirect_mouse_event (XEvent *xevent)
{
  GdkDisplay *gdisplay;
  MetaUI *ui;
#if GTK_CHECK_VERSION (3, 0, 0)
  GdkDeviceManager *gmanager;
  GdkDevice *gdevice;
  GdkEvent *gevent;
#else
  GdkEvent gevent;
#endif
  GdkWindow *gdk_window;
  Window window;

  switch (xevent->type)
    {
    case ButtonPress:
    case ButtonRelease:
      window = xevent->xbutton.window;
      break;
    case MotionNotify:
      window = xevent->xmotion.window;
      break;
    case EnterNotify:
    case LeaveNotify:
      window = xevent->xcrossing.window;
      break;
    default:
      return FALSE;
    }

  gdisplay = gdk_x11_lookup_xdisplay (xevent->xany.display);
  ui = g_object_get_data (G_OBJECT (gdisplay), "meta-ui");
  if (!ui)
    return FALSE;

#if GTK_CHECK_VERSION (3, 0, 0)
  gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window);
#else
  gdk_window = gdk_window_lookup_for_display (gdisplay, window);
#endif
  if (gdk_window == NULL)
    return FALSE;

#if GTK_CHECK_VERSION (3, 0, 0)
  gmanager = gdk_display_get_device_manager (gdisplay);
  gdevice = gdk_device_manager_get_client_pointer (gmanager);
#endif

  /* If GDK already thinks it has a grab, we better let it see events; this
   * is the menu-navigation case and events need to get sent to the appropriate
   * (client-side) subwindow for individual menu items.
   */
#if GTK_CHECK_VERSION (3, 0, 0)
  if (gdk_display_device_is_grabbed (gdisplay, gdevice))
#else
  if (gdk_display_pointer_is_grabbed (gdisplay))
#endif
    return FALSE;

#if !GTK_CHECK_VERSION (3, 0, 0)
  memset (&gevent, 0, sizeof (gevent));
#endif

  switch (xevent->type)
    {
    case ButtonPress:
    case ButtonRelease:
      if (xevent->type == ButtonPress)
        {
          GtkSettings *settings = gtk_settings_get_default ();
          int double_click_time;
          int double_click_distance;

          g_object_get (settings,
                        "gtk-double-click-time", &double_click_time,
                        "gtk-double-click-distance", &double_click_distance,
                        NULL);

          if (xevent->xbutton.button == ui->button_click_number &&
              xevent->xbutton.window == ui->button_click_window &&
              xevent->xbutton.time < ui->button_click_time + double_click_time &&
              ABS (xevent->xbutton.x - ui->button_click_x) <= double_click_distance &&
              ABS (xevent->xbutton.y - ui->button_click_y) <= double_click_distance)
            {
#if GTK_CHECK_VERSION (3, 0, 0)
              gevent = gdk_event_new (GDK_2BUTTON_PRESS);
#else
              gevent.button.type = GDK_2BUTTON_PRESS;
#endif

              ui->button_click_number = 0;
            }
          else
            {
#if GTK_CHECK_VERSION (3, 0, 0)
              gevent = gdk_event_new (GDK_BUTTON_PRESS);
#else
              gevent.button.type = GDK_BUTTON_PRESS;
#endif
              ui->button_click_number = xevent->xbutton.button;
              ui->button_click_window = xevent->xbutton.window;
              ui->button_click_time = xevent->xbutton.time;
              ui->button_click_x = xevent->xbutton.x;
              ui->button_click_y = xevent->xbutton.y;
            }
        }
      else
        {
#if GTK_CHECK_VERSION (3, 0, 0)
          gevent = gdk_event_new (GDK_BUTTON_RELEASE);
#else
          gevent.button.type = GDK_BUTTON_RELEASE;
#endif
        }

#if GTK_CHECK_VERSION (3, 0, 0)
      gevent->button.window = g_object_ref (gdk_window);
      gevent->button.button = xevent->xbutton.button;
      gevent->button.time = xevent->xbutton.time;
      gevent->button.x = xevent->xbutton.x;
      gevent->button.y = xevent->xbutton.y;
      gevent->button.x_root = xevent->xbutton.x_root;
      gevent->button.y_root = xevent->xbutton.y_root;
#else
      gevent.button.window = gdk_window;
      gevent.button.button = xevent->xbutton.button;
      gevent.button.time = xevent->xbutton.time;
      gevent.button.x = xevent->xbutton.x;
      gevent.button.y = xevent->xbutton.y;
      gevent.button.x_root = xevent->xbutton.x_root;
      gevent.button.y_root = xevent->xbutton.y_root;
#endif

      break;
    case MotionNotify:
#if GTK_CHECK_VERSION (3, 0, 0)
      gevent = gdk_event_new (GDK_MOTION_NOTIFY);
      gevent->motion.type = GDK_MOTION_NOTIFY;
      gevent->motion.window = g_object_ref (gdk_window);
#else
      gevent.motion.type = GDK_MOTION_NOTIFY;
      gevent.motion.window = gdk_window;
#endif
      break;
    case EnterNotify:
    case LeaveNotify:
#if GTK_CHECK_VERSION (3, 0, 0)
      gevent = gdk_event_new (xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
      gevent->crossing.window = g_object_ref (gdk_window);
      gevent->crossing.x = xevent->xcrossing.x;
      gevent->crossing.y = xevent->xcrossing.y;
#else
      gevent.crossing.type = xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
      gevent.crossing.window = gdk_window;
      gevent.crossing.x = xevent->xcrossing.x;
      gevent.crossing.y = xevent->xcrossing.y;
#endif
      break;
    default:
      g_assert_not_reached ();
      break;
    }

  /* If we've gotten here, we've filled in the gdk_event and should send it on */
#if GTK_CHECK_VERSION (3, 0, 0)
  gdk_event_set_device (gevent, gdevice);
  gtk_main_do_event (gevent);
  gdk_event_free (gevent);
#else
  gtk_main_do_event (&gevent);
#endif

  return TRUE;
}