diff options
| author | Po Lu | 2022-06-23 13:38:30 +0800 |
|---|---|---|
| committer | Po Lu | 2022-06-23 13:58:38 +0800 |
| commit | 0b4db66a9deae682dc7d444f4ab8d0e49f15c3b9 (patch) | |
| tree | 6f08101c3b9697085153e3babe29dc379d031b9c /src | |
| parent | 00034ad2e635adc93cd1d6dcb1b500c10d990c74 (diff) | |
| download | emacs-0b4db66a9deae682dc7d444f4ab8d0e49f15c3b9.tar.gz emacs-0b4db66a9deae682dc7d444f4ab8d0e49f15c3b9.zip | |
Allow dropping more data types on PGTK
* lisp/loadup.el (featurep): Load `pgtk-dnd'.
* lisp/pgtk-dnd.el: New file.
(pgtk-dnd-test-function, pgtk-dnd-types-alist)
(pgtk-dnd-known-types, pgtk-dnd-use-offix-drop)
(pgtk-dnd-current-state, pgtk-get-selection-internal)
(pgtk-register-dnd-targets, pgtk-dnd-empty-state)
(pgtk-dnd-init-frame, pgtk-dnd-get-state-cons-for-frame)
(pgtk-dnd-get-state-for-frame, pgtk-dnd-default-test-function)
(pgtk-dnd-current-type, pgtk-dnd-forget-drop)
(pgtk-dnd-maybe-call-test-function, pgtk-dnd-save-state)
(pgtk-dnd-handle-moz-url, pgtk-dnd-insert-utf8-text)
(pgtk-dnd-insert-utf16-text, pgtk-dnd-insert-ctext)
(pgtk-dnd-handle-uri-list, pgtk-dnd-handle-file-name)
(pgtk-dnd-choose-type, pgtk-dnd-drop-data)
(pgtk-dnd-handle-drag-n-drop-event, pgtk-update-drop-status)
(pgtk-drop-finish, pgtk-dnd-handle-gdk, pgtk-dnd): New variables
and functions and library.
* lisp/term/pgtk-win.el (special-event-map): Load
`drag-n-drop-event'.
(after-make-frame-functions): Register DND after make frame
functions.
* src/emacs.c (main): Stop calling empty init_pgtkterm function.
* src/pgtkselect.c (Fpgtk_register_dnd_targets, Fpgtk_drop_finish)
(Fpgtk_update_drop_status): New functions.
(syms_of_pgtkselect): Register new functions.
* src/pgtkterm.c (struct event_queue_t): Fix coding style of
definition.
(symbol_to_drag_action, drag_action_to_symbol)
(pgtk_update_drop_status, pgtk_finish_drop): New functions.
(drag_data_received): Delete function.
(pgtk_set_event_handler): Register for DND correctly.
(syms_of_pgtkterm): New defsyms for DND types.
(init_pgtkterm): Delete function.
* src/pgtkterm.h: Update prototypes, fix prototype coding style.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 3 | ||||
| -rw-r--r-- | src/pgtkselect.c | 99 | ||||
| -rw-r--r-- | src/pgtkterm.c | 276 | ||||
| -rw-r--r-- | src/pgtkterm.h | 120 |
4 files changed, 378 insertions, 120 deletions
diff --git a/src/emacs.c b/src/emacs.c index 37c6c76e7a3..3c768412818 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1930,9 +1930,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem | |||
| 1930 | init_bignum (); | 1930 | init_bignum (); |
| 1931 | init_threads (); | 1931 | init_threads (); |
| 1932 | init_eval (); | 1932 | init_eval (); |
| 1933 | #ifdef HAVE_PGTK | ||
| 1934 | init_pgtkterm (); /* Must come before `init_atimer'. */ | ||
| 1935 | #endif | ||
| 1936 | running_asynch_code = 0; | 1933 | running_asynch_code = 0; |
| 1937 | init_random (); | 1934 | init_random (); |
| 1938 | init_xfaces (); | 1935 | init_xfaces (); |
diff --git a/src/pgtkselect.c b/src/pgtkselect.c index 122b5d8c073..2a4f6adba4b 100644 --- a/src/pgtkselect.c +++ b/src/pgtkselect.c | |||
| @@ -1762,6 +1762,86 @@ pgtk_handle_selection_notify (GdkEventSelection *event) | |||
| 1762 | (event->property != GDK_NONE ? Qt : Qlambda)); | 1762 | (event->property != GDK_NONE ? Qt : Qlambda)); |
| 1763 | } | 1763 | } |
| 1764 | 1764 | ||
| 1765 | |||
| 1766 | /*********************************************************************** | ||
| 1767 | Drag and drop support | ||
| 1768 | ***********************************************************************/ | ||
| 1769 | |||
| 1770 | DEFUN ("pgtk-register-dnd-targets", Fpgtk_register_dnd_targets, | ||
| 1771 | Spgtk_register_dnd_targets, 2, 2, 0, | ||
| 1772 | doc: /* Register TARGETS on FRAME. | ||
| 1773 | TARGETS should be a list of strings describing data types (selection | ||
| 1774 | targets) that can be dropped on top of FRAME. */) | ||
| 1775 | (Lisp_Object frame, Lisp_Object targets) | ||
| 1776 | { | ||
| 1777 | struct frame *f; | ||
| 1778 | GtkTargetEntry *entries; | ||
| 1779 | GtkTargetList *list; | ||
| 1780 | ptrdiff_t length, n; | ||
| 1781 | Lisp_Object tem, t; | ||
| 1782 | char *buf; | ||
| 1783 | USE_SAFE_ALLOCA; | ||
| 1784 | |||
| 1785 | f = decode_window_system_frame (frame); | ||
| 1786 | CHECK_LIST (targets); | ||
| 1787 | length = list_length (targets); | ||
| 1788 | n = 0; | ||
| 1789 | entries = SAFE_ALLOCA (sizeof *entries * length); | ||
| 1790 | memset (entries, 0, sizeof *entries * length); | ||
| 1791 | tem = targets; | ||
| 1792 | |||
| 1793 | FOR_EACH_TAIL (tem) | ||
| 1794 | { | ||
| 1795 | if (!CONSP (tem)) | ||
| 1796 | continue; | ||
| 1797 | |||
| 1798 | t = XCAR (tem); | ||
| 1799 | |||
| 1800 | CHECK_STRING (t); | ||
| 1801 | SAFE_ALLOCA_STRING (buf, t); | ||
| 1802 | |||
| 1803 | entries[n++].target = buf; | ||
| 1804 | } | ||
| 1805 | CHECK_LIST_END (tem, targets); | ||
| 1806 | |||
| 1807 | if (n != length) | ||
| 1808 | emacs_abort (); | ||
| 1809 | |||
| 1810 | list = gtk_target_list_new (entries, n); | ||
| 1811 | gtk_drag_dest_set_target_list (FRAME_GTK_WIDGET (f), list); | ||
| 1812 | gtk_target_list_unref (list); | ||
| 1813 | |||
| 1814 | SAFE_FREE (); | ||
| 1815 | |||
| 1816 | return Qnil; | ||
| 1817 | } | ||
| 1818 | |||
| 1819 | DEFUN ("pgtk-drop-finish", Fpgtk_drop_finish, Spgtk_drop_finish, 3, 3, 0, | ||
| 1820 | doc: /* Finish the drag-n-drop event that happened at TIMESTAMP. | ||
| 1821 | SUCCESS is whether or not the drop was successful, i.e. the action | ||
| 1822 | chosen in the last call to `pgtk-update-drop-status' was performed. | ||
| 1823 | TIMESTAMP is the time associated with the drag-n-drop event that is | ||
| 1824 | being finished. | ||
| 1825 | DELETE is whether or not the action was `move'. */) | ||
| 1826 | (Lisp_Object success, Lisp_Object timestamp, Lisp_Object delete) | ||
| 1827 | { | ||
| 1828 | pgtk_finish_drop (success, timestamp, delete); | ||
| 1829 | |||
| 1830 | return Qnil; | ||
| 1831 | } | ||
| 1832 | |||
| 1833 | DEFUN ("pgtk-update-drop-status", Fpgtk_update_drop_status, | ||
| 1834 | Spgtk_update_drop_status, 2, 2, 0, | ||
| 1835 | doc: /* Update the status of the current drag-and-drop operation. | ||
| 1836 | ACTION is the action the drop source should take. | ||
| 1837 | TIMESTAMP is the same as in `pgtk-drop-finish'. */) | ||
| 1838 | (Lisp_Object action, Lisp_Object timestamp) | ||
| 1839 | { | ||
| 1840 | pgtk_update_drop_status (action, timestamp); | ||
| 1841 | |||
| 1842 | return Qnil; | ||
| 1843 | } | ||
| 1844 | |||
| 1765 | void | 1845 | void |
| 1766 | syms_of_pgtkselect (void) | 1846 | syms_of_pgtkselect (void) |
| 1767 | { | 1847 | { |
| @@ -1777,23 +1857,22 @@ syms_of_pgtkselect (void) | |||
| 1777 | DEFSYM (QNULL, "NULL"); | 1857 | DEFSYM (QNULL, "NULL"); |
| 1778 | DEFSYM (QATOM, "ATOM"); | 1858 | DEFSYM (QATOM, "ATOM"); |
| 1779 | DEFSYM (QTARGETS, "TARGETS"); | 1859 | DEFSYM (QTARGETS, "TARGETS"); |
| 1780 | |||
| 1781 | DEFSYM (Qpgtk_sent_selection_functions, | ||
| 1782 | "pgtk-sent-selection-functions"); | ||
| 1783 | DEFSYM (Qpgtk_lost_selection_functions, | ||
| 1784 | "pgtk-lost-selection-functions"); | ||
| 1785 | |||
| 1786 | DEFSYM (Qforeign_selection, "foreign-selection"); | ||
| 1787 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); | 1860 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); |
| 1788 | DEFSYM (QSTRING, "STRING"); | ||
| 1789 | DEFSYM (QCOMPOUND_TEXT, "COMPOUND_TEXT"); | 1861 | DEFSYM (QCOMPOUND_TEXT, "COMPOUND_TEXT"); |
| 1790 | DEFSYM (Qtext_plain_charset_utf_8, "text/plain;charset=utf-8"); | 1862 | |
| 1863 | DEFSYM (Qforeign_selection, "foreign-selection"); | ||
| 1864 | |||
| 1865 | DEFSYM (Qpgtk_sent_selection_functions, "pgtk-sent-selection-functions"); | ||
| 1866 | DEFSYM (Qpgtk_lost_selection_functions, "pgtk-lost-selection-functions"); | ||
| 1791 | 1867 | ||
| 1792 | defsubr (&Spgtk_disown_selection_internal); | 1868 | defsubr (&Spgtk_disown_selection_internal); |
| 1793 | defsubr (&Spgtk_get_selection_internal); | 1869 | defsubr (&Spgtk_get_selection_internal); |
| 1794 | defsubr (&Spgtk_own_selection_internal); | 1870 | defsubr (&Spgtk_own_selection_internal); |
| 1795 | defsubr (&Spgtk_selection_exists_p); | 1871 | defsubr (&Spgtk_selection_exists_p); |
| 1796 | defsubr (&Spgtk_selection_owner_p); | 1872 | defsubr (&Spgtk_selection_owner_p); |
| 1873 | defsubr (&Spgtk_register_dnd_targets); | ||
| 1874 | defsubr (&Spgtk_update_drop_status); | ||
| 1875 | defsubr (&Spgtk_drop_finish); | ||
| 1797 | 1876 | ||
| 1798 | DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist, | 1877 | DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist, |
| 1799 | doc: /* SKIP: real doc in xselect.c. */); | 1878 | doc: /* SKIP: real doc in xselect.c. */); |
| @@ -1817,7 +1896,7 @@ The functions are called with three arguments: | |||
| 1817 | We might have failed (and declined the request) for any number of reasons, | 1896 | We might have failed (and declined the request) for any number of reasons, |
| 1818 | including being asked for a selection that we no longer own, or being asked | 1897 | including being asked for a selection that we no longer own, or being asked |
| 1819 | to convert into a type that we don't know about or that is inappropriate. | 1898 | to convert into a type that we don't know about or that is inappropriate. |
| 1820 | This hook doesn't let you change the behavior of Emacs's selection replies, | 1899 | xThis hook doesn't let you change the behavior of Emacs's selection replies, |
| 1821 | it merely informs you that they have happened. */); | 1900 | it merely informs you that they have happened. */); |
| 1822 | Vpgtk_sent_selection_functions = Qnil; | 1901 | Vpgtk_sent_selection_functions = Qnil; |
| 1823 | 1902 | ||
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 91874ff58a5..a123311366a 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -76,25 +76,36 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 76 | 76 | ||
| 77 | static bool any_help_event_p; | 77 | static bool any_help_event_p; |
| 78 | 78 | ||
| 79 | struct pgtk_display_info *x_display_list; /* Chain of existing displays */ | 79 | /* Chain of existing displays */ |
| 80 | extern Lisp_Object tip_frame; | 80 | struct pgtk_display_info *x_display_list; |
| 81 | 81 | ||
| 82 | static struct event_queue_t | 82 | struct event_queue_t |
| 83 | { | 83 | { |
| 84 | union buffered_input_event *q; | 84 | union buffered_input_event *q; |
| 85 | int nr, cap; | 85 | int nr, cap; |
| 86 | } event_q = { | ||
| 87 | NULL, 0, 0, | ||
| 88 | }; | 86 | }; |
| 89 | 87 | ||
| 88 | /* A queue of events that will be read by the read_socket_hook. */ | ||
| 89 | static struct event_queue_t event_q; | ||
| 90 | |||
| 90 | /* Non-zero timeout value means ignore next mouse click if it arrives | 91 | /* Non-zero timeout value means ignore next mouse click if it arrives |
| 91 | before that timeout elapses (i.e. as part of the same sequence of | 92 | before that timeout elapses (i.e. as part of the same sequence of |
| 92 | events resulting from clicking on a frame to select it). */ | 93 | events resulting from clicking on a frame to select it). */ |
| 93 | |||
| 94 | static Time ignore_next_mouse_click_timeout; | 94 | static Time ignore_next_mouse_click_timeout; |
| 95 | 95 | ||
| 96 | /* The default Emacs icon . */ | ||
| 96 | static Lisp_Object xg_default_icon_file; | 97 | static Lisp_Object xg_default_icon_file; |
| 97 | 98 | ||
| 99 | /* The current GdkDragContext of a drop. */ | ||
| 100 | static GdkDragContext *current_drop_context; | ||
| 101 | |||
| 102 | /* Whether or not current_drop_context was set from a drop | ||
| 103 | handler. */ | ||
| 104 | static bool current_drop_context_drop; | ||
| 105 | |||
| 106 | /* The time of the last drop. */ | ||
| 107 | static guint32 current_drop_time; | ||
| 108 | |||
| 98 | static void pgtk_delete_display (struct pgtk_display_info *); | 109 | static void pgtk_delete_display (struct pgtk_display_info *); |
| 99 | static void pgtk_clear_frame_area (struct frame *, int, int, int, int); | 110 | static void pgtk_clear_frame_area (struct frame *, int, int, int, int); |
| 100 | static void pgtk_fill_rectangle (struct frame *, unsigned long, int, int, | 111 | static void pgtk_fill_rectangle (struct frame *, unsigned long, int, int, |
| @@ -6146,40 +6157,217 @@ scroll_event (GtkWidget *widget, GdkEvent *event, gpointer *user_data) | |||
| 6146 | return TRUE; | 6157 | return TRUE; |
| 6147 | } | 6158 | } |
| 6148 | 6159 | ||
| 6160 | |||
| 6161 | |||
| 6162 | /* C part of drop handling code. | ||
| 6163 | The Lisp part is in pgtk-dnd.el. */ | ||
| 6164 | |||
| 6165 | static GdkDragAction | ||
| 6166 | symbol_to_drag_action (Lisp_Object act) | ||
| 6167 | { | ||
| 6168 | if (EQ (act, Qcopy)) | ||
| 6169 | return GDK_ACTION_COPY; | ||
| 6170 | |||
| 6171 | if (EQ (act, Qmove)) | ||
| 6172 | return GDK_ACTION_MOVE; | ||
| 6173 | |||
| 6174 | if (EQ (act, Qlink)) | ||
| 6175 | return GDK_ACTION_LINK; | ||
| 6176 | |||
| 6177 | if (EQ (act, Qprivate)) | ||
| 6178 | return GDK_ACTION_PRIVATE; | ||
| 6179 | |||
| 6180 | if (NILP (act)) | ||
| 6181 | return GDK_ACTION_DEFAULT; | ||
| 6182 | |||
| 6183 | signal_error ("Invalid drag acction", act); | ||
| 6184 | } | ||
| 6185 | |||
| 6186 | static Lisp_Object | ||
| 6187 | drag_action_to_symbol (GdkDragAction action) | ||
| 6188 | { | ||
| 6189 | switch (action) | ||
| 6190 | { | ||
| 6191 | case GDK_ACTION_COPY: | ||
| 6192 | return Qcopy; | ||
| 6193 | |||
| 6194 | case GDK_ACTION_MOVE: | ||
| 6195 | return Qmove; | ||
| 6196 | |||
| 6197 | case GDK_ACTION_LINK: | ||
| 6198 | return Qlink; | ||
| 6199 | |||
| 6200 | case GDK_ACTION_PRIVATE: | ||
| 6201 | return Qprivate; | ||
| 6202 | |||
| 6203 | case GDK_ACTION_DEFAULT: | ||
| 6204 | default: | ||
| 6205 | return Qnil; | ||
| 6206 | } | ||
| 6207 | } | ||
| 6208 | |||
| 6209 | void | ||
| 6210 | pgtk_update_drop_status (Lisp_Object action, Lisp_Object event_time) | ||
| 6211 | { | ||
| 6212 | guint32 time; | ||
| 6213 | |||
| 6214 | CONS_TO_INTEGER (event_time, guint32, time); | ||
| 6215 | |||
| 6216 | if (!current_drop_context || time < current_drop_time) | ||
| 6217 | return; | ||
| 6218 | |||
| 6219 | gdk_drag_status (current_drop_context, | ||
| 6220 | symbol_to_drag_action (action), | ||
| 6221 | time); | ||
| 6222 | } | ||
| 6223 | |||
| 6224 | void | ||
| 6225 | pgtk_finish_drop (Lisp_Object success, Lisp_Object event_time, | ||
| 6226 | Lisp_Object del) | ||
| 6227 | { | ||
| 6228 | guint32 time; | ||
| 6229 | |||
| 6230 | CONS_TO_INTEGER (event_time, guint32, time); | ||
| 6231 | |||
| 6232 | if (!current_drop_context || time < current_drop_time) | ||
| 6233 | return; | ||
| 6234 | |||
| 6235 | gtk_drag_finish (current_drop_context, !NILP (success), | ||
| 6236 | !NILP (del), time); | ||
| 6237 | |||
| 6238 | if (current_drop_context_drop) | ||
| 6239 | g_clear_pointer (¤t_drop_context, | ||
| 6240 | g_object_unref); | ||
| 6241 | } | ||
| 6242 | |||
| 6149 | static void | 6243 | static void |
| 6150 | drag_data_received (GtkWidget *widget, GdkDragContext *context, | 6244 | drag_leave (GtkWidget *widget, GdkDragContext *context, |
| 6151 | gint x, gint y, GtkSelectionData *data, | 6245 | guint time, gpointer user_data) |
| 6152 | guint info, guint time, gpointer user_data) | ||
| 6153 | { | 6246 | { |
| 6154 | struct frame *f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); | 6247 | struct frame *f; |
| 6155 | gchar **uris = gtk_selection_data_get_uris (data); | 6248 | union buffered_input_event inev; |
| 6249 | |||
| 6250 | f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); | ||
| 6156 | 6251 | ||
| 6157 | if (uris != NULL) | 6252 | if (current_drop_context) |
| 6158 | { | 6253 | { |
| 6159 | for (int i = 0; uris[i] != NULL; i++) | 6254 | if (current_drop_context_drop) |
| 6160 | { | 6255 | gtk_drag_finish (current_drop_context, |
| 6161 | union buffered_input_event inev; | 6256 | FALSE, FALSE, current_drop_time); |
| 6162 | Lisp_Object arg = Qnil; | ||
| 6163 | 6257 | ||
| 6164 | EVENT_INIT (inev.ie); | 6258 | g_clear_pointer (¤t_drop_context, |
| 6165 | inev.ie.kind = NO_EVENT; | 6259 | g_object_unref); |
| 6166 | inev.ie.arg = Qnil; | 6260 | } |
| 6167 | 6261 | ||
| 6168 | arg = list2 (Qurl, build_string (uris[i])); | 6262 | inev.ie.kind = DRAG_N_DROP_EVENT; |
| 6263 | inev.ie.modifiers = 0; | ||
| 6264 | inev.ie.arg = Qnil; | ||
| 6265 | inev.ie.timestamp = time; | ||
| 6169 | 6266 | ||
| 6170 | inev.ie.kind = DRAG_N_DROP_EVENT; | 6267 | XSETINT (inev.ie.x, 0); |
| 6171 | inev.ie.modifiers = 0; | 6268 | XSETINT (inev.ie.y, 0); |
| 6172 | XSETINT (inev.ie.x, x); | 6269 | XSETFRAME (inev.ie.frame_or_window, f); |
| 6173 | XSETINT (inev.ie.y, y); | ||
| 6174 | XSETFRAME (inev.ie.frame_or_window, f); | ||
| 6175 | inev.ie.arg = arg; | ||
| 6176 | inev.ie.timestamp = 0; | ||
| 6177 | 6270 | ||
| 6178 | evq_enqueue (&inev); | 6271 | evq_enqueue (&inev); |
| 6179 | } | 6272 | } |
| 6273 | |||
| 6274 | static gboolean | ||
| 6275 | drag_motion (GtkWidget *widget, GdkDragContext *context, | ||
| 6276 | gint x, gint y, guint time) | ||
| 6277 | |||
| 6278 | { | ||
| 6279 | struct frame *f; | ||
| 6280 | union buffered_input_event inev; | ||
| 6281 | GdkAtom name; | ||
| 6282 | GdkDragAction suggestion; | ||
| 6283 | |||
| 6284 | f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); | ||
| 6285 | |||
| 6286 | if (!f) | ||
| 6287 | return FALSE; | ||
| 6288 | |||
| 6289 | if (current_drop_context) | ||
| 6290 | { | ||
| 6291 | if (current_drop_context_drop) | ||
| 6292 | gtk_drag_finish (current_drop_context, | ||
| 6293 | FALSE, FALSE, current_drop_time); | ||
| 6294 | |||
| 6295 | g_clear_pointer (¤t_drop_context, | ||
| 6296 | g_object_unref); | ||
| 6180 | } | 6297 | } |
| 6181 | 6298 | ||
| 6182 | gtk_drag_finish (context, TRUE, FALSE, time); | 6299 | current_drop_context = g_object_ref (context); |
| 6300 | current_drop_time = time; | ||
| 6301 | current_drop_context_drop = false; | ||
| 6302 | |||
| 6303 | name = gdk_drag_get_selection (context); | ||
| 6304 | suggestion = gdk_drag_context_get_suggested_action (context); | ||
| 6305 | |||
| 6306 | EVENT_INIT (inev.ie); | ||
| 6307 | |||
| 6308 | inev.ie.kind = DRAG_N_DROP_EVENT; | ||
| 6309 | inev.ie.modifiers = 0; | ||
| 6310 | inev.ie.arg = list4 (Qlambda, intern (gdk_atom_name (name)), | ||
| 6311 | make_uint (time), | ||
| 6312 | drag_action_to_symbol (suggestion)); | ||
| 6313 | inev.ie.timestamp = time; | ||
| 6314 | |||
| 6315 | XSETINT (inev.ie.x, x); | ||
| 6316 | XSETINT (inev.ie.y, y); | ||
| 6317 | XSETFRAME (inev.ie.frame_or_window, f); | ||
| 6318 | |||
| 6319 | evq_enqueue (&inev); | ||
| 6320 | |||
| 6321 | return TRUE; | ||
| 6322 | } | ||
| 6323 | |||
| 6324 | static gboolean | ||
| 6325 | drag_drop (GtkWidget *widget, GdkDragContext *context, | ||
| 6326 | int x, int y, guint time, gpointer user_data) | ||
| 6327 | { | ||
| 6328 | struct frame *f; | ||
| 6329 | union buffered_input_event inev; | ||
| 6330 | GdkAtom name; | ||
| 6331 | GdkDragAction selected_action; | ||
| 6332 | |||
| 6333 | f = pgtk_any_window_to_frame (gtk_widget_get_window (widget)); | ||
| 6334 | |||
| 6335 | if (!f) | ||
| 6336 | return FALSE; | ||
| 6337 | |||
| 6338 | if (current_drop_context) | ||
| 6339 | { | ||
| 6340 | if (current_drop_context_drop) | ||
| 6341 | gtk_drag_finish (current_drop_context, | ||
| 6342 | FALSE, FALSE, current_drop_time); | ||
| 6343 | |||
| 6344 | g_clear_pointer (¤t_drop_context, | ||
| 6345 | g_object_unref); | ||
| 6346 | } | ||
| 6347 | |||
| 6348 | current_drop_context = g_object_ref (context); | ||
| 6349 | current_drop_time = time; | ||
| 6350 | current_drop_context_drop = true; | ||
| 6351 | |||
| 6352 | name = gdk_drag_get_selection (context); | ||
| 6353 | selected_action = gdk_drag_context_get_selected_action (context); | ||
| 6354 | |||
| 6355 | EVENT_INIT (inev.ie); | ||
| 6356 | |||
| 6357 | inev.ie.kind = DRAG_N_DROP_EVENT; | ||
| 6358 | inev.ie.modifiers = 0; | ||
| 6359 | inev.ie.arg = list4 (Qquote, intern (gdk_atom_name (name)), | ||
| 6360 | make_uint (time), | ||
| 6361 | drag_action_to_symbol (selected_action)); | ||
| 6362 | inev.ie.timestamp = time; | ||
| 6363 | |||
| 6364 | XSETINT (inev.ie.x, x); | ||
| 6365 | XSETINT (inev.ie.y, y); | ||
| 6366 | XSETFRAME (inev.ie.frame_or_window, f); | ||
| 6367 | |||
| 6368 | evq_enqueue (&inev); | ||
| 6369 | |||
| 6370 | return TRUE; | ||
| 6183 | } | 6371 | } |
| 6184 | 6372 | ||
| 6185 | static void | 6373 | static void |
| @@ -6208,9 +6396,9 @@ pgtk_set_event_handler (struct frame *f) | |||
| 6208 | return; | 6396 | return; |
| 6209 | } | 6397 | } |
| 6210 | 6398 | ||
| 6211 | gtk_drag_dest_set (FRAME_GTK_WIDGET (f), GTK_DEST_DEFAULT_ALL, NULL, 0, | 6399 | gtk_drag_dest_set (FRAME_GTK_WIDGET (f), 0, NULL, 0, |
| 6212 | GDK_ACTION_COPY); | 6400 | (GDK_ACTION_MOVE | GDK_ACTION_COPY |
| 6213 | gtk_drag_dest_add_uri_targets (FRAME_GTK_WIDGET (f)); | 6401 | | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); |
| 6214 | 6402 | ||
| 6215 | if (FRAME_GTK_OUTER_WIDGET (f)) | 6403 | if (FRAME_GTK_OUTER_WIDGET (f)) |
| 6216 | { | 6404 | { |
| @@ -6251,8 +6439,12 @@ pgtk_set_event_handler (struct frame *f) | |||
| 6251 | G_CALLBACK (scroll_event), NULL); | 6439 | G_CALLBACK (scroll_event), NULL); |
| 6252 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "configure-event", | 6440 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "configure-event", |
| 6253 | G_CALLBACK (configure_event), NULL); | 6441 | G_CALLBACK (configure_event), NULL); |
| 6254 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "drag-data-received", | 6442 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "drag-leave", |
| 6255 | G_CALLBACK (drag_data_received), NULL); | 6443 | G_CALLBACK (drag_leave), NULL); |
| 6444 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "drag-motion", | ||
| 6445 | G_CALLBACK (drag_motion), NULL); | ||
| 6446 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "drag-drop", | ||
| 6447 | G_CALLBACK (drag_drop), NULL); | ||
| 6256 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "draw", | 6448 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "draw", |
| 6257 | G_CALLBACK (pgtk_handle_draw), NULL); | 6449 | G_CALLBACK (pgtk_handle_draw), NULL); |
| 6258 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "property-notify-event", | 6450 | g_signal_connect (G_OBJECT (FRAME_GTK_WIDGET (f)), "property-notify-event", |
| @@ -6803,12 +6995,17 @@ syms_of_pgtkterm (void) | |||
| 6803 | 6995 | ||
| 6804 | DEFSYM (Qlatin_1, "latin-1"); | 6996 | DEFSYM (Qlatin_1, "latin-1"); |
| 6805 | 6997 | ||
| 6806 | xg_default_icon_file = | 6998 | xg_default_icon_file |
| 6807 | build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); | 6999 | = build_pure_c_string ("icons/hicolor/scalable/apps/emacs.svg"); |
| 6808 | staticpro (&xg_default_icon_file); | 7000 | staticpro (&xg_default_icon_file); |
| 6809 | 7001 | ||
| 6810 | DEFSYM (Qx_gtk_map_stock, "x-gtk-map-stock"); | 7002 | DEFSYM (Qx_gtk_map_stock, "x-gtk-map-stock"); |
| 6811 | 7003 | ||
| 7004 | DEFSYM (Qcopy, "copy"); | ||
| 7005 | DEFSYM (Qmove, "move"); | ||
| 7006 | DEFSYM (Qlink, "link"); | ||
| 7007 | DEFSYM (Qprivate, "private"); | ||
| 7008 | |||
| 6812 | 7009 | ||
| 6813 | Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); | 7010 | Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); |
| 6814 | Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); | 7011 | Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); |
| @@ -7093,8 +7290,3 @@ pgtk_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type) | |||
| 7093 | 7290 | ||
| 7094 | return CALLN (Fapply, intern ("concat"), Fnreverse (acc)); | 7291 | return CALLN (Fapply, intern ("concat"), Fnreverse (acc)); |
| 7095 | } | 7292 | } |
| 7096 | |||
| 7097 | void | ||
| 7098 | init_pgtkterm (void) | ||
| 7099 | { | ||
| 7100 | } | ||
diff --git a/src/pgtkterm.h b/src/pgtkterm.h index 86578be6b56..fcc6c5310e9 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h | |||
| @@ -448,9 +448,9 @@ enum | |||
| 448 | #define FRAME_FONT(f) (FRAME_X_OUTPUT (f)->font) | 448 | #define FRAME_FONT(f) (FRAME_X_OUTPUT (f)->font) |
| 449 | #define FRAME_GTK_OUTER_WIDGET(f) (FRAME_X_OUTPUT (f)->widget) | 449 | #define FRAME_GTK_OUTER_WIDGET(f) (FRAME_X_OUTPUT (f)->widget) |
| 450 | #define FRAME_GTK_WIDGET(f) (FRAME_X_OUTPUT (f)->edit_widget) | 450 | #define FRAME_GTK_WIDGET(f) (FRAME_X_OUTPUT (f)->edit_widget) |
| 451 | #define FRAME_WIDGET(f) (FRAME_GTK_OUTER_WIDGET (f) ? \ | 451 | #define FRAME_WIDGET(f) (FRAME_GTK_OUTER_WIDGET (f) \ |
| 452 | FRAME_GTK_OUTER_WIDGET (f) : \ | 452 | ? FRAME_GTK_OUTER_WIDGET (f) \ |
| 453 | FRAME_GTK_WIDGET (f)) | 453 | : FRAME_GTK_WIDGET (f)) |
| 454 | 454 | ||
| 455 | #define FRAME_PGTK_VIEW(f) FRAME_GTK_WIDGET (f) | 455 | #define FRAME_PGTK_VIEW(f) FRAME_GTK_WIDGET (f) |
| 456 | #define FRAME_X_WINDOW(f) FRAME_GTK_OUTER_WIDGET (f) | 456 | #define FRAME_X_WINDOW(f) FRAME_GTK_OUTER_WIDGET (f) |
| @@ -538,69 +538,57 @@ extern void pgtk_handle_property_notify (GdkEventProperty *); | |||
| 538 | extern void pgtk_handle_selection_notify (GdkEventSelection *); | 538 | extern void pgtk_handle_selection_notify (GdkEventSelection *); |
| 539 | 539 | ||
| 540 | /* Display init/shutdown functions implemented in pgtkterm.c */ | 540 | /* Display init/shutdown functions implemented in pgtkterm.c */ |
| 541 | extern struct pgtk_display_info *pgtk_term_init (Lisp_Object display_name, | 541 | extern struct pgtk_display_info *pgtk_term_init (Lisp_Object, char *); |
| 542 | char *resource_name); | 542 | extern void pgtk_term_shutdown (int); |
| 543 | extern void pgtk_term_shutdown (int sig); | ||
| 544 | 543 | ||
| 545 | /* Implemented in pgtkterm, published in or needed from pgtkfns. */ | 544 | /* Implemented in pgtkterm, published in or needed from pgtkfns. */ |
| 546 | extern void pgtk_clear_frame (struct frame *f); | 545 | extern void pgtk_clear_frame (struct frame *); |
| 547 | extern char *pgtk_xlfd_to_fontname (const char *xlfd); | 546 | extern char *pgtk_xlfd_to_fontname (const char *); |
| 548 | 547 | ||
| 549 | /* Implemented in pgtkfns.c. */ | 548 | /* Implemented in pgtkfns.c. */ |
| 550 | extern void pgtk_set_doc_edited (void); | 549 | extern void pgtk_set_doc_edited (void); |
| 551 | extern const char *pgtk_get_defaults_value (const char *key); | 550 | extern const char *pgtk_get_defaults_value (const char *); |
| 552 | extern const char *pgtk_get_string_resource (XrmDatabase rdb, | 551 | extern const char *pgtk_get_string_resource (XrmDatabase, const char *, const char *); |
| 553 | const char *name, | 552 | extern void pgtk_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object); |
| 554 | const char *class); | ||
| 555 | extern void pgtk_implicitly_set_name (struct frame *f, Lisp_Object arg, | ||
| 556 | Lisp_Object oldval); | ||
| 557 | 553 | ||
| 558 | /* Color management implemented in pgtkterm. */ | 554 | /* Color management implemented in pgtkterm. */ |
| 559 | extern bool pgtk_defined_color (struct frame *f, | 555 | extern bool pgtk_defined_color (struct frame *, const char *, |
| 560 | const char *name, | 556 | Emacs_Color *, bool, bool); |
| 561 | Emacs_Color * color_def, bool alloc, | 557 | extern void pgtk_query_color (struct frame *, Emacs_Color *); |
| 562 | bool makeIndex); | 558 | extern void pgtk_query_colors (struct frame *, Emacs_Color *, int); |
| 563 | extern void pgtk_query_color (struct frame *f, Emacs_Color * color); | 559 | extern int pgtk_parse_color (struct frame *, const char *, Emacs_Color *); |
| 564 | extern void pgtk_query_colors (struct frame *f, Emacs_Color * colors, | ||
| 565 | int ncolors); | ||
| 566 | extern int pgtk_parse_color (struct frame *f, const char *color_name, | ||
| 567 | Emacs_Color * color); | ||
| 568 | 560 | ||
| 569 | /* Implemented in pgtkterm.c */ | 561 | /* Implemented in pgtkterm.c */ |
| 570 | extern void pgtk_clear_area (struct frame *f, int x, int y, int width, | 562 | extern void pgtk_clear_area (struct frame *, int, int, int, int); |
| 571 | int height); | 563 | extern int pgtk_gtk_to_emacs_modifiers (struct pgtk_display_info *, int); |
| 572 | extern int pgtk_gtk_to_emacs_modifiers (struct pgtk_display_info *dpyinfo, | 564 | extern void pgtk_clear_under_internal_border (struct frame *); |
| 573 | int state); | 565 | extern void pgtk_set_event_handler (struct frame *); |
| 574 | extern void pgtk_clear_under_internal_border (struct frame *f); | ||
| 575 | extern void pgtk_set_event_handler (struct frame *f); | ||
| 576 | 566 | ||
| 577 | /* Implemented in pgtkterm.c */ | 567 | /* Implemented in pgtkterm.c */ |
| 578 | extern int pgtk_display_pixel_height (struct pgtk_display_info *); | 568 | extern int pgtk_display_pixel_height (struct pgtk_display_info *); |
| 579 | extern int pgtk_display_pixel_width (struct pgtk_display_info *); | 569 | extern int pgtk_display_pixel_width (struct pgtk_display_info *); |
| 580 | 570 | ||
| 581 | extern void pgtk_destroy_window (struct frame *f); | 571 | extern void pgtk_destroy_window (struct frame *); |
| 582 | extern void pgtk_set_parent_frame (struct frame *f, Lisp_Object, Lisp_Object); | 572 | extern void pgtk_set_parent_frame (struct frame *, Lisp_Object, Lisp_Object); |
| 583 | extern void pgtk_set_no_focus_on_map (struct frame *, Lisp_Object, Lisp_Object); | 573 | extern void pgtk_set_no_focus_on_map (struct frame *, Lisp_Object, Lisp_Object); |
| 584 | extern void pgtk_set_no_accept_focus (struct frame *, Lisp_Object, Lisp_Object); | 574 | extern void pgtk_set_no_accept_focus (struct frame *, Lisp_Object, Lisp_Object); |
| 585 | extern void pgtk_set_z_group (struct frame *, Lisp_Object, Lisp_Object); | 575 | extern void pgtk_set_z_group (struct frame *, Lisp_Object, Lisp_Object); |
| 586 | 576 | ||
| 587 | /* Cairo related functions implemented in pgtkterm.c */ | 577 | /* Cairo related functions implemented in pgtkterm.c */ |
| 588 | extern void pgtk_cr_update_surface_desired_size (struct frame *, int, int, bool); | 578 | extern void pgtk_cr_update_surface_desired_size (struct frame *, int, int, bool); |
| 589 | extern cairo_t *pgtk_begin_cr_clip (struct frame *f); | 579 | extern cairo_t *pgtk_begin_cr_clip (struct frame *); |
| 590 | extern void pgtk_end_cr_clip (struct frame *f); | 580 | extern void pgtk_end_cr_clip (struct frame *); |
| 591 | extern void pgtk_set_cr_source_with_gc_foreground (struct frame *, Emacs_GC *, bool); | 581 | extern void pgtk_set_cr_source_with_gc_foreground (struct frame *, Emacs_GC *, bool); |
| 592 | extern void pgtk_set_cr_source_with_gc_background (struct frame *, Emacs_GC *, bool); | 582 | extern void pgtk_set_cr_source_with_gc_background (struct frame *, Emacs_GC *, bool); |
| 593 | extern void pgtk_set_cr_source_with_color (struct frame *, unsigned long, bool); | 583 | extern void pgtk_set_cr_source_with_color (struct frame *, unsigned long, bool); |
| 594 | extern void pgtk_cr_draw_frame (cairo_t * cr, struct frame *f); | 584 | extern void pgtk_cr_draw_frame (cairo_t *, struct frame *); |
| 595 | extern void pgtk_cr_destroy_frame_context (struct frame *f); | 585 | extern void pgtk_cr_destroy_frame_context (struct frame *); |
| 596 | extern Lisp_Object pgtk_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type); | 586 | extern Lisp_Object pgtk_cr_export_frames (Lisp_Object , cairo_surface_type_t); |
| 597 | 587 | ||
| 598 | /* Defined in pgtkmenu.c */ | 588 | /* Defined in pgtkmenu.c */ |
| 599 | extern Lisp_Object pgtk_popup_dialog (struct frame *f, Lisp_Object header, | 589 | extern Lisp_Object pgtk_popup_dialog (struct frame *, Lisp_Object, Lisp_Object); |
| 600 | Lisp_Object contents); | 590 | extern Lisp_Object pgtk_dialog_show (struct frame *, Lisp_Object, Lisp_Object, |
| 601 | extern Lisp_Object pgtk_dialog_show (struct frame *f, Lisp_Object title, | 591 | const char **); |
| 602 | Lisp_Object header, | ||
| 603 | const char **error_name); | ||
| 604 | extern void initialize_frame_menubar (struct frame *); | 592 | extern void initialize_frame_menubar (struct frame *); |
| 605 | 593 | ||
| 606 | 594 | ||
| @@ -612,44 +600,46 @@ extern void syms_of_pgtkselect (void); | |||
| 612 | extern void syms_of_pgtkim (void); | 600 | extern void syms_of_pgtkim (void); |
| 613 | 601 | ||
| 614 | /* Initialization and marking implemented in pgtkterm.c */ | 602 | /* Initialization and marking implemented in pgtkterm.c */ |
| 615 | extern void init_pgtkterm (void); | ||
| 616 | extern void mark_pgtkterm (void); | 603 | extern void mark_pgtkterm (void); |
| 617 | extern void pgtk_delete_terminal (struct terminal *terminal); | 604 | extern void pgtk_delete_terminal (struct terminal *); |
| 618 | 605 | ||
| 619 | extern void pgtk_make_frame_visible (struct frame *f); | 606 | extern void pgtk_make_frame_visible (struct frame *); |
| 620 | extern void pgtk_make_frame_invisible (struct frame *f); | 607 | extern void pgtk_make_frame_invisible (struct frame *); |
| 621 | extern void pgtk_free_frame_resources (struct frame *); | 608 | extern void pgtk_free_frame_resources (struct frame *); |
| 622 | extern void pgtk_iconify_frame (struct frame *f); | 609 | extern void pgtk_iconify_frame (struct frame *); |
| 623 | extern void pgtk_focus_frame (struct frame *f, bool noactivate); | 610 | extern void pgtk_focus_frame (struct frame *, bool); |
| 624 | extern void pgtk_set_scroll_bar_default_width (struct frame *f); | 611 | extern void pgtk_set_scroll_bar_default_width (struct frame *); |
| 625 | extern void pgtk_set_scroll_bar_default_height (struct frame *f); | 612 | extern void pgtk_set_scroll_bar_default_height (struct frame *); |
| 626 | extern Lisp_Object pgtk_get_focus_frame (struct frame *frame); | 613 | extern Lisp_Object pgtk_get_focus_frame (struct frame *); |
| 627 | 614 | ||
| 628 | extern void pgtk_frame_rehighlight (struct pgtk_display_info *dpyinfo); | 615 | extern void pgtk_frame_rehighlight (struct pgtk_display_info *); |
| 629 | 616 | ||
| 630 | extern void pgtk_change_tab_bar_height (struct frame *, int); | 617 | extern void pgtk_change_tab_bar_height (struct frame *, int); |
| 631 | 618 | ||
| 632 | extern struct pgtk_display_info *check_pgtk_display_info (Lisp_Object object); | 619 | extern struct pgtk_display_info *check_pgtk_display_info (Lisp_Object); |
| 633 | 620 | ||
| 634 | extern void pgtk_default_font_parameter (struct frame *f, Lisp_Object parms); | 621 | extern void pgtk_default_font_parameter (struct frame *, Lisp_Object); |
| 635 | 622 | ||
| 636 | extern void pgtk_menu_set_in_use (bool in_use); | 623 | extern void pgtk_menu_set_in_use (bool); |
| 637 | 624 | ||
| 625 | /* Drag and drop functions used by Lisp. */ | ||
| 626 | extern void pgtk_update_drop_status (Lisp_Object, Lisp_Object); | ||
| 627 | extern void pgtk_finish_drop (Lisp_Object, Lisp_Object, Lisp_Object); | ||
| 638 | 628 | ||
| 639 | extern void pgtk_enqueue_string (struct frame *f, gchar * str); | 629 | extern void pgtk_enqueue_string (struct frame *, gchar *); |
| 640 | extern void pgtk_enqueue_preedit (struct frame *f, Lisp_Object image_data); | 630 | extern void pgtk_enqueue_preedit (struct frame *, Lisp_Object); |
| 641 | extern void pgtk_im_focus_in (struct frame *f); | 631 | extern void pgtk_im_focus_in (struct frame *); |
| 642 | extern void pgtk_im_focus_out (struct frame *f); | 632 | extern void pgtk_im_focus_out (struct frame *); |
| 643 | extern bool pgtk_im_filter_keypress (struct frame *f, GdkEventKey * ev); | 633 | extern bool pgtk_im_filter_keypress (struct frame *, GdkEventKey *); |
| 644 | extern void pgtk_im_set_cursor_location (struct frame *f, int x, int y, | 634 | extern void pgtk_im_set_cursor_location (struct frame *, int, int, |
| 645 | int width, int height); | 635 | int, int); |
| 646 | extern void pgtk_im_init (struct pgtk_display_info *dpyinfo); | 636 | extern void pgtk_im_init (struct pgtk_display_info *); |
| 647 | extern void pgtk_im_finish (struct pgtk_display_info *dpyinfo); | 637 | extern void pgtk_im_finish (struct pgtk_display_info *); |
| 648 | 638 | ||
| 649 | extern bool xg_set_icon (struct frame *, Lisp_Object); | 639 | extern bool xg_set_icon (struct frame *, Lisp_Object); |
| 650 | extern bool xg_set_icon_from_xpm_data (struct frame *f, const char **data); | 640 | extern bool xg_set_icon_from_xpm_data (struct frame *, const char **); |
| 651 | 641 | ||
| 652 | extern bool pgtk_text_icon (struct frame *f, const char *icon_name); | 642 | extern bool pgtk_text_icon (struct frame *, const char *); |
| 653 | 643 | ||
| 654 | extern double pgtk_frame_scale_factor (struct frame *); | 644 | extern double pgtk_frame_scale_factor (struct frame *); |
| 655 | extern int pgtk_emacs_to_gtk_modifiers (struct pgtk_display_info *, int); | 645 | extern int pgtk_emacs_to_gtk_modifiers (struct pgtk_display_info *, int); |