[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44195] trunk/blender: Drag-n-drop support on Linux
Sergey Sharybin
sergey.vfx at gmail.com
Fri Feb 17 17:58:16 CET 2012
Revision: 44195
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44195
Author: nazgul
Date: 2012-02-17 16:58:09 +0000 (Fri, 17 Feb 2012)
Log Message:
-----------
Drag-n-drop support on Linux
This commit implements drag-n-drop support from external applications into Blender.
Used xdnd implementation from Paul Sheer.
Modified Paths:
--------------
trunk/blender/extern/CMakeLists.txt
trunk/blender/extern/SConscript
trunk/blender/intern/ghost/CMakeLists.txt
trunk/blender/intern/ghost/SConscript
trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
trunk/blender/intern/ghost/intern/GHOST_SystemX11.h
trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp
trunk/blender/intern/ghost/intern/GHOST_WindowX11.h
trunk/blender/source/creator/CMakeLists.txt
Added Paths:
-----------
trunk/blender/extern/xdnd/
trunk/blender/extern/xdnd/CMakeLists.txt
trunk/blender/extern/xdnd/SConscript
trunk/blender/extern/xdnd/xdnd.c
trunk/blender/extern/xdnd/xdnd.h
trunk/blender/intern/ghost/intern/GHOST_DropTargetX11.cpp
trunk/blender/intern/ghost/intern/GHOST_DropTargetX11.h
Modified: trunk/blender/extern/CMakeLists.txt
===================================================================
--- trunk/blender/extern/CMakeLists.txt 2012-02-17 16:55:55 UTC (rev 44194)
+++ trunk/blender/extern/CMakeLists.txt 2012-02-17 16:58:09 UTC (rev 44195)
@@ -71,3 +71,7 @@
if(WITH_CARVE)
add_subdirectory(carve)
endif()
+
+if(UNIX AND NOT APPLE)
+ add_subdirectory(xdnd)
+endif()
Modified: trunk/blender/extern/SConscript
===================================================================
--- trunk/blender/extern/SConscript 2012-02-17 16:55:55 UTC (rev 44194)
+++ trunk/blender/extern/SConscript 2012-02-17 16:58:09 UTC (rev 44195)
@@ -34,3 +34,6 @@
if env['WITH_BF_CARVE']:
SConscript(['carve/SConscript'])
+
+if env['OURPLATFORM'] in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'freebsd9', 'aix4', 'aix5'):
+ SConscript(['xdnd/SConscript'])
Copied: trunk/blender/extern/xdnd/CMakeLists.txt (from rev 44193, trunk/blender/extern/CMakeLists.txt)
===================================================================
--- trunk/blender/extern/xdnd/CMakeLists.txt (rev 0)
+++ trunk/blender/extern/xdnd/CMakeLists.txt 2012-02-17 16:58:09 UTC (rev 44195)
@@ -0,0 +1,43 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2012, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Sergey Sharybin.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ .
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+ xdnd.c
+ xdnd.h
+)
+
+add_definitions(
+ -DHAVE_SYS_TIME_H
+)
+
+blender_add_lib(extern_xdnd "${SRC}" "${INC}" "${INC_SYS}")
Added: trunk/blender/extern/xdnd/SConscript
===================================================================
--- trunk/blender/extern/xdnd/SConscript (rev 0)
+++ trunk/blender/extern/xdnd/SConscript 2012-02-17 16:58:09 UTC (rev 44195)
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+Import('env')
+
+defs = ['HAVE_SYS_TIME_H']
+sources = env.Glob('*.c')
+
+incs = '.'
+
+env.BlenderLib ( 'extern_xdnd', sources, Split(incs), defs, libtype=['extern','player'], priority=[10, 185])
Added: trunk/blender/extern/xdnd/xdnd.c
===================================================================
--- trunk/blender/extern/xdnd/xdnd.c (rev 0)
+++ trunk/blender/extern/xdnd/xdnd.c 2012-02-17 16:58:09 UTC (rev 44195)
@@ -0,0 +1,1599 @@
+/* xdnd.c, xdnd.h - C program library for handling the Xdnd protocol
+ Copyright (C) 1996-2000 Paul Sheer
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+ */
+
+
+/*
+ Released 1998-08-07
+ Changes:
+
+ 2000-08-08: INCR protocol implemented.
+
+*/
+
+/*
+ DONE:
+ - INCR protocol now implemented
+
+ TODO:
+ - action_choose_dialog not yet supported (never called)
+ - widget_delete_selection not yet supported and DELETE requests are ignored
+ - not yet tested with applications that only supported XDND 0 or 1
+*/
+
+#include <X11/Xlib.h>
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+
+#include "xdnd.h"
+
+static void xdnd_send_enter (DndClass * dnd, Window window, Window from, Atom * typelist);
+static void xdnd_send_position (DndClass * dnd, Window window, Window from, Atom action, int x, int y,
+ unsigned long etime);
+static void xdnd_send_status (DndClass * dnd, Window window, Window from, int will_accept, int want_position,
+ int x, int y, int w, int h, Atom action);
+static void xdnd_send_leave (DndClass * dnd, Window window, Window from);
+static void xdnd_send_drop (DndClass * dnd, Window window, Window from, unsigned long etime);
+static void xdnd_send_finished (DndClass * dnd, Window window, Window from, int error);
+static int xdnd_convert_selection (DndClass * dnd, Window window, Window requester, Atom type);
+static void xdnd_selection_send (DndClass * dnd, XSelectionRequestEvent * request, unsigned char *data,
+ int length);
+static int xdnd_get_selection (DndClass * dnd, Window from, Atom property, Window insert);
+
+
+/* just to remind us : */
+
+#if 0
+typedef struct {
+ int type;
+ unsigned long serial;
+ Bool send_event;
+ Display *display;
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+XClientMessageEvent xclient;
+#endif
+
+/* #define DND_DEBUG */
+
+#define xdnd_xfree(x) {if (x) { free (x); x = 0; }}
+
+#ifdef DND_DEBUG
+
+#include <sys/time.h>
+#include <unistd.h>
+
+char *xdnd_debug_milliseconds (void)
+{
+ struct timeval tv;
+ static char r[22];
+ gettimeofday (&tv, 0);
+ sprintf (r, "%.2ld.%.3ld", tv.tv_sec % 100L, tv.tv_usec / 1000L);
+ return r;
+}
+
+#define dnd_debug1(a) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds ())
+#define dnd_debug2(a,b) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b)
+#define dnd_debug3(a,b,c) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c)
+#define dnd_debug4(a,b,c,d) printf("%s: %d: %s: " a "\n", __FILE__, __LINE__, xdnd_debug_milliseconds (), b, c, d)
+#else
+#define dnd_debug1(a)
+#define dnd_debug2(a,b)
+#define dnd_debug3(a,b,c)
+#define dnd_debug4(a,b,c,d)
+#endif
+
+#define dnd_warning(a) fprintf (stderr, a)
+
+#define dnd_version_at_least(a,b) ((a) >= (b))
+
+static unsigned char dnd_copy_cursor_bits[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x02, 0x00, 0x08, 0x01,
+ 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0xe8, 0x0f,
+ 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01, 0x02, 0x00, 0x08, 0x01,
+ 0x02, 0x00, 0x08, 0x00, 0x02, 0x04, 0x08, 0x00, 0x02, 0x0c, 0x08, 0x00,
+ 0x02, 0x1c, 0x08, 0x00, 0x02, 0x3c, 0x08, 0x00, 0x02, 0x7c, 0x08, 0x00,
+ 0x02, 0xfc, 0x08, 0x00, 0x02, 0xfc, 0x09, 0x00, 0x02, 0xfc, 0x0b, 0x00,
+ 0x02, 0x7c, 0x08, 0x00, 0xfe, 0x6d, 0x0f, 0x00, 0x00, 0xc4, 0x00, 0x00,
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char dnd_copy_mask_bits[] =
+{
+ 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f,
+ 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
+ 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f, 0x07, 0x00, 0xfc, 0x1f,
+ 0x07, 0x06, 0xfc, 0x1f, 0x07, 0x0e, 0xfc, 0x1f, 0x07, 0x1e, 0x1c, 0x00,
+ 0x07, 0x3e, 0x1c, 0x00, 0x07, 0x7e, 0x1c, 0x00, 0x07, 0xfe, 0x1c, 0x00,
+ 0x07, 0xfe, 0x1d, 0x00, 0x07, 0xfe, 0x1f, 0x00, 0x07, 0xfe, 0x1f, 0x00,
+ 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x1e, 0x00, 0xff, 0xef, 0x1f, 0x00,
+ 0x00, 0xe6, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00,
+ 0x00, 0x80, 0x01, 0x00};
+
+static unsigned char dnd_move_cursor_bits[] =
+{
+ 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x02, 0x00, 0x08, 0x02, 0x00, 0x08,
+ 0x02, 0x00, 0x08, 0x02, 0x00, 0x08, 0x02, 0x00, 0x08, 0x02, 0x00, 0x08,
+ 0x02, 0x00, 0x08, 0x02, 0x00, 0x08, 0x02, 0x04, 0x08, 0x02, 0x0c, 0x08,
+ 0x02, 0x1c, 0x08, 0x02, 0x3c, 0x08, 0x02, 0x7c, 0x08, 0x02, 0xfc, 0x08,
+ 0x02, 0xfc, 0x09, 0x02, 0xfc, 0x0b, 0x02, 0x7c, 0x08, 0xfe, 0x6d, 0x0f,
+ 0x00, 0xc4, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01,
+ 0x00, 0x00, 0x00};
+
+static unsigned char dnd_move_mask_bits[] =
+{
+ 0xff, 0xff, 0x1f, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x1f, 0x07, 0x00, 0x1c,
+ 0x07, 0x00, 0x1c, 0x07, 0x00, 0x1c, 0x07, 0x00, 0x1c, 0x07, 0x00, 0x1c,
+ 0x07, 0x00, 0x1c, 0x07, 0x06, 0x1c, 0x07, 0x0e, 0x1c, 0x07, 0x1e, 0x1c,
+ 0x07, 0x3e, 0x1c, 0x07, 0x7e, 0x1c, 0x07, 0xfe, 0x1c, 0x07, 0xfe, 0x1d,
+ 0x07, 0xfe, 0x1f, 0x07, 0xfe, 0x1f, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x1e,
+ 0xff, 0xef, 0x1f, 0x00, 0xe6, 0x01, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03,
+ 0x00, 0x80, 0x01};
+
+static unsigned char dnd_link_cursor_bits[] =
+{
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x02, 0x00, 0x08, 0x01,
+ 0x02, 0x00, 0x88, 0x00, 0x02, 0x00, 0x48, 0x00, 0x02, 0x00, 0xe8, 0x0f,
+ 0x02, 0x00, 0x48, 0x00, 0x02, 0x00, 0x88, 0x00, 0x02, 0x00, 0x08, 0x01,
+ 0x02, 0x00, 0x08, 0x00, 0x02, 0x04, 0x08, 0x00, 0x02, 0x0c, 0x08, 0x00,
+ 0x02, 0x1c, 0x08, 0x00, 0x02, 0x3c, 0x08, 0x00, 0x02, 0x7c, 0x08, 0x00,
+ 0x02, 0xfc, 0x08, 0x00, 0x02, 0xfc, 0x09, 0x00, 0x02, 0xfc, 0x0b, 0x00,
+ 0x02, 0x7c, 0x08, 0x00, 0xfe, 0x6d, 0x0f, 0x00, 0x00, 0xc4, 0x00, 0x00,
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char dnd_link_mask_bits[] =
+{
+ 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1f,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list