aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-12-03 11:41:27 +0200
committerEli Zaretskii2013-12-03 11:41:27 +0200
commit051546df1a4e52c44b612853fa14a653bc082860 (patch)
tree60a7018a0e76403447cb7000a2e6c074f7f827ed /src
parent2c47be65fe7e9d8ad350f5022dbdcf8cb729c2e2 (diff)
downloademacs-051546df1a4e52c44b612853fa14a653bc082860.tar.gz
emacs-051546df1a4e52c44b612853fa14a653bc082860.zip
Drag-n-drop converted, but works only within current codepage.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 0741761febe..08d66f25642 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -52,6 +52,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
52#include "keymap.h" 52#include "keymap.h"
53 53
54#ifdef WINDOWSNT 54#ifdef WINDOWSNT
55#include "w32.h" /* for filename_from_utf16, filename_from_ansi */
55#include "w32heap.h" 56#include "w32heap.h"
56#endif 57#endif
57 58
@@ -3099,7 +3100,14 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f)
3099 HDROP hdrop; 3100 HDROP hdrop;
3100 POINT p; 3101 POINT p;
3101 WORD num_files; 3102 WORD num_files;
3102 guichar_t *name; 3103 wchar_t name_w[MAX_PATH];
3104#ifdef NTGUI_UNICODE
3105 const int use_unicode = 1;
3106#else
3107 int use_unicode = w32_unicode_filenames;
3108 char name_a[MAX_PATH];
3109 char file[MAX_UTF8_PATH];
3110#endif
3103 int i, len; 3111 int i, len;
3104 3112
3105 result->kind = DRAG_N_DROP_EVENT; 3113 result->kind = DRAG_N_DROP_EVENT;
@@ -3124,17 +3132,34 @@ construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame *f)
3124 3132
3125 for (i = 0; i < num_files; i++) 3133 for (i = 0; i < num_files; i++)
3126 { 3134 {
3127 len = GUI_FN (DragQueryFile) (hdrop, i, NULL, 0); 3135 /* FIXME: In the native w32 build, the Unicode branch works only
3128 if (len <= 0) 3136 for file names that can be expressed in the current ANSI
3129 continue; 3137 codepage; the characters not supported by that codepage get
3130 3138 replaced with blanks. I don't know why this happens. */
3131 name = alloca ((len + 1) * sizeof (*name)); 3139 if (use_unicode)
3132 GUI_FN (DragQueryFile) (hdrop, i, name, len + 1); 3140 {
3141 eassert (DragQueryFileW (hdrop, i, NULL, 0) < MAX_PATH);
3142 /* If DragQueryFile returns zero, it failed to fetch a file
3143 name. */
3144 if (DragQueryFileW (hdrop, i, name_w, MAX_PATH) == 0)
3145 continue;
3133#ifdef NTGUI_UNICODE 3146#ifdef NTGUI_UNICODE
3134 files = Fcons (from_unicode_buffer (name), files); 3147 files = Fcons (from_unicode_buffer (name_w), files);
3135#else 3148#else
3136 files = Fcons (DECODE_FILE (build_string (name)), files); 3149 filename_from_utf16 (name_w, file);
3150 files = Fcons (DECODE_FILE (build_unibyte_string (file)), files);
3137#endif /* NTGUI_UNICODE */ 3151#endif /* NTGUI_UNICODE */
3152 }
3153#ifndef NTGUI_UNICODE
3154 else
3155 {
3156 eassert (DragQueryFileA (hdrop, i, NULL, 0) < MAX_PATH);
3157 if (DragQueryFileA (hdrop, i, name_a, MAX_PATH) == 0)
3158 continue;
3159 filename_from_ansi (name_a, file);
3160 files = Fcons (DECODE_FILE (build_unibyte_string (file)), files);
3161 }
3162#endif
3138 } 3163 }
3139 3164
3140 DragFinish (hdrop); 3165 DragFinish (hdrop);