Mercurial > hg > xemacs-beta
comparison src/gui-msw.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | bbff43aa5eb7 |
children | a86b2b5e0111 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
25 #include "gui.h" | 25 #include "gui.h" |
26 #include "redisplay.h" | 26 #include "redisplay.h" |
27 #include "frame.h" | 27 #include "frame.h" |
28 #include "elhash.h" | 28 #include "elhash.h" |
29 #include "console-msw.h" | 29 #include "console-msw.h" |
30 #include "buffer.h" | |
30 | 31 |
31 /* | 32 /* |
32 * Return value is Qt if we have dispatched the command, | 33 * Return value is Qt if we have dispatched the command, |
33 * or Qnil if id has not been mapped to a callback. | 34 * or Qnil if id has not been mapped to a callback. |
34 * Window procedure may try other targets to route the | 35 * Window procedure may try other targets to route the |
35 * command if we return nil | 36 * command if we return nil |
36 */ | 37 */ |
37 Lisp_Object | 38 Lisp_Object |
38 mswindows_handle_gui_wm_command (struct frame* f, HWND ctrl, WORD id) | 39 mswindows_handle_gui_wm_command (struct frame* f, HWND ctrl, DWORD id) |
39 { | 40 { |
40 /* Try to map the command id through the proper hash table */ | 41 /* Try to map the command id through the proper hash table */ |
41 Lisp_Object data, fn, arg, frame; | 42 Lisp_Object data, fn, arg, frame; |
43 | |
44 /* #### make_int should assert that --kkm */ | |
45 assert (XINT (make_int (id)) == id); | |
42 | 46 |
43 data = Fgethash (make_int (id), | 47 data = Fgethash (make_int (id), |
44 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f), Qnil); | 48 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f), Qnil); |
45 | 49 |
46 if (NILP (data) || UNBOUNDP (data)) | 50 if (NILP (data) || UNBOUNDP (data)) |
47 return Qnil; | 51 return Qnil; |
48 | 52 |
49 MARK_SUBWINDOWS_CHANGED; | 53 MARK_SUBWINDOWS_STATE_CHANGED; |
50 /* Ok, this is our one. Enqueue it. */ | 54 /* Ok, this is our one. Enqueue it. */ |
51 get_gui_callback (data, &fn, &arg); | 55 get_gui_callback (data, &fn, &arg); |
52 XSETFRAME (frame, f); | 56 XSETFRAME (frame, f); |
53 mswindows_enqueue_misc_user_event (frame, fn, arg); | 57 mswindows_enqueue_misc_user_event (frame, fn, arg); |
54 | 58 |
55 return Qt; | 59 return Qt; |
56 } | 60 } |
57 | 61 |
62 DEFUN ("mswindows-shell-execute", Fmswindows_shell_execute, 2, 4, 0, /* | |
63 Get Windows to perform OPERATION on DOCUMENT. | |
64 This is a wrapper around the ShellExecute system function, which | |
65 invokes the application registered to handle OPERATION for DOCUMENT. | |
66 OPERATION is typically \"open\", \"print\" or \"explore\" (but can be | |
67 nil for the default action), and DOCUMENT is typically the name of a | |
68 document file or URL, but can also be a program executable to run or | |
69 a directory to open in the Windows Explorer. | |
70 | |
71 If DOCUMENT is a program executable, PARAMETERS can be a string | |
72 containing command line parameters, but otherwise should be nil. | |
73 | |
74 SHOW-FLAG can be used to control whether the invoked application is hidden | |
75 or minimized. If SHOW-FLAG is nil, the application is displayed normally, | |
76 otherwise it is an integer representing a ShowWindow flag: | |
77 | |
78 0 - start hidden | |
79 1 - start normally | |
80 3 - start maximized | |
81 6 - start minimized | |
82 */ | |
83 (operation, document, parameters, show_flag)) | |
84 { | |
85 /* Encode filename and current directory. */ | |
86 Lisp_Object current_dir = Ffile_name_directory (document); | |
87 char* path = NULL; | |
88 char* doc = NULL; | |
89 Extbyte* f=0; | |
90 int ret; | |
91 struct gcpro gcpro1, gcpro2; | |
92 | |
93 CHECK_STRING (document); | |
94 | |
95 /* Just get the filename if we were given it. */ | |
96 document = Ffile_name_nondirectory (document); | |
97 | |
98 if (NILP (current_dir)) | |
99 current_dir = current_buffer->directory; | |
100 | |
101 GCPRO2 (current_dir, document); | |
102 | |
103 /* Use mule and cygwin-safe APIs top get at file data. */ | |
104 if (STRINGP (current_dir)) | |
105 { | |
106 TO_EXTERNAL_FORMAT (LISP_STRING, current_dir, | |
107 C_STRING_ALLOCA, f, | |
108 Qfile_name); | |
109 #ifdef __CYGWIN32__ | |
110 CYGWIN_WIN32_PATH (f, path); | |
111 #else | |
112 path = f; | |
113 #endif | |
114 } | |
115 | |
116 if (STRINGP (document)) | |
117 { | |
118 TO_EXTERNAL_FORMAT (LISP_STRING, document, | |
119 C_STRING_ALLOCA, f, | |
120 Qfile_name); | |
121 doc = f; | |
122 } | |
123 | |
124 UNGCPRO; | |
125 | |
126 ret = (int) ShellExecute (NULL, | |
127 (STRINGP (operation) ? | |
128 XSTRING_DATA (operation) : NULL), | |
129 doc, | |
130 (STRINGP (parameters) ? | |
131 XSTRING_DATA (parameters) : NULL), | |
132 path, | |
133 (INTP (show_flag) ? | |
134 XINT (show_flag) : SW_SHOWDEFAULT)); | |
135 | |
136 if (ret > 32) | |
137 return Qt; | |
138 | |
139 if (ret == ERROR_FILE_NOT_FOUND || ret == SE_ERR_FNF) | |
140 signal_simple_error ("file not found", document); | |
141 else if (ret == ERROR_PATH_NOT_FOUND || ret == SE_ERR_PNF) | |
142 signal_simple_error ("path not found", current_dir); | |
143 else if (ret == ERROR_BAD_FORMAT) | |
144 signal_simple_error ("bad executable format", document); | |
145 else | |
146 error ("internal error"); | |
147 | |
148 return Qnil; | |
149 } | |
150 | |
151 void | |
152 syms_of_gui_mswindows (void) | |
153 { | |
154 DEFSUBR (Fmswindows_shell_execute); | |
155 } |