⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkdnd-fb.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 2 页
字号:
/* GDK - The GIMP Drawing Kit * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. *//* * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS * file for a list of people on the GTK+ Team.  See the ChangeLog * files for a list of changes.  These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/.  */#include <config.h>#include "gdk.h"          /* For gdk_flush() */#include "gdkdnd.h"#include "gdkproperty.h"#include "gdkinternals.h"#include "gdkprivate-fb.h"typedef struct _GdkDragContextPrivate GdkDragContextPrivate;typedef enum {  GDK_DRAG_STATUS_DRAG,  GDK_DRAG_STATUS_MOTION_WAIT,  GDK_DRAG_STATUS_ACTION_WAIT,  GDK_DRAG_STATUS_DROP} GtkDragStatus;/* Structure that holds information about a drag in progress. * this is used on both source and destination sides. */struct _GdkDragContextPrivate {  GdkAtom local_selection;    guint16 last_x;		/* Coordinates from last event */  guint16 last_y;    guint drag_status : 4;	/* current status of drag */};/* Drag Contexts */static GList *contexts;static gpointer parent_class = NULL;#define GDK_DRAG_CONTEXT_PRIVATE_DATA(ctx) ((GdkDragContextPrivate *) GDK_DRAG_CONTEXT (ctx)->windowing_data)GdkDragContext *current_dest_drag = NULL;static voidgdk_drag_context_init (GdkDragContext *dragcontext){  dragcontext->windowing_data = g_new0 (GdkDragContextPrivate, 1);  contexts = g_list_prepend (contexts, dragcontext);}static voidgdk_drag_context_finalize (GObject *object){  GdkDragContext *context = GDK_DRAG_CONTEXT (object);  GdkDragContextPrivate *private = GDK_DRAG_CONTEXT_PRIVATE_DATA (object);    g_list_free (context->targets);  if (context->source_window)    gdk_window_unref (context->source_window);    if (context->dest_window)    gdk_window_unref (context->dest_window);    if (private)    {      g_free (private);      context->windowing_data = NULL;    }    contexts = g_list_remove (contexts, context);  G_OBJECT_CLASS (parent_class)->finalize (object);}static voidgdk_drag_context_class_init (GdkDragContextClass *klass){  GObjectClass *object_class = G_OBJECT_CLASS (klass);  parent_class = g_type_class_peek_parent (klass);  object_class->finalize = gdk_drag_context_finalize;}GTypegdk_drag_context_get_type (void){  static GType object_type = 0;  if (!object_type)    {      static const GTypeInfo object_info =      {        sizeof (GdkDragContextClass),        (GBaseInitFunc) NULL,        (GBaseFinalizeFunc) NULL,        (GClassInitFunc) gdk_drag_context_class_init,        NULL,           /* class_finalize */        NULL,           /* class_data */        sizeof (GdkDragContext),        0,              /* n_preallocs */        (GInstanceInitFunc) gdk_drag_context_init,      };            object_type = g_type_register_static (G_TYPE_OBJECT,                                            "GdkDragContext",                                            &object_info,					    0);    }    return object_type;}GdkDragContext *gdk_drag_context_new        (void){  return (GdkDragContext *)g_object_new (gdk_drag_context_get_type (), NULL);}void            gdk_drag_context_ref (GdkDragContext *context){  g_object_ref (context);}void            gdk_drag_context_unref (GdkDragContext *context){  g_object_unref (context);}static GdkDragContext *gdk_drag_context_find (gboolean     is_source,		       GdkWindow   *source,		       GdkWindow   *dest){  GList *tmp_list = contexts;    GdkDragContext *context;  GdkDragContextPrivate *private;  while (tmp_list)    {      context = (GdkDragContext *)tmp_list->data;      private = GDK_DRAG_CONTEXT_PRIVATE_DATA (context);      if ((!context->is_source == !is_source) &&	  ((source == NULL) || (context->source_window && (context->source_window == source))) &&	  ((dest == NULL) || (context->dest_window && (context->dest_window == dest))))	  return context;            tmp_list = tmp_list->next;    }    return NULL;}/************************************************************* ************************** Public API *********************** *************************************************************/void_gdk_dnd_init (void){}/* Source side */static voidlocal_send_leave (GdkDragContext  *context,		  guint32          time){  GdkEvent tmp_event;    if ((current_dest_drag != NULL) &&      (current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&      (current_dest_drag->source_window == context->source_window))    {      tmp_event.dnd.type = GDK_DRAG_LEAVE;      tmp_event.dnd.window = context->dest_window;      /* Pass ownership of context to the event */      tmp_event.dnd.context = current_dest_drag;      tmp_event.dnd.send_event = FALSE;      tmp_event.dnd.time = GDK_CURRENT_TIME; /* FIXME? */      current_dest_drag = NULL;            gdk_event_put (&tmp_event);    }  }static voidlocal_send_enter (GdkDragContext  *context,		  guint32          time){  GdkEvent tmp_event;  GdkDragContextPrivate *private;  GdkDragContext *new_context;  private = GDK_DRAG_CONTEXT_PRIVATE_DATA (context);    if (!private->local_selection)    private->local_selection = gdk_atom_intern ("LocalDndSelection", FALSE);  if (current_dest_drag != NULL)    {      gdk_drag_context_unref (current_dest_drag);      current_dest_drag = NULL;    }  new_context = gdk_drag_context_new ();  new_context->protocol = GDK_DRAG_PROTO_LOCAL;  new_context->is_source = FALSE;  new_context->source_window = context->source_window;  gdk_window_ref (new_context->source_window);  new_context->dest_window = context->dest_window;  gdk_window_ref (new_context->dest_window);  new_context->targets = g_list_copy (context->targets);  gdk_window_set_events (new_context->source_window,			 gdk_window_get_events (new_context->source_window) |			 GDK_PROPERTY_CHANGE_MASK); new_context->actions = context->actions;  tmp_event.dnd.type = GDK_DRAG_ENTER;  tmp_event.dnd.window = context->dest_window;  tmp_event.dnd.send_event = FALSE;  tmp_event.dnd.context = new_context;  gdk_drag_context_ref (new_context);  tmp_event.dnd.time = GDK_CURRENT_TIME; /* FIXME? */    current_dest_drag = new_context;    (GDK_DRAG_CONTEXT_PRIVATE_DATA (new_context))->local_selection =     private->local_selection;  gdk_event_put (&tmp_event);}static voidlocal_send_motion (GdkDragContext  *context,		    gint            x_root, 		    gint            y_root,		    GdkDragAction   action,		    guint32         time){  GdkEvent tmp_event;    if ((current_dest_drag != NULL) &&      (current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&      (current_dest_drag->source_window == context->source_window))    {      tmp_event.dnd.type = GDK_DRAG_MOTION;      tmp_event.dnd.window = current_dest_drag->dest_window;      tmp_event.dnd.send_event = FALSE;      tmp_event.dnd.context = current_dest_drag;      gdk_drag_context_ref (current_dest_drag);      tmp_event.dnd.time = time;      current_dest_drag->suggested_action = action;      current_dest_drag->actions = current_dest_drag->suggested_action;      tmp_event.dnd.x_root = x_root;      tmp_event.dnd.y_root = y_root;      (GDK_DRAG_CONTEXT_PRIVATE_DATA (current_dest_drag))->last_x = x_root;      (GDK_DRAG_CONTEXT_PRIVATE_DATA (current_dest_drag))->last_y = y_root;      GDK_DRAG_CONTEXT_PRIVATE_DATA (context)->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;            gdk_event_put (&tmp_event);    }}static voidlocal_send_drop (GdkDragContext *context, guint32 time){  GdkEvent tmp_event;    if ((current_dest_drag != NULL) &&      (current_dest_drag->protocol == GDK_DRAG_PROTO_LOCAL) &&      (current_dest_drag->source_window == context->source_window))    {      GdkDragContextPrivate *private;      private = GDK_DRAG_CONTEXT_PRIVATE_DATA (current_dest_drag);      tmp_event.dnd.type = GDK_DROP_START;      tmp_event.dnd.window = current_dest_drag->dest_window;      tmp_event.dnd.send_event = FALSE;      tmp_event.dnd.context = current_dest_drag;      gdk_drag_context_ref (current_dest_drag);      tmp_event.dnd.time = GDK_CURRENT_TIME;            tmp_event.dnd.x_root = private->last_x;      tmp_event.dnd.y_root = private->last_y;            gdk_event_put (&tmp_event);    }}static voidgdk_drag_do_leave (GdkDragContext *context, guint32 time){  if (context->dest_window)    {      switch (context->protocol)	{	case GDK_DRAG_PROTO_LOCAL:	  local_send_leave (context, time);	  break;	default:	  break;	}      gdk_window_unref (context->dest_window);      context->dest_window = NULL;    }}GdkDragContext * gdk_drag_begin (GdkWindow     *window,		GList         *targets){  GList *tmp_list;  GdkDragContext *new_context;  g_return_val_if_fail (window != NULL, NULL);  new_context = gdk_drag_context_new ();  new_context->is_source = TRUE;  new_context->source_window = window;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -