aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2016-01-30 11:28:37 -0800
committerPaul Eggert2016-01-30 11:28:37 -0800
commit2b41d6a979b0ea361e078891b8763b4ae7be8092 (patch)
treeaef17169e9bf8e59baa82ec7df5c1b64139d9c9f
parentfe9c8b687c5121a413342024b62824a86d2de2be (diff)
parent71468e00735a44e19814a73e8f9013c0f272c342 (diff)
downloademacs-2b41d6a979b0ea361e078891b8763b4ae7be8092.tar.gz
emacs-2b41d6a979b0ea361e078891b8763b4ae7be8092.zip
-
-rw-r--r--doc/emacs/dired.texi26
-rw-r--r--doc/lispref/control.texi224
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/functions.texi225
-rw-r--r--etc/NEWS33
-rw-r--r--lisp/progmodes/cc-engine.el171
-rw-r--r--lisp/progmodes/cc-fonts.el93
-rw-r--r--lisp/textmodes/reftex-ref.el2
-rw-r--r--src/buffer.c8
-rw-r--r--src/dispextern.h28
-rw-r--r--src/dispnew.c7
-rw-r--r--src/emacs.c7
-rw-r--r--src/emacsgtkfixed.c40
-rw-r--r--src/emacsgtkfixed.h2
-rw-r--r--src/gtkutil.c28
-rw-r--r--src/image.c67
-rw-r--r--src/keyboard.c4
-rw-r--r--src/lisp.h3
-rw-r--r--src/print.c14
-rw-r--r--src/sysdep.c2
-rw-r--r--src/window.c6
-rw-r--r--src/xdisp.c66
-rw-r--r--src/xterm.c16
-rw-r--r--src/xwidget.c554
-rw-r--r--src/xwidget.h115
25 files changed, 969 insertions, 773 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 92c1fd5a041..123f1aea936 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -778,27 +778,31 @@ Byte compile the specified Emacs Lisp files
778Compilation, elisp, The Emacs Lisp Reference Manual}. 778Compilation, elisp, The Emacs Lisp Reference Manual}.
779 779
780@kindex A @r{(Dired)} 780@kindex A @r{(Dired)}
781@findex dired-do-search 781@findex dired-do-find-regexp
782@cindex search multiple files (in Dired) 782@cindex search multiple files (in Dired)
783@item A @var{regexp} @key{RET} 783@item A @var{regexp} @key{RET}
784Search all the specified files for the regular expression @var{regexp} 784Search all the specified files for the regular expression @var{regexp}
785(@code{dired-do-search}). 785(@code{dired-do-find-regexp}).
786 786
787This command is a variant of @code{tags-search}. The search stops at 787This command is a variant of @code{xref-find-references}
788the first match it finds; use @kbd{M-x tags-loop-continue} to resume 788(@pxref{Identifier Search}), it displays the @file{*xref*} buffer,
789the search and find the next match. @xref{Identifier Search}. 789where you can navigate between matches and display them as needed
790using the commands described in @ref{Xref Commands}.
790 791
791@kindex Q @r{(Dired)} 792@kindex Q @r{(Dired)}
792@findex dired-do-query-replace-regexp 793@findex dired-do-find-regexp-and-replace
793@cindex search and replace in multiple files (in Dired) 794@cindex search and replace in multiple files (in Dired)
794@item Q @var{regexp} @key{RET} @var{to} @key{RET} 795@item Q @var{regexp} @key{RET} @var{to} @key{RET}
795Perform @code{query-replace-regexp} on each of the specified files, 796Perform @code{query-replace-regexp} on each of the specified files,
796replacing matches for @var{regexp} with the string 797replacing matches for @var{regexp} with the string
797@var{to} (@code{dired-do-query-replace-regexp}). 798@var{to} (@code{dired-do-find-regexp-and-replace}).
798 799
799This command is a variant of @code{tags-query-replace}. If you exit the 800This command is a variant of @code{xref-query-replace}. It presents
800query replace loop, you can use @kbd{M-x tags-loop-continue} to resume 801an @file{*xref*} buffer that lists all the matches of @var{regexp},
801the scan and replace more matches. @xref{Identifier Search}. 802and you can use the special commands in that buffer (@pxref{Xref
803Commands}). In particular, if you exit the query replace loop, you
804can use @kbd{r} in that buffer to replace more matches.
805@xref{Identifier Search}.
802@end table 806@end table
803 807
804@node Shell Commands in Dired 808@node Shell Commands in Dired
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 008a991102b..df60347f839 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -297,36 +297,147 @@ For example:
297@cindex pcase 297@cindex pcase
298@cindex pattern matching 298@cindex pattern matching
299 299
300To compare a particular value against various possible cases, the macro 300The @code{cond} form lets you choose between alternatives using
301@code{pcase} can come handy. It takes the following form: 301predicate conditions that compare values of expressions against
302specific values known and written in advance. However, sometimes it
303is useful to select alternatives based on more general conditions that
304distinguish between broad classes of values. The @code{pcase} macro
305allows to choose between alternatives based on matching the value of
306an expression against a series of patterns. A pattern can be a
307literal value (comparison to literal values is what @code{cond} does),
308or it can be a more general description of the expected structure of
309the expression's value.
310
311@defmac pcase expression &rest clauses
312Evaluate @var{expression} and choose among an arbitrary number of
313alternatives based on the value of @var{expression}. The possible
314alternatives are specified by @var{clauses}, each of which must be a
315list of the form @code{(@var{pattern} @var{body-forms})}.
316@code{pcase} tries to match the value of @var{expression} to the
317@var{pattern} of each clause, in textual order. If the value matches,
318the clause succeeds; @code{pcase} then evaluates its @var{body-forms},
319and returns the value of the last of @var{body-forms}. Any remaining
320@var{clauses} are ignored.
321
322The @var{pattern} part of a clause can be of one of two types:
323@dfn{QPattern}, a pattern quoted with a backquote; or a
324@dfn{UPattern}, which is not quoted. UPatterns are simpler, so we
325describe them first.
326
327Note: In the description of the patterns below, we use ``the value
328being matched'' to refer to the value of the @var{expression} that is
329the first argument of @code{pcase}.
330
331A UPattern can have one of the following forms:
302 332
303@example 333@table @code
304(pcase @var{exp} @var{branch}1 @var{branch}2 @var{branch}3 @dots{})
305@end example
306 334
307where each @var{branch} takes the form @code{(@var{upattern} 335@item '@var{val}
308@var{body-forms}@dots{})}. 336Matches if the value being matched is @code{equal} to @var{val}.
337@item @var{atom}
338Matches any @var{atom}, which can be a keyword, a number, or a string.
339(These are self-quoting, so this kind of UPattern is actually a
340shorthand for @code{'@var{atom}}.)
341@item _
342Matches any value. This is known as @dfn{don't care} or @dfn{wildcard}.
343@item @var{symbol}
344Matches any value, and additionally let-binds @var{symbol} to the
345value it matched, so that you can later refer to it, either in the
346@var{body-forms} or also later in the pattern.
347@item (pred @var{predfun})
348Matches if the predicate function @var{predfun} returns non-@code{nil}
349when called with the value being matched as its argument.
350@var{predfun} can be one of the possible forms described below.
351@item (guard @var{boolean-expression})
352Matches if @var{boolean-expression} evaluates to non-@code{nil}. This
353allows to include in a UPattern boolean conditions that refer to
354symbols bound to values (including the value being matched) by
355previous UPatterns. Typically used inside an @code{and} UPattern, see
356below. For example, @w{@code{(and x (guard (< x 10)))}} is a pattern
357which matches any number smaller than 10 and let-binds the variable
358@code{x} to that number.
359@item (let @var{upattern} @var{expression})
360Matches if the specified @var{expression} matches the specified
361@var{upattern}. This allows to match a pattern against the value of
362an @emph{arbitrary} expression, not just the expression that is the
363first argument to @code{pcase}. (It is called @code{let} because
364@var{upattern} can bind symbols to values using the @var{symbol}
365UPattern.)
366@item (app @var{function} @var{upattern})
367Matches if @var{function} applied to the value being matched returns a
368value that matches @var{upattern}. This is like the @code{pred}
369UPattern, except that it tests the result against @var{UPattern},
370rather than against a boolean truth value. The @var{function} call can
371use one of the forms described below.
372@item (or @var{upattern1} @var{upattern2}@dots{})
373Matches if one the argument UPatterns matches. As soon as the first
374matching UPattern is found, the rest are not tested. For this reason,
375if any of the UPatterns let-bind symbols to the matched value, they
376should all bind the same symbols.
377@item (and @var{upattern1} @var{upattern2}@dots{})
378Matches if all the argument UPatterns match.
379@end table
380
381The function calls used in the @code{pred} and @code{app} UPatterns
382can have one of the following forms:
383
384@table @asis
385@item function symbol, like @code{integerp}
386In this case, the named function is applied to the value being
387matched.
388@item lambda-function @code{(lambda (@var{arg}) @var{body})}
389In this case, the lambda-function is called with one argument, the
390value being matched.
391@item @code{(@var{func} @var{args}@dots{})}
392This is a function call with @var{n} specified arguments; the function
393is called with these @var{n} arguments and an additional @var{n}+1-th
394argument that is the value being matched.
395@end table
309 396
310It will first evaluate @var{exp} and then compare the value against each 397Here's an illustrative example of using UPatterns:
311@var{upattern} to see which @var{branch} to use, after which it will run the
312corresponding @var{body-forms}. A common use case is to distinguish
313between a few different constant values:
314 398
399@c FIXME: This example should use every one of the UPatterns described
400@c above at least once.
315@example 401@example
316(pcase (get-return-code x) 402(pcase (get-return-code x)
317 (`success (message "Done!")) 403 ('success (message "Done!"))
318 (`would-block (message "Sorry, can't do it now")) 404 ('would-block (message "Sorry, can't do it now"))
319 (`read-only (message "The shmliblick is read-only")) 405 ('read-only (message "The shmliblick is read-only"))
320 (`access-denied (message "You do not have the needed rights")) 406 ('access-denied (message "You do not have the needed rights"))
321 (code (message "Unknown return code %S" code))) 407 (code (message "Unknown return code %S" code)))
322@end example 408@end example
323 409
324In the last clause, @code{code} is a variable that gets bound to the value that 410The QPatterns are more powerful. They allow to match the value of the
325was returned by @code{(get-return-code x)}. 411@var{expression} that is the first argument of @code{pcase} against
412specifications of its @emph{structure}. For example, you can specify
413that the value must be a list of 2 elements whose first element is a
414string and the second element is a number. QPatterns can have one of
415the following forms:
416
417@table @code
418@item `(@var{qpattern1} . @var{qpattern2})
419Matches if the value being matched is a cons cell whose @code{car}
420matches @var{qpattern1} and whose @code{cdr} matches @var{qpattern2}.
421@item `[@var{qpattern1} @var{qpattern2} @dots{} @var{qpatternm}]
422Matches if the value being matched is a vector of length @var{m} whose
423@code{0}..@code{(@var{m}-1)}th elements match @var{qpattern1},
424@var{qpattern2} @dots{} @var{qpatternm}, respectively.
425@item `(,@var{upattern1} ,@var{upattern2} @dots{})
426Matches if the value being matched is a list whose elements match the
427corresponding @var{upattern1}, @var{upattern2}, etc.
428@item @var{atom}
429Matches if corresponding element of the value being matched is
430@code{equal} to the specified @var{atom}.
431@item ,@var{upattern}
432Matches if the corresponding element of the value being matched
433matches the specified @var{upattern}.
434@end table
435
436@end defmac
326 437
327To give a more complex example, a simple interpreter for a little 438Here is an example of using @code{pcase} to implement a simple
328expression language could look like (note that this example requires 439interpreter for a little expression language (note that this example
329lexical binding): 440requires lexical binding, @pxref{Lexical Binding}):
330 441
331@example 442@example
332(defun evaluate (exp env) 443(defun evaluate (exp env)
@@ -340,13 +451,19 @@ lexical binding):
340 (_ (error "Unknown expression %S" exp)))) 451 (_ (error "Unknown expression %S" exp))))
341@end example 452@end example
342 453
343Where @code{`(add ,x ,y)} is a pattern that checks that @code{exp} is a three 454Here @code{`(add ,x ,y)} is a pattern that checks that @code{exp} is a
344element list starting with the symbol @code{add}, then extracts the second and 455three-element list starting with the literal symbol @code{add}, then
345third elements and binds them to the variables @code{x} and @code{y}. 456extracts the second and third elements and binds them to the variables
346@code{(pred numberp)} is a pattern that simply checks that @code{exp} 457@code{x} and @code{y}. Then it evaluates @code{x} and @code{y} and
347is a number, and @code{_} is the catch-all pattern that matches anything. 458adds the results. The @code{call} and @code{fn} patterns similarly
459implement two flavors of function calls. @code{(pred numberp)} is a
460pattern that simply checks that @code{exp} is a number and if so,
461evaluates it. @code{(pred symbolp)} matches symbols, and returns
462their association. Finally, @code{_} is the catch-all pattern that
463matches anything, so it's suitable for reporting syntax errors.
348 464
349Here are some sample programs including their evaluation results: 465Here are some sample programs in this small language, including their
466evaluation results:
350 467
351@example 468@example
352(evaluate '(add 1 2) nil) ;=> 3 469(evaluate '(add 1 2) nil) ;=> 3
@@ -355,56 +472,13 @@ Here are some sample programs including their evaluation results:
355(evaluate '(sub 1 2) nil) ;=> error 472(evaluate '(sub 1 2) nil) ;=> error
356@end example 473@end example
357 474
358There are two kinds of patterns involved in @code{pcase}, called 475Additional UPatterns can be defined using the @code{pcase-defmacro}
359@emph{U-patterns} and @emph{Q-patterns}. The @var{upattern} mentioned above 476macro.
360are U-patterns and can take the following forms:
361 477
362@table @code 478@defmac pcase-defmacro name args &rest body
363@item `@var{qpattern} 479Define a new UPattern for @code{pcase}. The UPattern will have the
364This is one of the most common form of patterns. The intention is to mimic the 480form @code{(@var{name} @var{args})}.
365backquote macro: this pattern matches those values that could have been built 481@end defmac
366by such a backquote expression. Since we're pattern matching rather than
367building a value, the unquote does not indicate where to plug an expression,
368but instead it lets one specify a U-pattern that should match the value at
369that location.
370
371More specifically, a Q-pattern can take the following forms:
372@table @code
373@item (@var{qpattern1} . @var{qpattern2})
374This pattern matches any cons cell whose @code{car} matches @var{qpattern1} and
375whose @code{cdr} matches @var{qpattern2}.
376@item [@var{qpattern1} @var{qpattern2} @dots{} @var{qpatternm}]
377This pattern matches a vector of length @var{M} whose 0..(@var{M}-1)th
378elements match @var{qpattern1}, @var{qpattern2} @dots{} @var{qpatternm},
379respectively.
380@item @var{atom}
381This pattern matches any atom @code{equal} to @var{atom}.
382@item ,@var{upattern}
383This pattern matches any object that matches the @var{upattern}.
384@end table
385
386@item @var{symbol}
387A mere symbol in a U-pattern matches anything, and additionally let-binds this
388symbol to the value that it matched, so that you can later refer to it, either
389in the @var{body-forms} or also later in the pattern.
390@item _
391This so-called @emph{don't care} pattern matches anything, like the previous
392one, but unlike symbol patterns it does not bind any variable.
393@item (pred @var{pred})
394This pattern matches if the function @var{pred} returns non-@code{nil} when
395called with the object being matched.
396@item (or @var{upattern1} @var{upattern2}@dots{})
397This pattern matches as soon as one of the argument patterns succeeds.
398All argument patterns should let-bind the same variables.
399@item (and @var{upattern1} @var{upattern2}@dots{})
400This pattern matches only if all the argument patterns succeed.
401@item (guard @var{exp})
402This pattern ignores the object being examined and simply succeeds if @var{exp}
403evaluates to non-@code{nil} and fails otherwise. It is typically used inside
404an @code{and} pattern. For example, @code{(and x (guard (< x 10)))}
405is a pattern which matches any number smaller than 10 and let-binds it to
406the variable @code{x}.
407@end table
408 482
409@node Combining Conditions 483@node Combining Conditions
410@section Constructs for Combining Conditions 484@section Constructs for Combining Conditions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index da519f579c9..4c1541e98c6 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -536,6 +536,7 @@ Functions
536* Calling Functions:: How to use an existing function. 536* Calling Functions:: How to use an existing function.
537* Mapping Functions:: Applying a function to each element of a list, etc. 537* Mapping Functions:: Applying a function to each element of a list, etc.
538* Anonymous Functions:: Lambda expressions are functions with no names. 538* Anonymous Functions:: Lambda expressions are functions with no names.
539* Generic Functions:: Polymorphism, Emacs-style.
539* Function Cells:: Accessing or setting the function definition 540* Function Cells:: Accessing or setting the function definition
540 of a symbol. 541 of a symbol.
541* Closures:: Functions that enclose a lexical environment. 542* Closures:: Functions that enclose a lexical environment.
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 1e8e7540395..c5f5b4c22c4 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -18,6 +18,7 @@ define them.
18* Calling Functions:: How to use an existing function. 18* Calling Functions:: How to use an existing function.
19* Mapping Functions:: Applying a function to each element of a list, etc. 19* Mapping Functions:: Applying a function to each element of a list, etc.
20* Anonymous Functions:: Lambda expressions are functions with no names. 20* Anonymous Functions:: Lambda expressions are functions with no names.
21* Generic Functions:: Polymorphism, Emacs-style.
21* Function Cells:: Accessing or setting the function definition 22* Function Cells:: Accessing or setting the function definition
22 of a symbol. 23 of a symbol.
23* Closures:: Functions that enclose a lexical environment. 24* Closures:: Functions that enclose a lexical environment.
@@ -1092,6 +1093,230 @@ the compiled code. The byte-compiler cannot assume this list is a
1092function, even though it looks like one, since it does not know that 1093function, even though it looks like one, since it does not know that
1093@code{change-property} intends to use it as a function. 1094@code{change-property} intends to use it as a function.
1094 1095
1096@node Generic Functions
1097@section Generic Functions
1098@cindex generic functions
1099@cindex polymorphism
1100
1101 Functions defined using @code{defun} have a hard-coded set of
1102assumptions about the types and expected values of their arguments.
1103For example, a function that was designed to handle values of its
1104argument that are either numbers or lists of numbers will fail or
1105signal an error if called with a value of any other type, such as a
1106vector or a string. This happens because the implementation of the
1107function is not prepared to deal with types other than those assumed
1108during the design.
1109
1110 By contrast, object-oriented programs use @dfn{polymorphic
1111functions}: a set of specialized functions having the same name, each
1112one of which was written for a certain specific set of argument types.
1113Which of the functions is actually called is decided at run time based
1114on the types of the actual arguments.
1115
1116@cindex CLOS
1117 Emacs provides support for polymorphism. Like other Lisp
1118environments, notably Common Lisp and its Common Lisp Object System
1119(@acronym{CLOS}), this support is based on @dfn{generic functions}.
1120The Emacs generic functions closely follow @acronym{CLOS}, including
1121use of similar names, so if you have experience with @acronym{CLOS},
1122the rest of this section will sound very familiar.
1123
1124 A generic function specifies an abstract operation, by defining its
1125name and list of arguments, but (usually) no implementation. The
1126actual implementation for several specific classes of arguments is
1127provided by @dfn{methods}, which should be defined separately. Each
1128method that implements a generic function has the same name as the
1129generic function, but the method's definition indicates what kinds of
1130arguments it can handle by @dfn{specializing} the arguments defined by
1131the generic function. These @dfn{argument specializers} can be more
1132or less specific; for example, a @code{string} type is more specific
1133than a more general type, such as @code{sequence}.
1134
1135 Note that, unlike in message-based OO languages, such as C@t{++} and
1136Simula, methods that implement generic functions don't belong to a
1137class, they belong to the generic function they implement.
1138
1139 When a generic function is invoked, it selects the applicable
1140methods by comparing the actual arguments passed by the caller with
1141the argument specializers of each method. A method is applicable if
1142the actual arguments of the call are compatible with the method's
1143specializers. If more than one method is applicable, they are
1144combined using certain rules, described below, and the combination
1145then handles the call.
1146
1147@defmac cl-defgeneric name arguments [documentation] [options-and-methods@dots{}] &rest body
1148This macro defines a generic function with the specified @var{name}
1149and @var{arguments}. If @var{body} is present, it provides the
1150default implementation. If @var{documentation} is present (it should
1151always be), it specifies the documentation string for the generic
1152function, in the form @code{(:documentation @var{docstring})}. The
1153optional @var{options-and-methods} can be one of the following forms:
1154
1155@table @code
1156@item (declare @var{declarations})
1157A declare form, as described in @ref{Declare Form}.
1158@item (:argument-precedence-order &rest @var{args})
1159This form affects the sorting order for combining applicable methods.
1160Normally, when two methods are compared during combination, method
1161arguments are examined left to right, and the first method whose
1162argument specializer is more specific will come before the other one.
1163The order defined by this form overrides that, and the arguments are
1164examined according to their order in this form, and not left to right.
1165@item (:method [@var{qualifiers}@dots{}] args &rest body)
1166This form defines a method like @code{cl-defmethod} does.
1167@end table
1168@end defmac
1169
1170@defmac cl-defmethod name [qualifier] arguments &rest [docstring] body
1171This macro defines a particular implementation for the generic
1172function called @var{name}. The implementation code is given by
1173@var{body}. If present, @var{docstring} is the documentation string
1174for the method. The @var{arguments} list, which must be identical in
1175all the methods that implement a generic function, and must match the
1176argument list of that function, provides argument specializers of the
1177form @code{(@var{arg} @var{spec})}, where @var{arg} is the argument
1178name as specified in the @code{cl-defgeneric} call, and @var{spec} is
1179one of the following specializer forms:
1180
1181@table @code
1182@item @var{type}
1183This specializer requires the argument to be of the given @var{type},
1184one of the types from the type hierarchy described below.
1185@item (eql @var{object})
1186This specializer requires the argument be @code{eql} to the given
1187@var{object}.
1188@item (head @var{object})
1189The argument must be a cons cell whose @code{car} is @code{eql} to
1190@var{object}.
1191@item @var{struct-tag}
1192The argument must be an instance of a class named @var{struct-tag}
1193defined with @code{cl-defstruct} (@pxref{Structures,,, cl, Common Lisp
1194Extensions for GNU Emacs Lisp}), or of one of its parent classes.
1195@end table
1196
1197Alternatively, the argument specializer can be of the form
1198@code{&context (@var{expr} @var{spec})}, in which case the value of
1199@var{expr} must be compatible with the specializer provided by
1200@var{spec}; @var{spec} can be any of the forms described above. In
1201other words, this form of specializer uses the value of @var{expr}
1202instead of arguments for the decision whether the method is
1203applicable. For example, @code{&context (overwrite-mode (eql t))}
1204will make the method compatible only when @code{overwrite-mode} is
1205turned on.
1206
1207The type specializer, @code{(@var{arg} @var{type})}, can specify one
1208of the @dfn{system types} in the following list. When a parent type
1209is specified, an argument whose type is any of its more specific child
1210types, as well as grand-children, grand-grand-children, etc. will also
1211be compatible.
1212
1213@table @code
1214@item integer
1215Parent type: @code{number}.
1216@item number
1217@item null
1218Parent type: @code{symbol}
1219@item symbol
1220@item string
1221Parent type: @code{array}.
1222@item array
1223Parent type: @code{sequence}.
1224@item cons
1225Parent type: @code{list}.
1226@item list
1227Parent type: @code{sequence}.
1228@item marker
1229@item overlay
1230@item float
1231Parent type: @code{number}.
1232@item window-configuration
1233@item process
1234@item window
1235@item subr
1236@item compiled-function
1237@item buffer
1238@item char-table
1239Parent type: @code{array}.
1240@item bool-vector
1241Parent type: @code{array}.
1242@item vector
1243Parent type: @code{array}.
1244@item frame
1245@item hash-table
1246@item font-spec
1247@item font-entity
1248@item font-object
1249@end table
1250
1251The optional @var{qualifier} allows to combine several applicable
1252methods. If it is not present, the defined method is a @dfn{primary}
1253method, responsible for providing the primary implementation of the
1254generic function for the specialized arguments. You can also define
1255@dfn{auxiliary methods}, by using one of the following values as
1256@var{qualifier}:
1257
1258@table @code
1259@item :before
1260This auxiliary method will run before the primary method. More
1261accurately, all the @code{:before} methods will run before the
1262primary, in the most-specific-first order.
1263@item :after
1264This auxiliary method will run after the primary method. More
1265accurately, all such methods will run after the primary, in the
1266most-specific-last order.
1267@item :around
1268This auxiliary method will run @emph{instead} of the primary method.
1269The most specific of such methods will be run before any other method.
1270Such methods normally use @code{cl-call-next-method}, described below,
1271to invoke the other auxiliary or primary methods.
1272@item :extra @var{string}
1273This allows to add more methods, distinguished by @var{string}, for
1274the same specializers and qualifiers.
1275@end table
1276@end defmac
1277
1278@cindex dispatch of methods for generic function
1279@cindex multiple-dispatch methods
1280Each time a generic function is called, it builds the @dfn{effective
1281method} which will handle this invocation by combining the applicable
1282methods defined for the function. The process of finding the
1283applicable methods and producing the effective method is called
1284@dfn{dispatch}. The applicable methods are those all of whose
1285specializers are compatible with the actual arguments of the call.
1286Since all of the arguments must be compatible with the specializers,
1287they all determine whether a method is applicable. Methods that
1288explicitly specialize more than one argument are called
1289@dfn{multiple-dispatch methods}.
1290
1291The applicable methods are sorted into the order in which they will be
1292combined. The method whose left-most argument specializer is the most
1293specific one will come first in the order. (Specifying
1294@code{:argument-precedence-order} as part of @code{cl-defmethod}
1295overrides that, as described above.) If the method body calls
1296@code{cl-call-next-method}, the next most-specific method will run.
1297If there are applicable @code{:around} methods, the most-specific of
1298them will run first; it should call @code{cl-call-next-method} to run
1299any of the less specific @code{:around} methods. Next, the
1300@code{:before} methods run in the order of their specificity, followed
1301by the primary method, and lastly the @code{:after} methods in the
1302reverse order of their specificity.
1303
1304@defun cl-call-next-method &rest args
1305When invoked from within the lexical body of a primary or an
1306@code{:around} auxiliary method, call the next applicable method for
1307the same generic function. Normally, it is called with no arguments,
1308which means to call the next applicable method with the same arguments
1309that the calling method was invoked. Otherwise, the specified
1310arguments are used instead.
1311@end defun
1312
1313@defun cl-next-method-p
1314This function, when called from within the lexical body of a primary
1315or an @code{:around} auxiliary method, returns non-@code{nil} if there
1316is a next method to call.
1317@end defun
1318
1319
1095@node Function Cells 1320@node Function Cells
1096@section Accessing Function Cell Contents 1321@section Accessing Function Cell Contents
1097 1322
diff --git a/etc/NEWS b/etc/NEWS
index 4a370a9c809..1cc45c3c27d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -90,6 +90,8 @@ by setting `autoload-timestamps' to nil.
90** New configure option --with-cairo. 90** New configure option --with-cairo.
91This builds Emacs with Cairo drawing. As a side effect, it provides 91This builds Emacs with Cairo drawing. As a side effect, it provides
92support for built-in printing, when Emacs was built with GTK+. 92support for built-in printing, when Emacs was built with GTK+.
93Cairo drawing is an experimental feature in Emacs, and subject to
94change in future releases.
93 95
94+++ 96+++
95** New configure option --with-modules. 97** New configure option --with-modules.
@@ -577,9 +579,12 @@ If you need your objects to be named, do it by inheriting from `eieio-named'.
577*** The <class> variables are declared obsolete. 579*** The <class> variables are declared obsolete.
578+++ 580+++
579*** The <initarg> variables are declared obsolete. 581*** The <initarg> variables are declared obsolete.
582+++
580*** defgeneric and defmethod are declared obsolete. 583*** defgeneric and defmethod are declared obsolete.
584Use the equivalent facilities from cl-generic.el instead.
581+++ 585+++
582*** `constructor' is now an obsolete alias for `make-instance'. 586*** `constructor' is now an obsolete alias for `make-instance'.
587--- `pcase' accepts a new UPattern `eieio'.
583 588
584** ido 589** ido
585 590
@@ -772,6 +777,9 @@ prepending it.
772+++ 777+++
773*** New functions `cl-fresh-line', `cl-digit-char-p', and `cl-parse-integer'. 778*** New functions `cl-fresh-line', `cl-digit-char-p', and `cl-parse-integer'.
774 779
780---
781*** `pcase' accepts the new UPattern `cl-struct'.
782
775** Calendar and diary 783** Calendar and diary
776 784
777+++ 785+++
@@ -1073,6 +1081,10 @@ As a result of this, the following commands are now obsolete:
1073replacements yet. 1081replacements yet.
1074 1082
1075+++ 1083+++
1084*** Variants of `tags-search' and `tags-query-replace' in Dired were also
1085replaced by xref-style commands, see the "Dired" section below.
1086
1087+++
1076*** New variables 1088*** New variables
1077 1089
1078`find-tag-marker-ring-length' is now an obsolete alias for 1090`find-tag-marker-ring-length' is now an obsolete alias for
@@ -1216,6 +1228,17 @@ compression command is determined from the new
1216*** `W' is now bound to `browse-url-of-dired-file', and is useful for 1228*** `W' is now bound to `browse-url-of-dired-file', and is useful for
1217viewing HTML files and the like. 1229viewing HTML files and the like.
1218 1230
1231*** New user interface for the `A' and `Q' commands.
1232These keys, now bound to `dired-do-find-regexp' and
1233`dired-do-find-regexp-and-replace', work similarly to
1234`xref-find-apropos' and `xref-query-replace': they present the matches
1235in the `*xref*' buffer and let you move through the matches. No need
1236to use `tags-loop-continue' to resume the search or replace loop. The
1237previous commands, `dired-do-search' and
1238`dired-do-query-replace-regexp', are still available, but not bound to
1239keys; rebind `A' and `Q' to invoke them if you want the old behavior
1240back. We intend to obsolete the old commands in a future release.
1241
1219** Tabulated List Mode 1242** Tabulated List Mode
1220 1243
1221+++ 1244+++
@@ -1246,7 +1269,10 @@ command is called from Emacs (i.e., INSIDE_EMACS environment variable
1246is set). This feature requires newer versions of GnuPG (2.1.5 or 1269is set). This feature requires newer versions of GnuPG (2.1.5 or
1247later) and Pinentry (0.9.5 or later). 1270later) and Pinentry (0.9.5 or later).
1248 1271
1272+++
1249** cl-generic.el provides CLOS-style multiple-dispatch generic functions. 1273** cl-generic.el provides CLOS-style multiple-dispatch generic functions.
1274The main entry points are `cl-defgeneric' and `cl-defmethod'. See the
1275node "Generic Functions" in the Emacs Lisp manual for more details.
1250 1276
1251--- 1277---
1252** scss-mode (a minor variant of css-mode) 1278** scss-mode (a minor variant of css-mode)
@@ -1266,11 +1292,12 @@ a typographically-correct documents.
1266** The `seq' library adds sequence manipulation functions and macros 1292** The `seq' library adds sequence manipulation functions and macros
1267that complement basic functions provided by subr.el. All functions 1293that complement basic functions provided by subr.el. All functions
1268are prefixed with `seq-' and work on lists, strings and vectors. 1294are prefixed with `seq-' and work on lists, strings and vectors.
1295`pcase' accepts a new Upattern `seq'.
1269 1296
1270--- 1297---
1271** The `map' library provides map-manipulation functions that work on 1298** The `map' library provides map-manipulation functions that work on
1272alists, hash-table and arrays. All functions are prefixed with 1299alists, hash-table and arrays. All functions are prefixed with
1273`map-'. 1300`map-'. `pcase' accepts a new UPattern `map'.
1274 1301
1275--- 1302---
1276** The `thunk' library provides functions and macros to control the 1303** The `thunk' library provides functions and macros to control the
@@ -1441,7 +1468,9 @@ that happen, `unhandled-file-name-directory' now defaults to calling
1441* Lisp Changes in Emacs 25.1 1468* Lisp Changes in Emacs 25.1
1442 1469
1443** pcase 1470** pcase
1444*** New UPatterns `quote', `app', `cl-struct', `eieio', `seq', and `map'. 1471+++
1472*** New UPatterns `quote', `app'.
1473+++
1445*** New UPatterns can be defined with `pcase-defmacro'. 1474*** New UPatterns can be defined with `pcase-defmacro'.
1446+++ 1475+++
1447*** New vector QPattern. 1476*** New vector QPattern.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index b08c555e34f..7d3f5282214 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6802,6 +6802,110 @@ comment at the start of cc-engine.el for more info."
6802 ;; This identifier is bound only in the inner let. 6802 ;; This identifier is bound only in the inner let.
6803 '(setq start id-start)))) 6803 '(setq start id-start))))
6804 6804
6805(defun c-forward-declarator (&optional limit)
6806 ;; Assuming point is at the start of a declarator, move forward over it,
6807 ;; leaving point at the next token after it (e.g. a ) or a ; or a ,).
6808 ;;
6809 ;; Return a list (ID-START ID-END BRACKETS-AFTER-ID GOT-INIT), where ID-START and
6810 ;; ID-END are the bounds of the declarator's identifier, and
6811 ;; BRACKETS-AFTER-ID is non-nil if a [...] pair is present after the id.
6812 ;; GOT-INIT is non-nil when the declarator is followed by "=" or "(".
6813 ;;
6814 ;; If no declarator is found, leave point unmoved and return nil. LIMIT is
6815 ;; an optional limit for forward searching.
6816 ;;
6817 ;; Note that the global variable `c-last-identifier-range' is written to, so
6818 ;; the caller should bind it if necessary.
6819
6820 ;; Inside the following "condition form", we move forward over the
6821 ;; declarator's identifier up as far as any opening bracket (for array
6822 ;; size) or paren (for parameters of function-type) or brace (for
6823 ;; array/struct initialization) or "=" or terminating delimiter
6824 ;; (e.g. "," or ";" or "}").
6825 (let ((here (point))
6826 id-start id-end brackets-after-id paren-depth)
6827 (or limit (setq limit (point-max)))
6828 (if (and
6829 (< (point) limit)
6830
6831 ;; The following form moves forward over the declarator's
6832 ;; identifier (and what precedes it), returning t. If there
6833 ;; wasn't one, it returns nil.
6834 (let (got-identifier)
6835 (setq paren-depth 0)
6836 ;; Skip over type decl prefix operators, one for each iteration
6837 ;; of the while. These are, e.g. "*" in "int *foo" or "(" and
6838 ;; "*" in "int (*foo) (void)" (Note similar code in
6839 ;; `c-forward-decl-or-cast-1'.)
6840 (while (and (looking-at c-type-decl-prefix-key)
6841 (if (and (c-major-mode-is 'c++-mode)
6842 (match-beginning 3))
6843 ;; If the third submatch matches in C++ then
6844 ;; we're looking at an identifier that's a
6845 ;; prefix only if it specifies a member pointer.
6846 (progn
6847 (setq id-start (point))
6848 (c-forward-name)
6849 (if (looking-at "\\(::\\)")
6850 ;; We only check for a trailing "::" and
6851 ;; let the "*" that should follow be
6852 ;; matched in the next round.
6853 t
6854 ;; It turned out to be the real identifier,
6855 ;; so flag that and stop.
6856 (setq got-identifier t)
6857 nil))
6858 t))
6859 (if (eq (char-after) ?\()
6860 (progn
6861 (setq paren-depth (1+ paren-depth))
6862 (forward-char))
6863 (goto-char (match-end 1)))
6864 (c-forward-syntactic-ws))
6865
6866 ;; If we haven't passed the identifier already, do it now.
6867 (unless got-identifier
6868 (setq id-start (point))
6869 (c-forward-name))
6870 (prog1
6871 (/= (point) here)
6872 (save-excursion
6873 (c-backward-syntactic-ws)
6874 (setq id-end (point)))))
6875
6876 ;; Skip out of the parens surrounding the identifier. If closing
6877 ;; parens are missing, this form returns nil.
6878 (or (= paren-depth 0)
6879 (c-safe (goto-char (scan-lists (point) 1 paren-depth))))
6880
6881 (<= (point) limit)
6882
6883 ;; Skip over any trailing bit, such as "__attribute__".
6884 (progn
6885 (when (looking-at c-decl-hangon-key)
6886 (c-forward-keyword-clause 1))
6887 (<= (point) limit))
6888
6889 ;; Search syntactically to the end of the declarator (";",
6890 ;; ",", a closing paren, eob etc) or to the beginning of an
6891 ;; initializer or function prototype ("=" or "\\s\(").
6892 ;; Note that square brackets are now not also treated as
6893 ;; initializers, since this broke when there were also
6894 ;; initializing brace lists.
6895 (let (found)
6896 (while
6897 (and (setq found (c-syntactic-re-search-forward
6898 "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
6899 (eq (char-before) ?\[)
6900 (c-go-up-list-forward))
6901 (setq brackets-after-id t))
6902 (backward-char)
6903 found))
6904 (list id-start id-end brackets-after-id (match-beginning 1))
6905
6906 (goto-char here)
6907 nil)))
6908
6805(defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end) 6909(defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end)
6806 ;; Move forward over a declaration or a cast if at the start of one. 6910 ;; Move forward over a declaration or a cast if at the start of one.
6807 ;; The point is assumed to be at the start of some token. Nil is 6911 ;; The point is assumed to be at the start of some token. Nil is
@@ -8156,14 +8260,14 @@ comment at the start of cc-engine.el for more info."
8156 ;; Return the position of the first argument declaration if point is 8260 ;; Return the position of the first argument declaration if point is
8157 ;; inside a K&R style argument declaration list, nil otherwise. 8261 ;; inside a K&R style argument declaration list, nil otherwise.
8158 ;; `c-recognize-knr-p' is not checked. If LIM is non-nil, it's a 8262 ;; `c-recognize-knr-p' is not checked. If LIM is non-nil, it's a
8159 ;; position that bounds the backward search for the argument list. 8263 ;; position that bounds the backward search for the argument list. This
8264 ;; function doesn't move point.
8160 ;; 8265 ;;
8161 ;; Point must be within a possible K&R region, e.g. just before a top-level 8266 ;; Point must be within a possible K&R region, e.g. just before a top-level
8162 ;; "{". It must be outside of parens and brackets. The test can return 8267 ;; "{". It must be outside of parens and brackets. The test can return
8163 ;; false positives otherwise. 8268 ;; false positives otherwise.
8164 ;; 8269 ;;
8165 ;; This function might do hidden buffer changes. 8270 ;; This function might do hidden buffer changes.
8166
8167 (save-excursion 8271 (save-excursion
8168 (save-restriction 8272 (save-restriction
8169 ;; If we're in a macro, our search range is restricted to it. Narrow to 8273 ;; If we're in a macro, our search range is restricted to it. Narrow to
@@ -8172,8 +8276,12 @@ comment at the start of cc-engine.el for more info."
8172 (macro-end (save-excursion (and macro-start (c-end-of-macro) (point)))) 8276 (macro-end (save-excursion (and macro-start (c-end-of-macro) (point))))
8173 (low-lim (max (or lim (point-min)) (or macro-start (point-min)))) 8277 (low-lim (max (or lim (point-min)) (or macro-start (point-min))))
8174 before-lparen after-rparen 8278 before-lparen after-rparen
8175 (pp-count-out 20)) ; Max number of paren/brace constructs before 8279 (here (point))
8280 (pp-count-out 20) ; Max number of paren/brace constructs before
8176 ; we give up 8281 ; we give up
8282 ids ; List of identifiers in the parenthesised list.
8283 id-start after-prec-token decl-or-cast decl-res
8284 c-last-identifier-range identifier-ok)
8177 (narrow-to-region low-lim (or macro-end (point-max))) 8285 (narrow-to-region low-lim (or macro-end (point-max)))
8178 8286
8179 ;; Search backwards for the defun's argument list. We give up if we 8287 ;; Search backwards for the defun's argument list. We give up if we
@@ -8192,8 +8300,12 @@ comment at the start of cc-engine.el for more info."
8192 ;; int foo (bar, baz, yuk) 8300 ;; int foo (bar, baz, yuk)
8193 ;; int bar [] ; 8301 ;; int bar [] ;
8194 ;; int (*baz) (my_type) ; 8302 ;; int (*baz) (my_type) ;
8195 ;; int (*) (void) (*yuk) (void) ; 8303 ;; int (*(* yuk) (void)) (void) ;
8196 ;; { 8304 ;; {
8305 ;;
8306 ;; Additionally, for a knr list to be recognized:
8307 ;; o - The identifier of each deeclarator up to and including the
8308 ;; one "near" point must be contained in the arg list.
8197 8309
8198 (catch 'knr 8310 (catch 'knr
8199 (while (> pp-count-out 0) ; go back one paren/bracket pair each time. 8311 (while (> pp-count-out 0) ; go back one paren/bracket pair each time.
@@ -8239,21 +8351,58 @@ comment at the start of cc-engine.el for more info."
8239 (goto-char before-lparen) 8351 (goto-char before-lparen)
8240 (c-forward-token-2) ; to first token inside parens 8352 (c-forward-token-2) ; to first token inside parens
8241 (and 8353 (and
8242 (c-on-identifier) 8354 (setq id-start (c-on-identifier)) ; Must be at least one.
8243 (c-forward-token-2)
8244 (catch 'id-list 8355 (catch 'id-list
8245 (while (eq (char-after) ?\,) 8356 (while
8357 (progn
8358 (forward-char)
8359 (c-end-of-current-token)
8360 (push (buffer-substring-no-properties id-start
8361 (point))
8362 ids)
8363 (c-forward-syntactic-ws)
8364 (eq (char-after) ?\,))
8246 (c-forward-token-2) 8365 (c-forward-token-2)
8247 (unless (c-on-identifier) (throw 'id-list nil)) 8366 (unless (setq id-start (c-on-identifier))
8248 (c-forward-token-2)) 8367 (throw 'id-list nil)))
8249 (eq (char-after) ?\)))))) 8368 (eq (char-after) ?\)))))
8250 8369
8370 ;; Are all the identifiers in the k&r list up to the
8371 ;; current one also in the argument list?
8372 (progn
8373 (forward-char) ; over the )
8374 (setq after-prec-token after-rparen)
8375 (c-forward-syntactic-ws)
8376 (while (and
8377 (or (consp (setq decl-or-cast
8378 (c-forward-decl-or-cast-1
8379 after-prec-token
8380 nil ; Or 'arglist ???
8381 nil)))
8382 (progn
8383 (goto-char after-prec-token)
8384 (c-forward-syntactic-ws)
8385 (setq identifier-ok (eq (char-after) ?{))
8386 nil))
8387 (eq (char-after) ?\;)
8388 (setq after-prec-token (1+ (point)))
8389 (goto-char (car decl-or-cast))
8390 (setq decl-res (c-forward-declarator))
8391 (setq identifier-ok
8392 (member (buffer-substring-no-properties
8393 (car decl-res) (cadr decl-res))
8394 ids))
8395 (progn
8396 (goto-char after-prec-token)
8397 (prog1 (< (point) here)
8398 (c-forward-syntactic-ws))))
8399 (setq identifier-ok nil))
8400 identifier-ok))
8251 ;; ...Yes. We've identified the function's argument list. 8401 ;; ...Yes. We've identified the function's argument list.
8252 (throw 'knr 8402 (throw 'knr
8253 (progn (goto-char after-rparen) 8403 (progn (goto-char after-rparen)
8254 (c-forward-syntactic-ws) 8404 (c-forward-syntactic-ws)
8255 (point))) 8405 (point)))
8256
8257 ;; ...No. The current parens aren't the function's arg list. 8406 ;; ...No. The current parens aren't the function's arg list.
8258 (goto-char before-lparen)) 8407 (goto-char before-lparen))
8259 8408
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 03e67a99515..1e101d12aac 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1006,6 +1006,7 @@ casts and declarations are fontified. Used on level 2 and higher."
1006 ;;(message "c-font-lock-declarators from %s to %s" (point) limit) 1006 ;;(message "c-font-lock-declarators from %s to %s" (point) limit)
1007 (c-fontify-types-and-refs 1007 (c-fontify-types-and-refs
1008 ((pos (point)) next-pos id-start id-end 1008 ((pos (point)) next-pos id-start id-end
1009 decl-res
1009 paren-depth 1010 paren-depth
1010 id-face got-init 1011 id-face got-init
1011 c-last-identifier-range 1012 c-last-identifier-range
@@ -1015,93 +1016,15 @@ casts and declarations are fontified. Used on level 2 and higher."
1015 ;; The following `while' fontifies a single declarator id each time round. 1016 ;; The following `while' fontifies a single declarator id each time round.
1016 ;; It loops only when LIST is non-nil. 1017 ;; It loops only when LIST is non-nil.
1017 (while 1018 (while
1018 ;; Inside the following "condition form", we move forward over the 1019 (and pos (setq decl-res (c-forward-declarator limit)))
1019 ;; declarator's identifier up as far as any opening bracket (for array 1020 (setq next-pos (point)
1020 ;; size) or paren (for parameters of function-type) or brace (for 1021 id-start (car decl-res)
1021 ;; array/struct initialization) or "=" or terminating delimiter 1022 id-face (if (and (eq (char-after) ?\()
1022 ;; (e.g. "," or ";" or "}"). 1023 (not (car (cddr decl-res)))) ; brackets-after-id
1023 (and
1024 pos
1025 (< (point) limit)
1026
1027 ;; The following form moves forward over the declarator's
1028 ;; identifier (and what precedes it), returning t. If there
1029 ;; wasn't one, it returns nil, terminating the `while'.
1030 (let (got-identifier)
1031 (setq paren-depth 0)
1032 ;; Skip over type decl prefix operators, one for each iteration
1033 ;; of the while. These are, e.g. "*" in "int *foo" or "(" and
1034 ;; "*" in "int (*foo) (void)" (Note similar code in
1035 ;; `c-forward-decl-or-cast-1'.)
1036 (while (and (looking-at c-type-decl-prefix-key)
1037 (if (and (c-major-mode-is 'c++-mode)
1038 (match-beginning 3))
1039 ;; If the third submatch matches in C++ then
1040 ;; we're looking at an identifier that's a
1041 ;; prefix only if it specifies a member pointer.
1042 (progn
1043 (setq id-start (point))
1044 (c-forward-name)
1045 (if (looking-at "\\(::\\)")
1046 ;; We only check for a trailing "::" and
1047 ;; let the "*" that should follow be
1048 ;; matched in the next round.
1049 t
1050 ;; It turned out to be the real identifier,
1051 ;; so flag that and stop.
1052 (setq got-identifier t)
1053 nil))
1054 t))
1055 (if (eq (char-after) ?\()
1056 (progn
1057 (setq paren-depth (1+ paren-depth))
1058 (forward-char))
1059 (goto-char (match-end 1)))
1060 (c-forward-syntactic-ws))
1061
1062 ;; If we haven't passed the identifier already, do it now.
1063 (unless got-identifier
1064 (setq id-start (point))
1065 (c-forward-name))
1066 (setq id-end (point))
1067
1068 (/= id-end pos))
1069
1070 ;; Skip out of the parens surrounding the identifier. If closing
1071 ;; parens are missing, this form returns nil.
1072 (or (= paren-depth 0)
1073 (c-safe (goto-char (scan-lists (point) 1 paren-depth))))
1074
1075 (<= (point) limit)
1076
1077 ;; Skip over any trailing bit, such as "__attribute__".
1078 (progn
1079 (when (looking-at c-decl-hangon-key)
1080 (c-forward-keyword-clause 1))
1081 (<= (point) limit))
1082
1083 ;; Search syntactically to the end of the declarator (";",
1084 ;; ",", a closing paren, eob etc) or to the beginning of an
1085 ;; initializer or function prototype ("=" or "\\s(").
1086 ;; Note that square brackets are now not also treated as
1087 ;; initializers, since this broke when there were also
1088 ;; initializing brace lists.
1089 (let (found)
1090 (while
1091 (and (setq found (c-syntactic-re-search-forward
1092 "[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
1093 (eq (char-before) ?\[)
1094 (c-go-up-list-forward))
1095 (setq brackets-after-id t))
1096 found))
1097
1098 (setq next-pos (match-beginning 0)
1099 id-face (if (and (eq (char-after next-pos) ?\()
1100 (not brackets-after-id))
1101 'font-lock-function-name-face 1024 'font-lock-function-name-face
1102 'font-lock-variable-name-face) 1025 'font-lock-variable-name-face)
1103 got-init (and (match-beginning 1) 1026 got-init (and (cadr (cddr decl-res)) ; got-init
1104 (char-after (match-beginning 1)))) 1027 (char-after)))
1105 1028
1106 (if types 1029 (if types
1107 ;; Register and fontify the identifier as a type. 1030 ;; Register and fontify the identifier as a type.
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index 7f13ed5b06d..f5a784bf63d 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -228,7 +228,7 @@ This function is controlled by the settings of reftex-insert-label-flags."
228 (symbol-value reftex-docstruct-symbol))) 228 (symbol-value reftex-docstruct-symbol)))
229 (ding) 229 (ding)
230 (if (y-or-n-p 230 (if (y-or-n-p
231` (format-message "Label `%s' exists. Use anyway? " label)) 231 (format-message "Label `%s' exists. Use anyway? " label))
232 (setq valid t))) 232 (setq valid t)))
233 233
234 ;; Label is ok 234 ;; Label is ok
diff --git a/src/buffer.c b/src/buffer.c
index 51bbad78bbc..0c52eaf41ba 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -42,10 +42,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#include "blockinput.h" 42#include "blockinput.h"
43#include "keymap.h" 43#include "keymap.h"
44#include "frame.h" 44#include "frame.h"
45#include "xwidget.h"
45 46
46#ifdef HAVE_XWIDGETS
47# include "xwidget.h"
48#endif
49#ifdef WINDOWSNT 47#ifdef WINDOWSNT
50#include "w32heap.h" /* for mmap_* */ 48#include "w32heap.h" /* for mmap_* */
51#endif 49#endif
@@ -1749,10 +1747,8 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1749 unlock_buffer (b); 1747 unlock_buffer (b);
1750 1748
1751 kill_buffer_processes (buffer); 1749 kill_buffer_processes (buffer);
1752
1753#ifdef HAVE_XWIDGETS
1754 kill_buffer_xwidgets (buffer); 1750 kill_buffer_xwidgets (buffer);
1755#endif 1751
1756 /* Killing buffer processes may run sentinels which may have killed 1752 /* Killing buffer processes may run sentinels which may have killed
1757 our buffer. */ 1753 our buffer. */
1758 if (!BUFFER_LIVE_P (b)) 1754 if (!BUFFER_LIVE_P (b))
diff --git a/src/dispextern.h b/src/dispextern.h
index fad5bfd6f2f..7d7d7305b43 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -347,11 +347,10 @@ enum glyph_type
347 IMAGE_GLYPH, 347 IMAGE_GLYPH,
348 348
349 /* Glyph is a space of fractional width and/or height. */ 349 /* Glyph is a space of fractional width and/or height. */
350 STRETCH_GLYPH 350 STRETCH_GLYPH,
351#ifdef HAVE_XWIDGETS 351
352 /* Glyph is an external widget drawn by the GUI toolkit. */ 352 /* Glyph is an external widget drawn by the GUI toolkit. */
353 ,XWIDGET_GLYPH 353 XWIDGET_GLYPH
354#endif
355}; 354};
356 355
357 356
@@ -504,8 +503,10 @@ struct glyph
504 int img_id; 503 int img_id;
505 504
506#ifdef HAVE_XWIDGETS 505#ifdef HAVE_XWIDGETS
506 /* Xwidget reference (type == XWIDGET_GLYPH). */
507 struct xwidget *xwidget; 507 struct xwidget *xwidget;
508#endif 508#endif
509
509 /* Sub-structure for type == STRETCH_GLYPH. */ 510 /* Sub-structure for type == STRETCH_GLYPH. */
510 struct 511 struct
511 { 512 {
@@ -1357,9 +1358,9 @@ struct glyph_string
1357 /* Image, if any. */ 1358 /* Image, if any. */
1358 struct image *img; 1359 struct image *img;
1359 1360
1360#ifdef HAVE_XWIDGETS 1361 /* Xwidget. */
1361 struct xwidget *xwidget; 1362 struct xwidget *xwidget;
1362#endif 1363
1363 /* Slice */ 1364 /* Slice */
1364 struct glyph_slice slice; 1365 struct glyph_slice slice;
1365 1366
@@ -2111,11 +2112,10 @@ enum display_element_type
2111 IT_TRUNCATION, 2112 IT_TRUNCATION,
2112 2113
2113 /* Continuation glyphs. See the comment for IT_TRUNCATION. */ 2114 /* Continuation glyphs. See the comment for IT_TRUNCATION. */
2114 IT_CONTINUATION 2115 IT_CONTINUATION,
2115 2116
2116#ifdef HAVE_XWIDGETS 2117 /* Xwidget. */
2117 ,IT_XWIDGET 2118 IT_XWIDGET
2118#endif
2119}; 2119};
2120 2120
2121 2121
@@ -2179,9 +2179,7 @@ enum it_method {
2179 GET_FROM_C_STRING, 2179 GET_FROM_C_STRING,
2180 GET_FROM_IMAGE, 2180 GET_FROM_IMAGE,
2181 GET_FROM_STRETCH, 2181 GET_FROM_STRETCH,
2182#ifdef HAVE_XWIDGETS
2183 GET_FROM_XWIDGET, 2182 GET_FROM_XWIDGET,
2184#endif
2185 NUM_IT_METHODS 2183 NUM_IT_METHODS
2186}; 2184};
2187 2185
@@ -2399,12 +2397,10 @@ struct it
2399 struct { 2397 struct {
2400 Lisp_Object object; 2398 Lisp_Object object;
2401 } stretch; 2399 } stretch;
2402#ifdef HAVE_XWIDGETS
2403 /* method == GET_FROM_XWIDGET */ 2400 /* method == GET_FROM_XWIDGET */
2404 struct { 2401 struct {
2405 Lisp_Object object; 2402 Lisp_Object object;
2406 } xwidget; 2403 } xwidget;
2407#endif
2408 } u; 2404 } u;
2409 2405
2410 /* Current text and display positions. */ 2406 /* Current text and display positions. */
@@ -2529,10 +2525,8 @@ struct it
2529 /* If what == IT_IMAGE, the id of the image to display. */ 2525 /* If what == IT_IMAGE, the id of the image to display. */
2530 ptrdiff_t image_id; 2526 ptrdiff_t image_id;
2531 2527
2532#ifdef HAVE_XWIDGETS
2533 /* If what == IT_XWIDGET. */ 2528 /* If what == IT_XWIDGET. */
2534 struct xwidget *xwidget; 2529 struct xwidget *xwidget;
2535#endif
2536 2530
2537 /* Values from `slice' property. */ 2531 /* Values from `slice' property. */
2538 struct it_slice slice; 2532 struct it_slice slice;
diff --git a/src/dispnew.c b/src/dispnew.c
index 32c0dff9b92..fe07f793cb5 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -39,15 +39,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include "syssignal.h" 39#include "syssignal.h"
40#include "systime.h" 40#include "systime.h"
41#include "tparam.h" 41#include "tparam.h"
42#include "xwidget.h"
42 43
43#ifdef HAVE_WINDOW_SYSTEM 44#ifdef HAVE_WINDOW_SYSTEM
44#include TERM_HEADER 45#include TERM_HEADER
45#endif /* HAVE_WINDOW_SYSTEM */ 46#endif /* HAVE_WINDOW_SYSTEM */
46 47
47#ifdef HAVE_XWIDGETS
48# include "xwidget.h"
49#endif
50
51#include <errno.h> 48#include <errno.h>
52 49
53#include <fpending.h> 50#include <fpending.h>
@@ -3547,9 +3544,7 @@ update_window (struct window *w, bool force_p)
3547 add_window_display_history (w, w->current_matrix->method, paused_p); 3544 add_window_display_history (w, w->current_matrix->method, paused_p);
3548#endif 3545#endif
3549 3546
3550#ifdef HAVE_XWIDGETS
3551 xwidget_end_redisplay (w, w->current_matrix); 3547 xwidget_end_redisplay (w, w->current_matrix);
3552#endif
3553 clear_glyph_matrix (desired_matrix); 3548 clear_glyph_matrix (desired_matrix);
3554 3549
3555 return paused_p; 3550 return paused_p;
diff --git a/src/emacs.c b/src/emacs.c
index fcf048ca84b..f661196313f 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -65,10 +65,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
65#include "character.h" 65#include "character.h"
66#include "buffer.h" 66#include "buffer.h"
67#include "window.h" 67#include "window.h"
68 68#include "xwidget.h"
69#ifdef HAVE_XWIDGETS
70# include "xwidget.h"
71#endif
72#include "atimer.h" 69#include "atimer.h"
73#include "blockinput.h" 70#include "blockinput.h"
74#include "syssignal.h" 71#include "syssignal.h"
@@ -1495,9 +1492,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
1495 syms_of_xfns (); 1492 syms_of_xfns ();
1496 syms_of_xmenu (); 1493 syms_of_xmenu ();
1497 syms_of_fontset (); 1494 syms_of_fontset ();
1498#ifdef HAVE_XWIDGETS
1499 syms_of_xwidget (); 1495 syms_of_xwidget ();
1500#endif
1501 syms_of_xsettings (); 1496 syms_of_xsettings ();
1502#ifdef HAVE_X_SM 1497#ifdef HAVE_X_SM
1503 syms_of_xsmfns (); 1498 syms_of_xsmfns ();
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 08b840389c5..6795155831e 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -23,9 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23#include "lisp.h" 23#include "lisp.h"
24#include "frame.h" 24#include "frame.h"
25#include "xterm.h" 25#include "xterm.h"
26#ifdef HAVE_XWIDGETS 26#include "xwidget.h"
27# include "xwidget.h"
28#endif
29#include "emacsgtkfixed.h" 27#include "emacsgtkfixed.h"
30 28
31/* Silence a bogus diagnostic; see GNOME bug 683906. */ 29/* Silence a bogus diagnostic; see GNOME bug 683906. */
@@ -50,7 +48,6 @@ static void emacs_fixed_get_preferred_width (GtkWidget *widget,
50static void emacs_fixed_get_preferred_height (GtkWidget *widget, 48static void emacs_fixed_get_preferred_height (GtkWidget *widget,
51 gint *minimum, 49 gint *minimum,
52 gint *natural); 50 gint *natural);
53
54static GType emacs_fixed_get_type (void); 51static GType emacs_fixed_get_type (void);
55G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED) 52G_DEFINE_TYPE (EmacsFixed, emacs_fixed, GTK_TYPE_FIXED)
56 53
@@ -75,28 +72,28 @@ struct GtkFixedPrivateL
75 GList *children; 72 GList *children;
76}; 73};
77 74
78static void emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget, 75static void
79 GtkAllocation *allocation) 76emacs_fixed_gtk_widget_size_allocate (GtkWidget *widget,
77 GtkAllocation *allocation)
80{ 78{
81 // For xwidgets. 79 /* For xwidgets.
82 80
83 // This basically re-implements the base class method and adds an 81 This basically re-implements the base class method and adds an
84 // additional case for an xwidget view. 82 additional case for an xwidget view.
85 83
86 // It would be nicer if the bse class method could be called first, 84 It would be nicer if the bse class method could be called first,
87 // and the the xview modification only would remain here. It wasn't 85 and the the xview modification only would remain here. It wasn't
88 // possible to solve it that way yet. 86 possible to solve it that way yet. */
89 EmacsFixedClass *klass; 87 EmacsFixedClass *klass;
90 GtkWidgetClass *parent_class; 88 GtkWidgetClass *parent_class;
91 struct GtkFixedPrivateL* priv; 89 struct GtkFixedPrivateL *priv;
92 90
93 klass = EMACS_FIXED_GET_CLASS (widget); 91 klass = EMACS_FIXED_GET_CLASS (widget);
94 parent_class = g_type_class_peek_parent (klass); 92 parent_class = g_type_class_peek_parent (klass);
95 parent_class->size_allocate (widget, allocation); 93 parent_class->size_allocate (widget, allocation);
96 94
97 priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, 95 priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, GTK_TYPE_FIXED,
98 GTK_TYPE_FIXED, 96 struct GtkFixedPrivateL);
99 struct GtkFixedPrivateL);
100 97
101 gtk_widget_set_allocation (widget, allocation); 98 gtk_widget_set_allocation (widget, allocation);
102 99
@@ -154,7 +151,6 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
154 151
155 widget_class = (GtkWidgetClass*) klass; 152 widget_class = (GtkWidgetClass*) klass;
156 153
157
158 widget_class->get_preferred_width = emacs_fixed_get_preferred_width; 154 widget_class->get_preferred_width = emacs_fixed_get_preferred_width;
159 widget_class->get_preferred_height = emacs_fixed_get_preferred_height; 155 widget_class->get_preferred_height = emacs_fixed_get_preferred_height;
160#ifdef HAVE_XWIDGETS 156#ifdef HAVE_XWIDGETS
@@ -163,7 +159,6 @@ emacs_fixed_class_init (EmacsFixedClass *klass)
163 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate)); 159 g_type_class_add_private (klass, sizeof (EmacsFixedPrivate));
164} 160}
165 161
166
167static void 162static void
168emacs_fixed_init (EmacsFixed *fixed) 163emacs_fixed_init (EmacsFixed *fixed)
169{ 164{
@@ -172,14 +167,7 @@ emacs_fixed_init (EmacsFixed *fixed)
172 fixed->priv->f = 0; 167 fixed->priv->f = 0;
173} 168}
174 169
175/** 170GtkWidget *
176 * emacs_fixed_new:
177 *
178 * Creates a new #EmacsFixed.
179 *
180 * Returns: a new #EmacsFixed.
181 */
182GtkWidget*
183emacs_fixed_new (struct frame *f) 171emacs_fixed_new (struct frame *f)
184{ 172{
185 EmacsFixed *fixed = g_object_new (emacs_fixed_get_type (), NULL); 173 EmacsFixed *fixed = g_object_new (emacs_fixed_get_type (), NULL);
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h
index 378bd2b828c..72652c53104 100644
--- a/src/emacsgtkfixed.h
+++ b/src/emacsgtkfixed.h
@@ -29,7 +29,6 @@ G_BEGIN_DECLS
29 29
30struct frame; 30struct frame;
31 31
32//typedef struct _EmacsFixed EmacsFixed;
33typedef struct _EmacsFixedPrivate EmacsFixedPrivate; 32typedef struct _EmacsFixedPrivate EmacsFixedPrivate;
34typedef struct _EmacsFixedClass EmacsFixedClass; 33typedef struct _EmacsFixedClass EmacsFixedClass;
35 34
@@ -41,7 +40,6 @@ struct _EmacsFixed
41 EmacsFixedPrivate *priv; 40 EmacsFixedPrivate *priv;
42}; 41};
43 42
44
45struct _EmacsFixedClass 43struct _EmacsFixedClass
46{ 44{
47 GtkFixedClass parent_class; 45 GtkFixedClass parent_class;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 768df342983..14b76ce67ae 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -4084,20 +4084,28 @@ xg_page_setup_dialog (void)
4084Lisp_Object 4084Lisp_Object
4085xg_get_page_setup (void) 4085xg_get_page_setup (void)
4086{ 4086{
4087 GtkPageOrientation orientation;
4088 Lisp_Object orientation_symbol; 4087 Lisp_Object orientation_symbol;
4089 4088
4090 if (page_setup == NULL) 4089 if (page_setup == NULL)
4091 page_setup = gtk_page_setup_new (); 4090 page_setup = gtk_page_setup_new ();
4092 orientation = gtk_page_setup_get_orientation (page_setup); 4091
4093 if (orientation == GTK_PAGE_ORIENTATION_PORTRAIT) 4092 switch (gtk_page_setup_get_orientation (page_setup))
4094 orientation_symbol = Qportrait; 4093 {
4095 else if (orientation == GTK_PAGE_ORIENTATION_LANDSCAPE) 4094 case GTK_PAGE_ORIENTATION_PORTRAIT:
4096 orientation_symbol = Qlandscape; 4095 orientation_symbol = Qportrait;
4097 else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT) 4096 break;
4098 orientation_symbol = Qreverse_portrait; 4097 case GTK_PAGE_ORIENTATION_LANDSCAPE:
4099 else if (orientation == GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE) 4098 orientation_symbol = Qlandscape;
4100 orientation_symbol = Qreverse_landscape; 4099 break;
4100 case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
4101 orientation_symbol = Qreverse_portrait;
4102 break;
4103 case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
4104 orientation_symbol = Qreverse_landscape;
4105 break;
4106 default:
4107 eassume (false);
4108 }
4101 4109
4102 return listn (CONSTYPE_HEAP, 7, 4110 return listn (CONSTYPE_HEAP, 7,
4103 Fcons (Qorientation, orientation_symbol), 4111 Fcons (Qorientation, orientation_symbol),
diff --git a/src/image.c b/src/image.c
index 8bb5ff77b22..144fe30a746 100644
--- a/src/image.c
+++ b/src/image.c
@@ -57,8 +57,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
57#endif /* HAVE_WINDOW_SYSTEM */ 57#endif /* HAVE_WINDOW_SYSTEM */
58 58
59#ifdef HAVE_X_WINDOWS 59#ifdef HAVE_X_WINDOWS
60#define COLOR_TABLE_SUPPORT 1
61
62typedef struct x_bitmap_record Bitmap_Record; 60typedef struct x_bitmap_record Bitmap_Record;
63#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) 61#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
64#define NO_PIXMAP None 62#define NO_PIXMAP None
@@ -74,9 +72,6 @@ typedef struct x_bitmap_record Bitmap_Record;
74# include "w32.h" 72# include "w32.h"
75#endif 73#endif
76 74
77/* W32_TODO : Color tables on W32. */
78#undef COLOR_TABLE_SUPPORT
79
80typedef struct w32_bitmap_record Bitmap_Record; 75typedef struct w32_bitmap_record Bitmap_Record;
81#define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y) 76#define GET_PIXEL(ximg, x, y) GetPixel (ximg, x, y)
82#define NO_PIXMAP 0 77#define NO_PIXMAP 0
@@ -89,13 +84,7 @@ typedef struct w32_bitmap_record Bitmap_Record;
89 84
90#endif /* HAVE_NTGUI */ 85#endif /* HAVE_NTGUI */
91 86
92#ifdef USE_CAIRO
93#undef COLOR_TABLE_SUPPORT
94#endif
95
96#ifdef HAVE_NS 87#ifdef HAVE_NS
97#undef COLOR_TABLE_SUPPORT
98
99typedef struct ns_bitmap_record Bitmap_Record; 88typedef struct ns_bitmap_record Bitmap_Record;
100 89
101#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y) 90#define GET_PIXEL(ximg, x, y) XGetPixel (ximg, x, y)
@@ -109,6 +98,12 @@ typedef struct ns_bitmap_record Bitmap_Record;
109#define DefaultDepthOfScreen(screen) x_display_list->n_planes 98#define DefaultDepthOfScreen(screen) x_display_list->n_planes
110#endif /* HAVE_NS */ 99#endif /* HAVE_NS */
111 100
101#if (defined HAVE_X_WINDOWS \
102 && ! (defined HAVE_NTGUI || defined USE_CAIRO || defined HAVE_NS))
103/* W32_TODO : Color tables on W32. */
104# define COLOR_TABLE_SUPPORT 1
105#endif
106
112static void x_disable_image (struct frame *, struct image *); 107static void x_disable_image (struct frame *, struct image *);
113static void x_edge_detection (struct frame *, struct image *, Lisp_Object, 108static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
114 Lisp_Object); 109 Lisp_Object);
@@ -4615,16 +4610,14 @@ colors_in_color_table (int *n)
4615static unsigned long 4610static unsigned long
4616lookup_rgb_color (struct frame *f, int r, int g, int b) 4611lookup_rgb_color (struct frame *f, int r, int g, int b)
4617{ 4612{
4618 unsigned long pixel;
4619
4620#ifdef HAVE_NTGUI 4613#ifdef HAVE_NTGUI
4621 pixel = PALETTERGB (r >> 8, g >> 8, b >> 8); 4614 return PALETTERGB (r >> 8, g >> 8, b >> 8);
4622#endif /* HAVE_NTGUI */ 4615#elif defined HAVE_NS
4623 4616 return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8);
4624#ifdef HAVE_NS 4617#else
4625 pixel = RGB_TO_ULONG (r >> 8, g >> 8, b >> 8); 4618 xsignal1 (Qfile_error,
4626#endif /* HAVE_NS */ 4619 build_string ("This Emacs mishandles this image file type"));
4627 return pixel; 4620#endif
4628} 4621}
4629 4622
4630static void 4623static void
@@ -7320,7 +7313,6 @@ tiff_load (struct frame *f, struct image *img)
7320 { 7313 {
7321 unsigned char *data = (unsigned char *) xmalloc (width*height*4); 7314 unsigned char *data = (unsigned char *) xmalloc (width*height*4);
7322 uint32_t *dataptr = (uint32_t *) data; 7315 uint32_t *dataptr = (uint32_t *) data;
7323 int r, g, b, a;
7324 7316
7325 for (y = 0; y < height; ++y) 7317 for (y = 0; y < height; ++y)
7326 { 7318 {
@@ -7634,19 +7626,19 @@ gif_load (struct frame *f, struct image *img)
7634{ 7626{
7635 int rc, width, height, x, y, i, j; 7627 int rc, width, height, x, y, i, j;
7636 ColorMapObject *gif_color_map; 7628 ColorMapObject *gif_color_map;
7637 unsigned long pixel_colors[256];
7638 GifFileType *gif; 7629 GifFileType *gif;
7639 gif_memory_source memsrc; 7630 gif_memory_source memsrc;
7640 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); 7631 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
7641 Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); 7632 Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL);
7642 Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); 7633 Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL);
7643 unsigned long bgcolor = 0;
7644 EMACS_INT idx; 7634 EMACS_INT idx;
7645 int gif_err; 7635 int gif_err;
7646 7636
7647#ifdef USE_CAIRO 7637#ifdef USE_CAIRO
7648 unsigned char *data = 0; 7638 unsigned char *data = 0;
7649#else 7639#else
7640 unsigned long pixel_colors[256];
7641 unsigned long bgcolor = 0;
7650 XImagePtr ximg; 7642 XImagePtr ximg;
7651#endif 7643#endif
7652 7644
@@ -7833,9 +7825,13 @@ gif_load (struct frame *f, struct image *img)
7833 gif_load call to construct and save all animation frames. */ 7825 gif_load call to construct and save all animation frames. */
7834 7826
7835 init_color_table (); 7827 init_color_table ();
7828
7829#ifndef USE_CAIRO
7836 if (STRINGP (specified_bg)) 7830 if (STRINGP (specified_bg))
7837 bgcolor = x_alloc_image_color (f, img, specified_bg, 7831 bgcolor = x_alloc_image_color (f, img, specified_bg,
7838 FRAME_BACKGROUND_PIXEL (f)); 7832 FRAME_BACKGROUND_PIXEL (f));
7833#endif
7834
7839 for (j = 0; j <= idx; ++j) 7835 for (j = 0; j <= idx; ++j)
7840 { 7836 {
7841 /* We use a local variable `raster' here because RasterBits is a 7837 /* We use a local variable `raster' here because RasterBits is a
@@ -9182,11 +9178,6 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9182 int height; 9178 int height;
9183 const guint8 *pixels; 9179 const guint8 *pixels;
9184 int rowstride; 9180 int rowstride;
9185 XImagePtr ximg;
9186 Lisp_Object specified_bg;
9187 XColor background;
9188 int x;
9189 int y;
9190 9181
9191#if ! GLIB_CHECK_VERSION (2, 36, 0) 9182#if ! GLIB_CHECK_VERSION (2, 36, 0)
9192 /* g_type_init is a glib function that must be called prior to 9183 /* g_type_init is a glib function that must be called prior to
@@ -9240,16 +9231,14 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9240#ifdef USE_CAIRO 9231#ifdef USE_CAIRO
9241 { 9232 {
9242 unsigned char *data = (unsigned char *) xmalloc (width*height*4); 9233 unsigned char *data = (unsigned char *) xmalloc (width*height*4);
9243 int y;
9244 uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f); 9234 uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
9245 9235
9246 for (y = 0; y < height; ++y) 9236 for (int y = 0; y < height; ++y)
9247 { 9237 {
9248 const guchar *iconptr = pixels + y * rowstride; 9238 const guchar *iconptr = pixels + y * rowstride;
9249 uint32_t *dataptr = (uint32_t *) (data + y * rowstride); 9239 uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
9250 int x;
9251 9240
9252 for (x = 0; x < width; ++x) 9241 for (int x = 0; x < width; ++x)
9253 { 9242 {
9254 if (iconptr[3] == 0) 9243 if (iconptr[3] == 0)
9255 *dataptr = bgcolor; 9244 *dataptr = bgcolor;
@@ -9269,6 +9258,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9269 } 9258 }
9270#else 9259#else
9271 /* Try to create a x pixmap to hold the svg pixmap. */ 9260 /* Try to create a x pixmap to hold the svg pixmap. */
9261 XImagePtr ximg;
9272 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 9262 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
9273 { 9263 {
9274 g_object_unref (pixbuf); 9264 g_object_unref (pixbuf);
@@ -9279,7 +9269,8 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9279 9269
9280 /* Handle alpha channel by combining the image with a background 9270 /* Handle alpha channel by combining the image with a background
9281 color. */ 9271 color. */
9282 specified_bg = image_spec_value (img->spec, QCbackground, NULL); 9272 XColor background;
9273 Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
9283 if (!STRINGP (specified_bg) 9274 if (!STRINGP (specified_bg)
9284 || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) 9275 || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
9285 x_query_frame_background_color (f, &background); 9276 x_query_frame_background_color (f, &background);
@@ -9295,9 +9286,9 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9295 non-transparent images. Each pixel must be "flattened" by 9286 non-transparent images. Each pixel must be "flattened" by
9296 calculating the resulting color, given the transparency of the 9287 calculating the resulting color, given the transparency of the
9297 pixel, and the image background color. */ 9288 pixel, and the image background color. */
9298 for (y = 0; y < height; ++y) 9289 for (int y = 0; y < height; ++y)
9299 { 9290 {
9300 for (x = 0; x < width; ++x) 9291 for (int x = 0; x < width; ++x)
9301 { 9292 {
9302 int red; 9293 int red;
9303 int green; 9294 int green;
@@ -9597,8 +9588,6 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9597 0, 0, img->width, img->height, ~0, ZPixmap); 9588 0, 0, img->width, img->height, ~0, ZPixmap);
9598 if (ximg) 9589 if (ximg)
9599 { 9590 {
9600 int x, y;
9601
9602 /* Initialize the color table. */ 9591 /* Initialize the color table. */
9603 init_color_table (); 9592 init_color_table ();
9604 9593
@@ -9606,8 +9595,8 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9606 color table. After having done so, the color table will 9595 color table. After having done so, the color table will
9607 contain an entry for each color used by the image. */ 9596 contain an entry for each color used by the image. */
9608#ifdef COLOR_TABLE_SUPPORT 9597#ifdef COLOR_TABLE_SUPPORT
9609 for (y = 0; y < img->height; ++y) 9598 for (int y = 0; y < img->height; ++y)
9610 for (x = 0; x < img->width; ++x) 9599 for (int x = 0; x < img->width; ++x)
9611 { 9600 {
9612 unsigned long pixel = XGetPixel (ximg, x, y); 9601 unsigned long pixel = XGetPixel (ximg, x, y);
9613 9602
diff --git a/src/keyboard.c b/src/keyboard.c
index fe503b8ce56..b26cee24673 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5960,7 +5960,7 @@ make_lispy_event (struct input_event *event)
5960#ifdef HAVE_XWIDGETS 5960#ifdef HAVE_XWIDGETS
5961 case XWIDGET_EVENT: 5961 case XWIDGET_EVENT:
5962 { 5962 {
5963 return Fcons (Qxwidget_event,event->arg); 5963 return Fcons (Qxwidget_event, event->arg);
5964 } 5964 }
5965#endif 5965#endif
5966 5966
@@ -10971,7 +10971,7 @@ syms_of_keyboard (void)
10971#endif 10971#endif
10972 10972
10973#ifdef HAVE_XWIDGETS 10973#ifdef HAVE_XWIDGETS
10974 DEFSYM (Qxwidget_event,"xwidget-event"); 10974 DEFSYM (Qxwidget_event, "xwidget-event");
10975#endif 10975#endif
10976 10976
10977#ifdef USE_FILE_NOTIFY 10977#ifdef USE_FILE_NOTIFY
diff --git a/src/lisp.h b/src/lisp.h
index 8aa034e9e57..ee055e90699 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -799,11 +799,8 @@ enum pvec_type
799 PVEC_WINDOW_CONFIGURATION, 799 PVEC_WINDOW_CONFIGURATION,
800 PVEC_SUBR, 800 PVEC_SUBR,
801 PVEC_OTHER, 801 PVEC_OTHER,
802
803#ifdef HAVE_XWIDGETS
804 PVEC_XWIDGET, 802 PVEC_XWIDGET,
805 PVEC_XWIDGET_VIEW, 803 PVEC_XWIDGET_VIEW,
806#endif
807 804
808 /* These should be last, check internal_equal to see why. */ 805 /* These should be last, check internal_equal to see why. */
809 PVEC_COMPILED, 806 PVEC_COMPILED,
diff --git a/src/print.c b/src/print.c
index 4dd4e963093..2ecc0f52b47 100644
--- a/src/print.c
+++ b/src/print.c
@@ -32,10 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include "disptab.h" 32#include "disptab.h"
33#include "intervals.h" 33#include "intervals.h"
34#include "blockinput.h" 34#include "blockinput.h"
35 35#include "xwidget.h"
36#ifdef HAVE_XWIDGETS
37# include "xwidget.h"
38#endif
39 36
40#include <c-ctype.h> 37#include <c-ctype.h>
41#include <float.h> 38#include <float.h>
@@ -1740,18 +1737,11 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1740 print_c_string (XSUBR (obj)->symbol_name, printcharfun); 1737 print_c_string (XSUBR (obj)->symbol_name, printcharfun);
1741 printchar ('>', printcharfun); 1738 printchar ('>', printcharfun);
1742 } 1739 }
1743#ifdef HAVE_XWIDGETS 1740 else if (XWIDGETP (obj) || XWIDGET_VIEW_P (obj))
1744 else if (XWIDGETP (obj))
1745 { 1741 {
1746 print_c_string ("#<xwidget ", printcharfun); 1742 print_c_string ("#<xwidget ", printcharfun);
1747 printchar ('>', printcharfun); 1743 printchar ('>', printcharfun);
1748 } 1744 }
1749 else if (XWIDGET_VIEW_P (obj))
1750 {
1751 print_c_string ("#<xwidget ", printcharfun);
1752 printchar ('>', printcharfun);
1753 }
1754#endif
1755 else if (WINDOWP (obj)) 1745 else if (WINDOWP (obj))
1756 { 1746 {
1757 int len = sprintf (buf, "#<window %"pI"d", 1747 int len = sprintf (buf, "#<window %"pI"d",
diff --git a/src/sysdep.c b/src/sysdep.c
index a86b53642f2..19a7212f7e2 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -100,6 +100,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
100#include "cm.h" 100#include "cm.h"
101 101
102#include "gnutls.h" 102#include "gnutls.h"
103/* MS-Windows loads GnuTLS at run time, if available; we don't want to
104 do that during startup just to call gnutls_rnd. */
103#if 0x020c00 <= GNUTLS_VERSION_NUMBER && !defined WINDOWSNT 105#if 0x020c00 <= GNUTLS_VERSION_NUMBER && !defined WINDOWSNT
104# include <gnutls/crypto.h> 106# include <gnutls/crypto.h>
105#else 107#else
diff --git a/src/window.c b/src/window.c
index add2de38d18..70b7e58feb5 100644
--- a/src/window.c
+++ b/src/window.c
@@ -35,15 +35,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
35#include "dispextern.h" 35#include "dispextern.h"
36#include "blockinput.h" 36#include "blockinput.h"
37#include "termhooks.h" /* For FRAME_TERMINAL. */ 37#include "termhooks.h" /* For FRAME_TERMINAL. */
38#include "xwidget.h"
38#ifdef HAVE_WINDOW_SYSTEM 39#ifdef HAVE_WINDOW_SYSTEM
39#include TERM_HEADER 40#include TERM_HEADER
40#endif /* HAVE_WINDOW_SYSTEM */ 41#endif /* HAVE_WINDOW_SYSTEM */
41#ifdef MSDOS 42#ifdef MSDOS
42#include "msdos.h" 43#include "msdos.h"
43#endif 44#endif
44#ifdef HAVE_XWIDGETS
45# include "xwidget.h"
46#endif
47 45
48static ptrdiff_t count_windows (struct window *); 46static ptrdiff_t count_windows (struct window *);
49static ptrdiff_t get_leaf_windows (struct window *, struct window **, 47static ptrdiff_t get_leaf_windows (struct window *, struct window **,
@@ -4371,9 +4369,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4371 4369
4372 /* Block input. */ 4370 /* Block input. */
4373 block_input (); 4371 block_input ();
4374#ifdef HAVE_XWIDGETS
4375 xwidget_view_delete_all_in_window (w); 4372 xwidget_view_delete_all_in_window (w);
4376#endif
4377 window_resize_apply (p, horflag); 4373 window_resize_apply (p, horflag);
4378 /* If this window is referred to by the dpyinfo's mouse 4374 /* If this window is referred to by the dpyinfo's mouse
4379 highlight, invalidate that slot to be safe (Bug#9904). */ 4375 highlight, invalidate that slot to be safe (Bug#9904). */
diff --git a/src/xdisp.c b/src/xdisp.c
index 89385c0e172..5185e777324 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -314,13 +314,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
314#include "font.h" 314#include "font.h"
315#include "fontset.h" 315#include "fontset.h"
316#include "blockinput.h" 316#include "blockinput.h"
317#include "xwidget.h"
317#ifdef HAVE_WINDOW_SYSTEM 318#ifdef HAVE_WINDOW_SYSTEM
318#include TERM_HEADER 319#include TERM_HEADER
319#endif /* HAVE_WINDOW_SYSTEM */ 320#endif /* HAVE_WINDOW_SYSTEM */
320 321
321#ifdef HAVE_XWIDGETS
322# include "xwidget.h"
323#endif
324#ifndef FRAME_X_OUTPUT 322#ifndef FRAME_X_OUTPUT
325#define FRAME_X_OUTPUT(f) ((f)->output_data.x) 323#define FRAME_X_OUTPUT(f) ((f)->output_data.x)
326#endif 324#endif
@@ -857,9 +855,7 @@ static bool next_element_from_buffer (struct it *);
857static bool next_element_from_composition (struct it *); 855static bool next_element_from_composition (struct it *);
858static bool next_element_from_image (struct it *); 856static bool next_element_from_image (struct it *);
859static bool next_element_from_stretch (struct it *); 857static bool next_element_from_stretch (struct it *);
860#ifdef HAVE_XWIDGETS
861static bool next_element_from_xwidget (struct it *); 858static bool next_element_from_xwidget (struct it *);
862#endif
863static void load_overlay_strings (struct it *, ptrdiff_t); 859static void load_overlay_strings (struct it *, ptrdiff_t);
864static bool get_next_display_element (struct it *); 860static bool get_next_display_element (struct it *);
865static enum move_it_result 861static enum move_it_result
@@ -5147,11 +5143,8 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5147 && valid_image_p (value)) 5143 && valid_image_p (value))
5148#endif /* not HAVE_WINDOW_SYSTEM */ 5144#endif /* not HAVE_WINDOW_SYSTEM */
5149 || (CONSP (value) && EQ (XCAR (value), Qspace)) 5145 || (CONSP (value) && EQ (XCAR (value), Qspace))
5150#ifdef HAVE_XWIDGETS
5151 || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p) 5146 || ((it ? FRAME_WINDOW_P (it->f) : frame_window_p)
5152 && valid_xwidget_spec_p (value)) 5147 && valid_xwidget_spec_p (value)));
5153#endif
5154 );
5155 5148
5156 if (valid_p && display_replaced == 0) 5149 if (valid_p && display_replaced == 0)
5157 { 5150 {
@@ -5226,17 +5219,15 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5226 *position = it->position = start_pos; 5219 *position = it->position = start_pos;
5227 retval = 1 + (it->area == TEXT_AREA); 5220 retval = 1 + (it->area == TEXT_AREA);
5228 } 5221 }
5229#ifdef HAVE_XWIDGETS 5222 else if (valid_xwidget_spec_p (value))
5230 else if (valid_xwidget_spec_p(value))
5231 { 5223 {
5232 it->what = IT_XWIDGET; 5224 it->what = IT_XWIDGET;
5233 it->method = GET_FROM_XWIDGET; 5225 it->method = GET_FROM_XWIDGET;
5234 it->position = start_pos; 5226 it->position = start_pos;
5235 it->object = NILP (object) ? it->w->contents : object; 5227 it->object = NILP (object) ? it->w->contents : object;
5236 *position = start_pos; 5228 *position = start_pos;
5237 it->xwidget = lookup_xwidget(value); 5229 it->xwidget = lookup_xwidget (value);
5238 } 5230 }
5239#endif
5240#ifdef HAVE_WINDOW_SYSTEM 5231#ifdef HAVE_WINDOW_SYSTEM
5241 else 5232 else
5242 { 5233 {
@@ -5989,11 +5980,9 @@ push_it (struct it *it, struct text_pos *position)
5989 case GET_FROM_STRETCH: 5980 case GET_FROM_STRETCH:
5990 p->u.stretch.object = it->object; 5981 p->u.stretch.object = it->object;
5991 break; 5982 break;
5992#ifdef HAVE_XWIDGETS
5993 case GET_FROM_XWIDGET: 5983 case GET_FROM_XWIDGET:
5994 p->u.xwidget.object = it->object; 5984 p->u.xwidget.object = it->object;
5995 break; 5985 break;
5996#endif
5997 case GET_FROM_BUFFER: 5986 case GET_FROM_BUFFER:
5998 case GET_FROM_DISPLAY_VECTOR: 5987 case GET_FROM_DISPLAY_VECTOR:
5999 case GET_FROM_STRING: 5988 case GET_FROM_STRING:
@@ -6095,11 +6084,9 @@ pop_it (struct it *it)
6095 it->object = p->u.image.object; 6084 it->object = p->u.image.object;
6096 it->slice = p->u.image.slice; 6085 it->slice = p->u.image.slice;
6097 break; 6086 break;
6098#ifdef HAVE_XWIDGETS
6099 case GET_FROM_XWIDGET: 6087 case GET_FROM_XWIDGET:
6100 it->object = p->u.xwidget.object; 6088 it->object = p->u.xwidget.object;
6101 break; 6089 break;
6102#endif
6103 case GET_FROM_STRETCH: 6090 case GET_FROM_STRETCH:
6104 it->object = p->u.stretch.object; 6091 it->object = p->u.stretch.object;
6105 break; 6092 break;
@@ -6775,9 +6762,7 @@ static next_element_function const get_next_element[NUM_IT_METHODS] =
6775 next_element_from_c_string, 6762 next_element_from_c_string,
6776 next_element_from_image, 6763 next_element_from_image,
6777 next_element_from_stretch, 6764 next_element_from_stretch,
6778#ifdef HAVE_XWIDGETS
6779 next_element_from_xwidget, 6765 next_element_from_xwidget,
6780#endif
6781}; 6766};
6782 6767
6783#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it) 6768#define GET_NEXT_DISPLAY_ELEMENT(it) (*get_next_element[(it)->method]) (it)
@@ -7638,9 +7623,7 @@ set_iterator_to_next (struct it *it, bool reseat_p)
7638 7623
7639 case GET_FROM_IMAGE: 7624 case GET_FROM_IMAGE:
7640 case GET_FROM_STRETCH: 7625 case GET_FROM_STRETCH:
7641#ifdef HAVE_XWIDGETS
7642 case GET_FROM_XWIDGET: 7626 case GET_FROM_XWIDGET:
7643#endif
7644 7627
7645 /* The position etc with which we have to proceed are on 7628 /* The position etc with which we have to proceed are on
7646 the stack. The position may be at the end of a string, 7629 the stack. The position may be at the end of a string,
@@ -8103,14 +8086,12 @@ next_element_from_image (struct it *it)
8103 return true; 8086 return true;
8104} 8087}
8105 8088
8106#ifdef HAVE_XWIDGETS
8107static bool 8089static bool
8108next_element_from_xwidget (struct it *it) 8090next_element_from_xwidget (struct it *it)
8109{ 8091{
8110 it->what = IT_XWIDGET; 8092 it->what = IT_XWIDGET;
8111 return true; 8093 return true;
8112} 8094}
8113#endif
8114 8095
8115 8096
8116/* Fill iterator IT with next display element from a stretch glyph 8097/* Fill iterator IT with next display element from a stretch glyph
@@ -18844,9 +18825,11 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18844 glyph->left_box_line_p, 18825 glyph->left_box_line_p,
18845 glyph->right_box_line_p); 18826 glyph->right_box_line_p);
18846 } 18827 }
18847#ifdef HAVE_XWIDGETS
18848 else if (glyph->type == XWIDGET_GLYPH) 18828 else if (glyph->type == XWIDGET_GLYPH)
18849 { 18829 {
18830#ifndef HAVE_XWIDGETS
18831 eassume (false);
18832#else
18850 fprintf (stderr, 18833 fprintf (stderr,
18851 " %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n", 18834 " %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
18852 glyph - row->glyphs[TEXT_AREA], 18835 glyph - row->glyphs[TEXT_AREA],
@@ -18863,9 +18846,8 @@ dump_glyph (struct glyph_row *row, struct glyph *glyph, int area)
18863 glyph->face_id, 18846 glyph->face_id,
18864 glyph->left_box_line_p, 18847 glyph->left_box_line_p,
18865 glyph->right_box_line_p); 18848 glyph->right_box_line_p);
18866
18867 }
18868#endif 18849#endif
18850 }
18869} 18851}
18870 18852
18871 18853
@@ -24364,13 +24346,11 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
24364 24346
24365 return OK_PIXELS (width_p ? img->width : img->height); 24347 return OK_PIXELS (width_p ? img->width : img->height);
24366 } 24348 }
24367# ifdef HAVE_XWIDGETS
24368 if (FRAME_WINDOW_P (it->f) && valid_xwidget_spec_p (prop)) 24349 if (FRAME_WINDOW_P (it->f) && valid_xwidget_spec_p (prop))
24369 { 24350 {
24370 // TODO: Don't return dummy size. 24351 // TODO: Don't return dummy size.
24371 return OK_PIXELS (100); 24352 return OK_PIXELS (100);
24372 } 24353 }
24373# endif
24374#endif 24354#endif
24375 if (EQ (car, Qplus) || EQ (car, Qminus)) 24355 if (EQ (car, Qplus) || EQ (car, Qminus))
24376 { 24356 {
@@ -25273,8 +25253,11 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25273 } \ 25253 } \
25274 while (false) 25254 while (false)
25275 25255
25276#ifdef HAVE_XWIDGETS 25256#ifndef HAVE_XWIDGETS
25277#define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25257# define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
25258 eassume (false)
25259#else
25260# define BUILD_XWIDGET_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
25278 do \ 25261 do \
25279 { \ 25262 { \
25280 s = alloca (sizeof *s); \ 25263 s = alloca (sizeof *s); \
@@ -25287,7 +25270,6 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25287 while (false) 25270 while (false)
25288#endif 25271#endif
25289 25272
25290
25291/* Add a glyph string for a sequence of character glyphs to the list 25273/* Add a glyph string for a sequence of character glyphs to the list
25292 of strings between HEAD and TAIL. START is the index of the first 25274 of strings between HEAD and TAIL. START is the index of the first
25293 glyph in row area AREA of glyph row ROW that is part of the new 25275 glyph in row area AREA of glyph row ROW that is part of the new
@@ -25441,13 +25423,11 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25441 HL, X, LAST_X); \ 25423 HL, X, LAST_X); \
25442 break; 25424 break;
25443 25425
25444#ifdef HAVE_XWIDGETS 25426#define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
25445# define BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
25446 case XWIDGET_GLYPH: \ 25427 case XWIDGET_GLYPH: \
25447 BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \ 25428 BUILD_XWIDGET_GLYPH_STRING (START, END, HEAD, TAIL, \
25448 HL, X, LAST_X); \ 25429 HL, X, LAST_X); \
25449 break; 25430 break;
25450#endif
25451 25431
25452#define BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25432#define BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X) \
25453 case GLYPHLESS_GLYPH: \ 25433 case GLYPHLESS_GLYPH: \
@@ -25456,7 +25436,7 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25456 break; \ 25436 break; \
25457 \ 25437 \
25458 default: \ 25438 default: \
25459 emacs_abort (); \ 25439 emacs_abort (); \
25460 } \ 25440 } \
25461 \ 25441 \
25462 if (s) \ 25442 if (s) \
@@ -25468,16 +25448,10 @@ compute_overhangs_and_x (struct glyph_string *s, int x, bool backward_p)
25468 } while (false) 25448 } while (false)
25469 25449
25470 25450
25471#ifdef HAVE_XWIDGETS 25451#define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X) \
25472# define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X) \
25473 BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25452 BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X) \
25474 BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \ 25453 BUILD_GLYPH_STRINGS_XW(START, END, HEAD, TAIL, HL, X, LAST_X) \
25475 BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X) 25454 BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
25476#else
25477# define BUILD_GLYPH_STRINGS(START, END, HEAD, TAIL, HL, X, LAST_X) \
25478 BUILD_GLYPH_STRINGS_1(START, END, HEAD, TAIL, HL, X, LAST_X) \
25479 BUILD_GLYPH_STRINGS_2(START, END, HEAD, TAIL, HL, X, LAST_X)
25480#endif
25481 25455
25482 25456
25483/* Draw glyphs between START and END in AREA of ROW on window W, 25457/* Draw glyphs between START and END in AREA of ROW on window W,
@@ -26118,10 +26092,10 @@ produce_image_glyph (struct it *it)
26118 } 26092 }
26119} 26093}
26120 26094
26121#ifdef HAVE_XWIDGETS
26122static void 26095static void
26123produce_xwidget_glyph (struct it *it) 26096produce_xwidget_glyph (struct it *it)
26124{ 26097{
26098#ifdef HAVE_XWIDGETS
26125 struct xwidget *xw; 26099 struct xwidget *xw;
26126 int glyph_ascent, crop; 26100 int glyph_ascent, crop;
26127 eassert (it->what == IT_XWIDGET); 26101 eassert (it->what == IT_XWIDGET);
@@ -26219,8 +26193,8 @@ produce_xwidget_glyph (struct it *it)
26219 else 26193 else
26220 IT_EXPAND_MATRIX_WIDTH (it, area); 26194 IT_EXPAND_MATRIX_WIDTH (it, area);
26221 } 26195 }
26222}
26223#endif 26196#endif
26197}
26224 26198
26225/* Append a stretch glyph to IT->glyph_row. OBJECT is the source 26199/* Append a stretch glyph to IT->glyph_row. OBJECT is the source
26226 of the glyph, WIDTH and HEIGHT are the width and height of the 26200 of the glyph, WIDTH and HEIGHT are the width and height of the
@@ -27631,10 +27605,8 @@ x_produce_glyphs (struct it *it)
27631 produce_image_glyph (it); 27605 produce_image_glyph (it);
27632 else if (it->what == IT_STRETCH) 27606 else if (it->what == IT_STRETCH)
27633 produce_stretch_glyph (it); 27607 produce_stretch_glyph (it);
27634#ifdef HAVE_XWIDGETS
27635 else if (it->what == IT_XWIDGET) 27608 else if (it->what == IT_XWIDGET)
27636 produce_xwidget_glyph (it); 27609 produce_xwidget_glyph (it);
27637#endif
27638 27610
27639 done: 27611 done:
27640 /* Accumulate dimensions. Note: can't assume that it->descent > 0 27612 /* Accumulate dimensions. Note: can't assume that it->descent > 0
@@ -28004,10 +27976,8 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
28004 /* Use normal cursor if not blinked off. */ 27976 /* Use normal cursor if not blinked off. */
28005 if (!w->cursor_off_p) 27977 if (!w->cursor_off_p)
28006 { 27978 {
28007#ifdef HAVE_XWIDGETS
28008 if (glyph != NULL && glyph->type == XWIDGET_GLYPH) 27979 if (glyph != NULL && glyph->type == XWIDGET_GLYPH)
28009 return NO_CURSOR; 27980 return NO_CURSOR;
28010#endif
28011 if (glyph != NULL && glyph->type == IMAGE_GLYPH) 27981 if (glyph != NULL && glyph->type == IMAGE_GLYPH)
28012 { 27982 {
28013 if (cursor_type == FILLED_BOX_CURSOR) 27983 if (cursor_type == FILLED_BOX_CURSOR)
diff --git a/src/xterm.c b/src/xterm.c
index 44eed22d2ec..1f71afd7f70 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -62,9 +62,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
62#include "composite.h" 62#include "composite.h"
63#include "frame.h" 63#include "frame.h"
64#include "dispextern.h" 64#include "dispextern.h"
65#ifdef HAVE_XWIDGETS 65#include "xwidget.h"
66# include "xwidget.h"
67#endif
68#include "fontset.h" 66#include "fontset.h"
69#include "termhooks.h" 67#include "termhooks.h"
70#include "termopts.h" 68#include "termopts.h"
@@ -1315,7 +1313,6 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
1315{ 1313{
1316 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1314 struct frame *f = XFRAME (WINDOW_FRAME (w));
1317 Display *display = FRAME_X_DISPLAY (f); 1315 Display *display = FRAME_X_DISPLAY (f);
1318 Window window = FRAME_X_WINDOW (f);
1319 GC gc = f->output_data.x->normal_gc; 1316 GC gc = f->output_data.x->normal_gc;
1320 struct face *face = p->face; 1317 struct face *face = p->face;
1321 1318
@@ -1358,6 +1355,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
1358#else /* not USE_CAIRO */ 1355#else /* not USE_CAIRO */
1359 if (p->which) 1356 if (p->which)
1360 { 1357 {
1358 Window window = FRAME_X_WINDOW (f);
1361 char *bits; 1359 char *bits;
1362 Pixmap pixmap, clipmask = (Pixmap) 0; 1360 Pixmap pixmap, clipmask = (Pixmap) 0;
1363 int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); 1361 int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
@@ -3514,11 +3512,9 @@ x_draw_glyph_string (struct glyph_string *s)
3514 x_draw_image_glyph_string (s); 3512 x_draw_image_glyph_string (s);
3515 break; 3513 break;
3516 3514
3517#ifdef HAVE_XWIDGETS
3518 case XWIDGET_GLYPH: 3515 case XWIDGET_GLYPH:
3519 x_draw_xwidget_glyph_string (s); 3516 x_draw_xwidget_glyph_string (s);
3520 break; 3517 break;
3521#endif
3522 3518
3523 case STRETCH_GLYPH: 3519 case STRETCH_GLYPH:
3524 x_draw_stretch_glyph_string (s); 3520 x_draw_stretch_glyph_string (s);
@@ -3762,7 +3758,7 @@ x_delete_glyphs (struct frame *f, register int n)
3762/* Like XClearArea, but check that WIDTH and HEIGHT are reasonable. 3758/* Like XClearArea, but check that WIDTH and HEIGHT are reasonable.
3763 If they are <= 0, this is probably an error. */ 3759 If they are <= 0, this is probably an error. */
3764 3760
3765static void 3761static ATTRIBUTE_UNUSED void
3766x_clear_area1 (Display *dpy, Window window, 3762x_clear_area1 (Display *dpy, Window window,
3767 int x, int y, int width, int height, int exposures) 3763 int x, int y, int width, int height, int exposures)
3768{ 3764{
@@ -3770,7 +3766,6 @@ x_clear_area1 (Display *dpy, Window window,
3770 XClearArea (dpy, window, x, y, width, height, exposures); 3766 XClearArea (dpy, window, x, y, width, height, exposures);
3771} 3767}
3772 3768
3773
3774void 3769void
3775x_clear_area (struct frame *f, int x, int y, int width, int height) 3770x_clear_area (struct frame *f, int x, int y, int width, int height)
3776{ 3771{
@@ -8929,10 +8924,9 @@ x_draw_bar_cursor (struct window *w, struct glyph_row *row, int width, enum text
8929 if (cursor_glyph == NULL) 8924 if (cursor_glyph == NULL)
8930 return; 8925 return;
8931 8926
8932#ifdef HAVE_XWIDGETS 8927 /* Experimental avoidance of cursor on xwidget. */
8933 if (cursor_glyph->type == XWIDGET_GLYPH) 8928 if (cursor_glyph->type == XWIDGET_GLYPH)
8934 return; // Experimental avoidance of cursor on xwidget. 8929 return;
8935#endif
8936 8930
8937 /* If on an image, draw like a normal cursor. That's usually better 8931 /* If on an image, draw like a normal cursor. That's usually better
8938 visible than drawing a bar, esp. if the image is large so that 8932 visible than drawing a bar, esp. if the image is large so that
diff --git a/src/xwidget.c b/src/xwidget.c
index ea5dea0f9fe..be3e4ca5732 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include "xwidget.h"
22 23
23#include <signal.h> 24#include <signal.h>
24 25
@@ -105,8 +106,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
105#include <webkit/webkitdownload.h> 106#include <webkit/webkitdownload.h>
106#include <webkit/webkitwebpolicydecision.h> 107#include <webkit/webkitwebpolicydecision.h>
107 108
108#include "xwidget.h"
109
110static struct xwidget * 109static struct xwidget *
111allocate_xwidget (void) 110allocate_xwidget (void)
112{ 111{
@@ -120,8 +119,8 @@ allocate_xwidget_view (void)
120 PVEC_XWIDGET_VIEW); 119 PVEC_XWIDGET_VIEW);
121} 120}
122 121
123#define XSETXWIDGET(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)) 122#define XSETXWIDGET(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)
124#define XSETXWIDGET_VIEW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)) 123#define XSETXWIDGET_VIEW(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET_VIEW)
125 124
126static struct xwidget_view *xwidget_view_lookup (struct xwidget *, 125static struct xwidget_view *xwidget_view_lookup (struct xwidget *,
127 struct window *); 126 struct window *);
@@ -163,67 +162,57 @@ If BUFFER is nil, use the current buffer.
163If BUFFER is a string and no such buffer exists, create it. 162If BUFFER is a string and no such buffer exists, create it.
164TYPE is a symbol which can take one of the following values: 163TYPE is a symbol which can take one of the following values:
165 164
166- webkit_osr 165- webkit-osr
167 166
168Returns the newly constructed xwidget, or nil if construction fails. */) 167Returns the newly constructed xwidget, or nil if construction fails. */)
169 (Lisp_Object beg, Lisp_Object end, 168 (Lisp_Object beg, Lisp_Object end, Lisp_Object type,
170 Lisp_Object type, 169 Lisp_Object title, Lisp_Object width, Lisp_Object height,
171 Lisp_Object title, 170 Lisp_Object arguments, Lisp_Object buffer)
172 Lisp_Object width, Lisp_Object height,
173 Lisp_Object arguments, Lisp_Object buffer)
174{ 171{
175 //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) 172 CHECK_SYMBOL (type);
176 // arg "type" and fwd should be keyword args eventually 173 CHECK_NATNUM (width);
177 //(make-xwidget 3 3 'button "oei" 31 31 nil) 174 CHECK_NATNUM (height);
178 //(xwidget-info (car xwidget-list)) 175 /* This should work a bit like "make-button"
176 (make-button BEG END &rest PROPERTIES)
177 TYPE etc. should be keyword args eventually.
178 (make-xwidget 3 3 'button "oei" 31 31 nil)
179 (xwidget-info (car xwidget-list)) */
179 struct xwidget *xw = allocate_xwidget (); 180 struct xwidget *xw = allocate_xwidget ();
180 Lisp_Object val; 181 Lisp_Object val;
181 xw->type = type; 182 xw->type = type;
182 xw->title = title; 183 xw->title = title;
183 if (NILP (buffer)) 184 xw->buffer = NILP (buffer) ? Fcurrent_buffer () : Fget_buffer_create (buffer);
184 buffer = Fcurrent_buffer (); // no need to gcpro because
185 // Fcurrent_buffer doesn't
186 // call Feval/eval_sub.
187 else
188 buffer = Fget_buffer_create (buffer);
189 xw->buffer = buffer;
190
191 xw->height = XFASTINT (height); 185 xw->height = XFASTINT (height);
192 xw->width = XFASTINT (width); 186 xw->width = XFASTINT (width);
193 xw->kill_without_query = 0; 187 xw->kill_without_query = false;
194 XSETXWIDGET (val, xw); // set the vectorlike_header of VAL 188 XSETXWIDGET (val, xw);
195 // with the correct value
196 Vxwidget_list = Fcons (val, Vxwidget_list); 189 Vxwidget_list = Fcons (val, Vxwidget_list);
197 xw->widgetwindow_osr = NULL; 190 xw->widgetwindow_osr = NULL;
198 xw->widget_osr = NULL; 191 xw->widget_osr = NULL;
199 xw->plist = Qnil; 192 xw->plist = Qnil;
200 193
201
202 if (EQ (xw->type, Qwebkit_osr)) 194 if (EQ (xw->type, Qwebkit_osr))
203 { 195 {
204 block_input (); 196 block_input ();
205 xw->widgetwindow_osr = gtk_offscreen_window_new (); 197 xw->widgetwindow_osr = gtk_offscreen_window_new ();
206 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width, 198 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width,
207 xw->height); 199 xw->height);
208 xw->widgetscrolledwindow_osr = NULL; //webkit osr is the 200
209 //only scrolled 201 /* WebKit OSR is the only scrolled component at the moment. */
210 //component atm 202 xw->widgetscrolledwindow_osr = NULL;
211 203
212 if (EQ (xw->type, Qwebkit_osr)) 204 if (EQ (xw->type, Qwebkit_osr))
213 { 205 {
214 xw->widgetscrolledwindow_osr = gtk_scrolled_window_new (NULL, NULL); 206 xw->widgetscrolledwindow_osr = gtk_scrolled_window_new (NULL, NULL);
215 gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW 207 gtk_scrolled_window_set_min_content_height
216 (xw-> 208 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
217 widgetscrolledwindow_osr), 209 xw->height);
218 xw->height); 210 gtk_scrolled_window_set_min_content_width
219 gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW 211 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
220 (xw-> 212 xw->width);
221 widgetscrolledwindow_osr), 213 gtk_scrolled_window_set_policy
222 xw->width); 214 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
223 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW 215 GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
224 (xw->widgetscrolledwindow_osr),
225 GTK_POLICY_ALWAYS,
226 GTK_POLICY_ALWAYS);
227 216
228 xw->widget_osr = webkit_web_view_new (); 217 xw->widget_osr = webkit_web_view_new ();
229 gtk_container_add (GTK_CONTAINER (xw->widgetscrolledwindow_osr), 218 gtk_container_add (GTK_CONTAINER (xw->widgetscrolledwindow_osr),
@@ -248,12 +237,10 @@ Returns the newly constructed xwidget, or nil if construction fails. */)
248 gtk_widget_show (xw->widgetwindow_osr); 237 gtk_widget_show (xw->widgetwindow_osr);
249 gtk_widget_show (xw->widgetscrolledwindow_osr); 238 gtk_widget_show (xw->widgetscrolledwindow_osr);
250 239
251 /* store some xwidget data in the gtk widgets for convenient 240 /* Store some xwidget data in the gtk widgets for convenient
252 retrieval in the event handlers. */ 241 retrieval in the event handlers. */
253 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, 242 g_object_set_data (G_OBJECT (xw->widget_osr), XG_XWIDGET, xw);
254 (gpointer) (xw)); 243 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET, xw);
255 g_object_set_data (G_OBJECT (xw->widgetwindow_osr), XG_XWIDGET,
256 (gpointer) (xw));
257 244
258 /* signals */ 245 /* signals */
259 if (EQ (xw->type, Qwebkit_osr)) 246 if (EQ (xw->type, Qwebkit_osr))
@@ -286,7 +273,6 @@ Returns the newly constructed xwidget, or nil if construction fails. */)
286 } 273 }
287 274
288 unblock_input (); 275 unblock_input ();
289
290 } 276 }
291 277
292 return val; 278 return val;
@@ -317,18 +303,16 @@ BUFFER may be a buffer or the name of one. */)
317 return xw_list; 303 return xw_list;
318} 304}
319 305
320static int 306static bool
321xwidget_hidden (struct xwidget_view *xv) 307xwidget_hidden (struct xwidget_view *xv)
322{ 308{
323 return xv->hidden; 309 return xv->hidden;
324} 310}
325 311
326
327
328static void 312static void
329xwidget_show_view (struct xwidget_view *xv) 313xwidget_show_view (struct xwidget_view *xv)
330{ 314{
331 xv->hidden = 0; 315 xv->hidden = false;
332 gtk_widget_show (xv->widgetwindow); 316 gtk_widget_show (xv->widgetwindow);
333 gtk_fixed_move (GTK_FIXED (xv->emacswindow), 317 gtk_fixed_move (GTK_FIXED (xv->emacswindow),
334 xv->widgetwindow, 318 xv->widgetwindow,
@@ -336,33 +320,30 @@ xwidget_show_view (struct xwidget_view *xv)
336 xv->y + xv->clip_top); 320 xv->y + xv->clip_top);
337} 321}
338 322
339
340/* Hide an xvidget view. */ 323/* Hide an xvidget view. */
341static void 324static void
342xwidget_hide_view (struct xwidget_view *xv) 325xwidget_hide_view (struct xwidget_view *xv)
343{ 326{
344 xv->hidden = 1; 327 xv->hidden = true;
345 gtk_fixed_move (GTK_FIXED (xv->emacswindow), xv->widgetwindow, 328 gtk_fixed_move (GTK_FIXED (xv->emacswindow), xv->widgetwindow,
346 10000, 10000); 329 10000, 10000);
347} 330}
348 331
349
350
351/* When the off-screen webkit master view changes this signal is called. 332/* When the off-screen webkit master view changes this signal is called.
352 It copies the bitmap from the off-screen instance. */ 333 It copies the bitmap from the off-screen instance. */
353static gboolean 334static gboolean
354offscreen_damage_event (GtkWidget * widget, GdkEvent * event, 335offscreen_damage_event (GtkWidget *widget, GdkEvent *event,
355 gpointer xv_widget) 336 gpointer xv_widget)
356{ 337{
357 // Queue a redraw of onscreen widget. 338 /* Queue a redraw of onscreen widget.
358 // There is a guard against receiving an invalid widget, 339 There is a guard against receiving an invalid widget,
359 // which should only happen if we failed to remove the 340 which should only happen if we failed to remove the
360 // specific signal handler for the damage event. 341 specific signal handler for the damage event. */
361 if (GTK_IS_WIDGET (xv_widget)) 342 if (GTK_IS_WIDGET (xv_widget))
362 gtk_widget_queue_draw (GTK_WIDGET (xv_widget)); 343 gtk_widget_queue_draw (GTK_WIDGET (xv_widget));
363 else 344 else
364 printf ("Warning, offscreen_damage_event received invalid xv pointer:%p\n", 345 printf ("Warning, offscreen_damage_event received invalid xv pointer:%p\n",
365 (void *) xv_widget); 346 xv_widget);
366 347
367 return FALSE; 348 return FALSE;
368} 349}
@@ -377,75 +358,58 @@ store_xwidget_event_string (struct xwidget *xw, const char *eventname,
377 EVENT_INIT (event); 358 EVENT_INIT (event);
378 event.kind = XWIDGET_EVENT; 359 event.kind = XWIDGET_EVENT;
379 event.frame_or_window = Qnil; 360 event.frame_or_window = Qnil;
380 361 event.arg = list3 (intern (eventname), xwl, build_string (eventstr));
381 event.arg = Qnil;
382 event.arg = Fcons (build_string (eventstr), event.arg);
383 event.arg = Fcons (xwl, event.arg);
384 event.arg = Fcons (intern (eventname), event.arg);
385 kbd_buffer_store_event (&event); 362 kbd_buffer_store_event (&event);
386
387} 363}
388 364
389//TODO deprecated, use load-status 365/* TODO deprecated, use load-status. */
390void 366void
391webkit_document_load_finished_cb (WebKitWebView * webkitwebview, 367webkit_document_load_finished_cb (WebKitWebView *webkitwebview,
392 WebKitWebFrame * arg1, 368 WebKitWebFrame *arg1,
393 gpointer data) 369 gpointer data)
394{ 370{
395 struct xwidget *xw = 371 struct xwidget *xw = g_object_get_data (G_OBJECT (webkitwebview),
396 (struct xwidget *) g_object_get_data (G_OBJECT (webkitwebview),
397 XG_XWIDGET); 372 XG_XWIDGET);
398 373
399 store_xwidget_event_string (xw, "document-load-finished", ""); 374 store_xwidget_event_string (xw, "document-load-finished", "");
400} 375}
401 376
402gboolean 377gboolean
403webkit_download_cb (WebKitWebView * webkitwebview, 378webkit_download_cb (WebKitWebView *webkitwebview,
404 WebKitDownload * arg1, 379 WebKitDownload *arg1,
405 gpointer data) 380 gpointer data)
406{ 381{
407 struct xwidget *xw = 382 struct xwidget *xw = g_object_get_data (G_OBJECT (webkitwebview),
408 (struct xwidget *) g_object_get_data (G_OBJECT (webkitwebview),
409 XG_XWIDGET); 383 XG_XWIDGET);
410 store_xwidget_event_string (xw, "download-requested", 384 store_xwidget_event_string (xw, "download-requested",
411 webkit_download_get_uri (arg1)); 385 webkit_download_get_uri (arg1));
412
413 return FALSE; 386 return FALSE;
414} 387}
415 388
416static gboolean 389static gboolean
417webkit_mime_type_policy_typedecision_requested_cb (WebKitWebView *webView, 390webkit_mime_type_policy_typedecision_requested_cb
418 WebKitWebFrame *frame, 391(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
419 WebKitNetworkRequest * request, 392 gchar *mimetype, WebKitWebPolicyDecision *policy_decision, gpointer user_data)
420 gchar * mimetype,
421 WebKitWebPolicyDecision *policy_decision,
422 gpointer user_data)
423{ 393{
424 // This function makes webkit send a download signal for all unknown 394 /* This function makes webkit send a download signal for all unknown
425 // mime types. TODO Defer the decision to lisp, so that its possible 395 mime types. TODO: Defer the decision to Lisp, so that it's
426 // to make Emacs handle teext mime for instance.xs 396 possible to make Emacs handle teext mime for instance.xs. */
427 if (!webkit_web_view_can_show_mime_type (webView, mimetype)) 397 if (!webkit_web_view_can_show_mime_type (webView, mimetype))
428 { 398 {
429 webkit_web_policy_decision_download (policy_decision); 399 webkit_web_policy_decision_download (policy_decision);
430 return TRUE; 400 return TRUE;
431 } 401 }
432 else 402 else
433 { 403 return FALSE;
434 return FALSE;
435 }
436} 404}
437 405
438
439static gboolean 406static gboolean
440webkit_new_window_policy_decision_requested_cb (WebKitWebView *webView, 407webkit_new_window_policy_decision_requested_cb
441 WebKitWebFrame *frame, 408(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
442 WebKitNetworkRequest *request, 409 WebKitWebNavigationAction *navigation_action,
443 WebKitWebNavigationAction *navigation_action, 410 WebKitWebPolicyDecision *policy_decision, gpointer user_data)
444 WebKitWebPolicyDecision *policy_decision,
445 gpointer user_data)
446{ 411{
447 struct xwidget *xw = 412 struct xwidget *xw = g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
448 (struct xwidget *) g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
449 webkit_web_navigation_action_get_original_uri (navigation_action); 413 webkit_web_navigation_action_get_original_uri (navigation_action);
450 414
451 store_xwidget_event_string (xw, "new-window-policy-decision-requested", 415 store_xwidget_event_string (xw, "new-window-policy-decision-requested",
@@ -455,29 +419,24 @@ webkit_new_window_policy_decision_requested_cb (WebKitWebView *webView,
455} 419}
456 420
457static gboolean 421static gboolean
458webkit_navigation_policy_decision_requested_cb (WebKitWebView *webView, 422webkit_navigation_policy_decision_requested_cb
459 WebKitWebFrame *frame, 423(WebKitWebView *webView, WebKitWebFrame *frame, WebKitNetworkRequest *request,
460 WebKitNetworkRequest *request, 424 WebKitWebNavigationAction *navigation_action,
461 WebKitWebNavigationAction *navigation_action, 425 WebKitWebPolicyDecision *policy_decision, gpointer user_data)
462 WebKitWebPolicyDecision * policy_decision,
463 gpointer user_data)
464{ 426{
465 struct xwidget *xw = 427 struct xwidget *xw = g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
466 (struct xwidget *) g_object_get_data (G_OBJECT (webView), XG_XWIDGET);
467 store_xwidget_event_string (xw, "navigation-policy-decision-requested", 428 store_xwidget_event_string (xw, "navigation-policy-decision-requested",
468 webkit_web_navigation_action_get_original_uri 429 webkit_web_navigation_action_get_original_uri
469 (navigation_action)); 430 (navigation_action));
470 return FALSE; 431 return FALSE;
471} 432}
472 433
473// For gtk3 offscreen rendered widgets. 434/* For gtk3 offscreen rendered widgets. */
474static gboolean 435static gboolean
475xwidget_osr_draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data) 436xwidget_osr_draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
476{ 437{
477 struct xwidget *xw = 438 struct xwidget *xw = g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
478 (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET); 439 struct xwidget_view *xv = g_object_get_data (G_OBJECT (widget),
479 struct xwidget_view *xv =
480 (struct xwidget_view *) g_object_get_data (G_OBJECT (widget),
481 XG_XWIDGET_VIEW); 440 XG_XWIDGET_VIEW);
482 441
483 cairo_rectangle (cr, 0, 0, xv->clip_right, xv->clip_bottom); 442 cairo_rectangle (cr, 0, 0, xv->clip_right, xv->clip_bottom);
@@ -491,31 +450,30 @@ xwidget_osr_draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
491} 450}
492 451
493static gboolean 452static gboolean
494xwidget_osr_event_forward (GtkWidget * widget, 453xwidget_osr_event_forward (GtkWidget *widget, GdkEvent *event,
495 GdkEvent * event, 454 gpointer user_data)
496 gpointer user_data)
497{ 455{
498 /* Copy events that arrive at the outer widget to the offscreen widget. */ 456 /* Copy events that arrive at the outer widget to the offscreen widget. */
499 struct xwidget *xw = 457 struct xwidget *xw = g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
500 (struct xwidget *) g_object_get_data (G_OBJECT (widget), XG_XWIDGET);
501 GdkEvent *eventcopy = gdk_event_copy (event); 458 GdkEvent *eventcopy = gdk_event_copy (event);
502 eventcopy->any.window = gtk_widget_get_window (xw->widget_osr); 459 eventcopy->any.window = gtk_widget_get_window (xw->widget_osr);
503 460
504 //TODO This might leak events. They should be deallocated later, 461 /* TODO: This might leak events. They should be deallocated later,
505 //perhaps in xwgir_event_cb 462 perhaps in xwgir_event_cb. */
506 gtk_main_do_event (eventcopy); 463 gtk_main_do_event (eventcopy);
507 return TRUE; //dont propagate this event furter
508}
509 464
465 /* Don't propagate this event further. */
466 return TRUE;
467}
510 468
511static gboolean 469static gboolean
512xwidget_osr_event_set_embedder (GtkWidget * widget, 470xwidget_osr_event_set_embedder (GtkWidget *widget, GdkEvent *event,
513 GdkEvent * event, gpointer data) 471 gpointer data)
514{ 472{
515 struct xwidget_view *xv = (struct xwidget_view *) data; 473 struct xwidget_view *xv = data;
516 struct xwidget *xww = XXWIDGET (xv->model); 474 struct xwidget *xww = XXWIDGET (xv->model);
517 gdk_offscreen_window_set_embedder (gtk_widget_get_window 475 gdk_offscreen_window_set_embedder (gtk_widget_get_window
518 (xww->widgetwindow_osr), 476 (xww->widgetwindow_osr),
519 gtk_widget_get_window (xv->widget)); 477 gtk_widget_get_window (xv->widget));
520 return FALSE; 478 return FALSE;
521} 479}
@@ -539,11 +497,11 @@ xwidget_init_view (struct xwidget *xww,
539 if (EQ (xww->type, Qwebkit_osr)) 497 if (EQ (xww->type, Qwebkit_osr))
540 { 498 {
541 xv->widget = gtk_drawing_area_new (); 499 xv->widget = gtk_drawing_area_new ();
542 // Expose event handling. 500 /* Expose event handling. */
543 gtk_widget_set_app_paintable (xv->widget, TRUE); 501 gtk_widget_set_app_paintable (xv->widget, TRUE);
544 gtk_widget_add_events (xv->widget, GDK_ALL_EVENTS_MASK); 502 gtk_widget_add_events (xv->widget, GDK_ALL_EVENTS_MASK);
545 503
546 /* Draw the view on damage-event */ 504 /* Draw the view on damage-event. */
547 g_signal_connect (G_OBJECT (xww->widgetwindow_osr), "damage-event", 505 g_signal_connect (G_OBJECT (xww->widgetwindow_osr), "damage-event",
548 G_CALLBACK (offscreen_damage_event), xv->widget); 506 G_CALLBACK (offscreen_damage_event), xv->widget);
549 507
@@ -558,38 +516,33 @@ xwidget_init_view (struct xwidget *xww,
558 } 516 }
559 else 517 else
560 { 518 {
561 // xwgir debug , orthogonal to forwarding 519 /* xwgir debug, orthogonal to forwarding. */
562 g_signal_connect (G_OBJECT (xv->widget), "enter-notify-event", 520 g_signal_connect (G_OBJECT (xv->widget), "enter-notify-event",
563 G_CALLBACK (xwidget_osr_event_set_embedder), xv); 521 G_CALLBACK (xwidget_osr_event_set_embedder), xv);
564 } 522 }
565 g_signal_connect (G_OBJECT (xv->widget), "draw", 523 g_signal_connect (G_OBJECT (xv->widget), "draw",
566 G_CALLBACK (xwidget_osr_draw_cb), NULL); 524 G_CALLBACK (xwidget_osr_draw_cb), NULL);
567 } 525 }
568 // Widget realization.
569 526
570 // Make container widget 1st, and put the actual widget inside the 527 /* Widget realization.
571 // container later. Drawing should crop container window if necessary 528
572 // to handle case where xwidget is partially obscured by other Emacs 529 Make container widget first, and put the actual widget inside the
573 // windows. Other containers than gtk_fixed where explored, but 530 container later. Drawing should crop container window if necessary
574 // gtk_fixed had the most predictable behaviour so far. 531 to handle case where xwidget is partially obscured by other Emacs
532 windows. Other containers than gtk_fixed where explored, but
533 gtk_fixed had the most predictable behaviour so far. */
534
575 xv->emacswindow = FRAME_GTK_WIDGET (s->f); 535 xv->emacswindow = FRAME_GTK_WIDGET (s->f);
576 xv->widgetwindow = gtk_fixed_new (); 536 xv->widgetwindow = gtk_fixed_new ();
577 gtk_widget_set_has_window (xv->widgetwindow, TRUE); 537 gtk_widget_set_has_window (xv->widgetwindow, TRUE);
578 gtk_container_add (GTK_CONTAINER (xv->widgetwindow), xv->widget); 538 gtk_container_add (GTK_CONTAINER (xv->widgetwindow), xv->widget);
579 539
580 // Store some xwidget data in the gtk widgets. 540 /* Store some xwidget data in the gtk widgets. */
581 // The emacs frame. 541 g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, s->f);
582 g_object_set_data (G_OBJECT (xv->widget), XG_FRAME_DATA, (gpointer) (s->f)); 542 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, xww);
583 // The xwidget. 543 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, xv);
584 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET, (gpointer) (xww)); 544 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, xww);
585 // The xwidget. 545 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW, xv);
586 g_object_set_data (G_OBJECT (xv->widget), XG_XWIDGET_VIEW, (gpointer) (xv));
587 // The xwidget window.
588 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET, (gpointer) (xww));
589 // the xwidget view.
590 g_object_set_data (G_OBJECT (xv->widgetwindow), XG_XWIDGET_VIEW,
591 (gpointer) (xv));
592
593 546
594 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width, 547 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xww->width,
595 xww->height); 548 xww->height);
@@ -599,18 +552,15 @@ xwidget_init_view (struct xwidget *xww,
599 xv->y = y; 552 xv->y = y;
600 gtk_widget_show_all (xv->widgetwindow); 553 gtk_widget_show_all (xv->widgetwindow);
601 554
602
603 return xv; 555 return xv;
604} 556}
605 557
606
607void 558void
608x_draw_xwidget_glyph_string (struct glyph_string *s) 559x_draw_xwidget_glyph_string (struct glyph_string *s)
609{ 560{
610 /* This method is called by the redisplay engine and places the 561 /* This method is called by the redisplay engine and places the
611 xwidget on screen. Moving and clipping is done here. Also view 562 xwidget on screen. Moving and clipping is done here. Also view
612 initialization. 563 initialization. */
613 */
614 struct xwidget *xww = s->xwidget; 564 struct xwidget *xww = s->xwidget;
615 struct xwidget_view *xv = xwidget_view_lookup (xww, s->w); 565 struct xwidget_view *xv = xwidget_view_lookup (xww, s->w);
616 int clip_right; 566 int clip_right;
@@ -620,16 +570,14 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
620 570
621 int x = s->x; 571 int x = s->x;
622 int y = s->y + (s->height / 2) - (xww->height / 2); 572 int y = s->y + (s->height / 2) - (xww->height / 2);
623 int moved = 0;
624 573
625 /* We do initialization here in the display loop because there is no 574 /* Do initialization here in the display loop because there is no
626 other time to know things like window placement etc. 575 other time to know things like window placement etc. */
627 */
628 xv = xwidget_init_view (xww, s, x, y); 576 xv = xwidget_init_view (xww, s, x, y);
629 577
630 // Calculate clipping, which is used for all manner of onscreen 578 /* Calculate clipping, which is used for all manner of onscreen
631 // xwidget views. Each widget border can get clipped by other emacs 579 xwidget views. Each widget border can get clipped by other emacs
632 // objects so there are four clipping variables. 580 objects so there are four clipping variables. */
633 clip_right = 581 clip_right =
634 min (xww->width, 582 min (xww->width,
635 WINDOW_RIGHT_EDGE_X (s->w) - x - 583 WINDOW_RIGHT_EDGE_X (s->w) - x -
@@ -646,31 +594,32 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
646 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y); 594 WINDOW_BOTTOM_EDGE_Y (s->w) - WINDOW_MODE_LINE_HEIGHT (s->w) - y);
647 clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y); 595 clip_top = max (0, WINDOW_TOP_EDGE_Y (s->w) - y);
648 596
649 // We are conserned with movement of the onscreen area. The area 597 /* We are conserned with movement of the onscreen area. The area
650 // might sit still when the widget actually moves. This happens 598 might sit still when the widget actually moves. This happens
651 // when an Emacs window border moves across a widget window. So, if 599 when an Emacs window border moves across a widget window. So, if
652 // any corner of the outer widget clipping window moves, that counts 600 any corner of the outer widget clipping window moves, that counts
653 // as movement here, even if it looks like no movement happens 601 as movement here, even if it looks like no movement happens
654 // because the widget sits still inside the clipping area. The 602 because the widget sits still inside the clipping area. The
655 // widget can also move inside the clipping area, which happens 603 widget can also move inside the clipping area, which happens
656 // later 604 later. */
657 moved = (xv->x + xv->clip_left != x + clip_left) 605 bool moved = (xv->x + xv->clip_left != x + clip_left
658 || ((xv->y + xv->clip_top) != (y + clip_top)); 606 || xv->y + xv->clip_top != y + clip_top);
659 xv->x = x; 607 xv->x = x;
660 xv->y = y; 608 xv->y = y;
661 if (moved) // Has it moved? 609
662 { 610 /* Has it moved? */
663 gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (s->f)), 611 if (moved)
664 xv->widgetwindow, x + clip_left, y + clip_top); 612 gtk_fixed_move (GTK_FIXED (FRAME_GTK_WIDGET (s->f)),
665 } 613 xv->widgetwindow, x + clip_left, y + clip_top);
666 // Clip the widget window if some parts happen to be outside 614
667 // drawable area. An Emacs window is not a gtk window. A gtk window 615 /* Clip the widget window if some parts happen to be outside
668 // covers the entire frame. Clipping might have changed even if we 616 drawable area. An Emacs window is not a gtk window. A gtk window
669 // havent actualy moved, we try figure out when we need to reclip 617 covers the entire frame. Clipping might have changed even if we
670 // for real. 618 havent actualy moved, we try figure out when we need to reclip
671 if ((xv->clip_right != clip_right) 619 for real. */
672 || (xv->clip_bottom != clip_bottom) 620 if (xv->clip_right != clip_right
673 || (xv->clip_top != clip_top) || (xv->clip_left != clip_left)) 621 || xv->clip_bottom != clip_bottom
622 || xv->clip_top != clip_top || xv->clip_left != clip_left)
674 { 623 {
675 gtk_widget_set_size_request (xv->widgetwindow, clip_right + clip_left, 624 gtk_widget_set_size_request (xv->widgetwindow, clip_right + clip_left,
676 clip_bottom + clip_top); 625 clip_bottom + clip_top);
@@ -682,10 +631,11 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
682 xv->clip_top = clip_top; 631 xv->clip_top = clip_top;
683 xv->clip_left = clip_left; 632 xv->clip_left = clip_left;
684 } 633 }
685 // If emacs wants to repaint the area where the widget lives, queue 634
686 // a redraw. It seems its possible to get out of sync with emacs 635 /* If emacs wants to repaint the area where the widget lives, queue
687 // redraws so emacs background sometimes shows up instead of the 636 a redraw. It seems its possible to get out of sync with emacs
688 // xwidgets background. It's just a visual glitch though. 637 redraws so emacs background sometimes shows up instead of the
638 xwidgets background. It's just a visual glitch though. */
689 if (!xwidget_hidden (xv)) 639 if (!xwidget_hidden (xv))
690 { 640 {
691 gtk_widget_queue_draw (xv->widgetwindow); 641 gtk_widget_queue_draw (xv->widgetwindow);
@@ -693,19 +643,15 @@ x_draw_xwidget_glyph_string (struct glyph_string *s)
693 } 643 }
694} 644}
695 645
696 646/* Macro that checks WEBKIT_IS_WEB_VIEW (xw->widget_osr) first. */
697// Macro that checks WEBKIT_IS_WEB_VIEW(xw->widget_osr) first 647#define WEBKIT_FN_INIT() \
698#define WEBKIT_FN_INIT() \ 648 CHECK_XWIDGET (xwidget); \
699 struct xwidget* xw; \ 649 struct xwidget *xw = XXWIDGET (xwidget); \
700 CHECK_XWIDGET (xwidget); \ 650 if (!xw->widget_osr || !WEBKIT_IS_WEB_VIEW (xw->widget_osr)) \
701 if (NILP (xwidget)) {printf("ERROR xwidget nil\n"); return Qnil;}; \ 651 { \
702 xw = XXWIDGET (xwidget); \ 652 printf ("ERROR xw->widget_osr does not hold a webkit instance\n"); \
703 if (NULL == xw) printf("ERROR xw is 0\n"); \ 653 return Qnil; \
704 if ((NULL == xw->widget_osr) || !WEBKIT_IS_WEB_VIEW(xw->widget_osr)){ \ 654 }
705 printf ("ERROR xw->widget_osr does not hold a webkit instance\n");\
706 return Qnil;\
707 };
708
709 655
710DEFUN ("xwidget-webkit-goto-uri", 656DEFUN ("xwidget-webkit-goto-uri",
711 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 657 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri,
@@ -723,7 +669,7 @@ DEFUN ("xwidget-webkit-goto-uri",
723DEFUN ("xwidget-webkit-execute-script", 669DEFUN ("xwidget-webkit-execute-script",
724 Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script, 670 Fxwidget_webkit_execute_script, Sxwidget_webkit_execute_script,
725 2, 2, 0, 671 2, 2, 0,
726 doc: /* Make the Webkit XWIDGET execute javascript SCRIPT. */) 672 doc: /* Make the Webkit XWIDGET execute JavaScript SCRIPT. */)
727 (Lisp_Object xwidget, Lisp_Object script) 673 (Lisp_Object xwidget, Lisp_Object script)
728{ 674{
729 WEBKIT_FN_INIT (); 675 WEBKIT_FN_INIT ();
@@ -741,14 +687,14 @@ This can be used to work around the lack of a return value from the
741exec method. */ ) 687exec method. */ )
742 (Lisp_Object xwidget) 688 (Lisp_Object xwidget)
743{ 689{
744 // TODO support multibyte strings 690 /* TODO support multibyte strings. */
745 WEBKIT_FN_INIT (); 691 WEBKIT_FN_INIT ();
746 const gchar *str = 692 const gchar *str =
747 webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr)); 693 webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr));
748 if (str == 0) 694 if (str == 0)
749 { 695 {
750 // TODO maybe return Qnil instead. I suppose webkit returns 696 /* TODO maybe return Qnil instead. I suppose webkit returns
751 // nullpointer when doc is not properly loaded or something 697 null pointer when doc is not properly loaded or something. */
752 return build_string (""); 698 return build_string ("");
753 } 699 }
754 return build_string (str); 700 return build_string (str);
@@ -759,32 +705,30 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
759 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) 705 (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height)
760{ 706{
761 CHECK_XWIDGET (xwidget); 707 CHECK_XWIDGET (xwidget);
708 CHECK_NATNUM (new_width);
709 CHECK_NATNUM (new_height);
762 struct xwidget *xw = XXWIDGET (xwidget); 710 struct xwidget *xw = XXWIDGET (xwidget);
763 struct xwidget_view *xv; 711 int w = XFASTINT (new_width);
764 int w, h; 712 int h = XFASTINT (new_height);
765
766 CHECK_NUMBER (new_width);
767 CHECK_NUMBER (new_height);
768 w = XFASTINT (new_width);
769 h = XFASTINT (new_height);
770 713
771 xw->width = w; 714 xw->width = w;
772 xw->height = h; 715 xw->height = h;
773 // If there is a offscreen widget resize it 1st. 716
717 /* If there is an offscreen widget resize it first. */
774 if (xw->widget_osr) 718 if (xw->widget_osr)
775 { 719 {
720 /* Use minimum size. */
776 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), 721 gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr),
777 xw->width, xw->height); //minimum size 722 xw->width, xw->height);
723
778 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width, 724 gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width,
779 xw->height); 725 xw->height);
780 gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW 726 gtk_scrolled_window_set_min_content_height
781 (xw-> 727 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
782 widgetscrolledwindow_osr), 728 xw->height);
783 xw->height); 729 gtk_scrolled_window_set_min_content_width
784 gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW 730 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr),
785 (xw-> 731 xw->width);
786 widgetscrolledwindow_osr),
787 xw->width);
788 732
789 gtk_container_resize_children (GTK_CONTAINER (xw->widgetwindow_osr)); 733 gtk_container_resize_children (GTK_CONTAINER (xw->widgetwindow_osr));
790 734
@@ -794,7 +738,7 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
794 { 738 {
795 if (XWIDGET_VIEW_P (XCAR (tail))) 739 if (XWIDGET_VIEW_P (XCAR (tail)))
796 { 740 {
797 xv = XXWIDGET_VIEW (XCAR (tail)); 741 struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
798 if (XXWIDGET (xv->model) == xw) 742 if (XXWIDGET (xv->model) == xw)
799 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xw->width, 743 gtk_widget_set_size_request (GTK_WIDGET (xv->widget), xw->width,
800 xw->height); 744 xw->height);
@@ -816,37 +760,17 @@ VALUE is the amount to scroll, either relatively or absolutely. */)
816 Lisp_Object value) 760 Lisp_Object value)
817{ 761{
818 CHECK_XWIDGET (xwidget); 762 CHECK_XWIDGET (xwidget);
763 CHECK_NATNUM (value);
819 struct xwidget *xw = XXWIDGET (xwidget); 764 struct xwidget *xw = XXWIDGET (xwidget);
820 GtkAdjustment *adjustment; 765 GtkAdjustment *adjustment
821 float final_value = 0.0; 766 = ((EQ (Qhorizontal, axis)
822 767 ? gtk_scrolled_window_get_hadjustment
823 adjustment = 768 : gtk_scrolled_window_get_vadjustment)
824 gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW 769 (GTK_SCROLLED_WINDOW (xw->widgetscrolledwindow_osr)));
825 (xw->widgetscrolledwindow_osr)); 770 double final_value = XFASTINT (value);
826 if (EQ (Qvertical, axis))
827 {
828 adjustment =
829 gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
830 (xw->widgetscrolledwindow_osr));
831 }
832 if (EQ (Qhorizontal, axis))
833 {
834 adjustment =
835 gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW
836 (xw->widgetscrolledwindow_osr));
837 }
838
839 if (EQ (Qt, relative)) 771 if (EQ (Qt, relative))
840 { 772 final_value += gtk_adjustment_get_value (adjustment);
841 final_value = gtk_adjustment_get_value (adjustment) + XFASTINT (value);
842 }
843 else
844 {
845 final_value = 0.0 + XFASTINT (value);
846 }
847
848 gtk_adjustment_set_value (adjustment, final_value); 773 gtk_adjustment_set_value (adjustment, final_value);
849
850 return Qnil; 774 return Qnil;
851} 775}
852 776
@@ -861,13 +785,9 @@ Emacs allocated area accordingly. */)
861{ 785{
862 CHECK_XWIDGET (xwidget); 786 CHECK_XWIDGET (xwidget);
863 GtkRequisition requisition; 787 GtkRequisition requisition;
864 Lisp_Object rv;
865 gtk_widget_size_request (XXWIDGET (xwidget)->widget_osr, &requisition); 788 gtk_widget_size_request (XXWIDGET (xwidget)->widget_osr, &requisition);
866 rv = Qnil; 789 return list2 (make_number (requisition.width),
867 rv = Fcons (make_number (requisition.height), rv); 790 make_number (requisition.height));
868 rv = Fcons (make_number (requisition.width), rv);
869 return rv;
870
871} 791}
872 792
873DEFUN ("xwidgetp", 793DEFUN ("xwidgetp",
@@ -896,18 +816,9 @@ Currently [TYPE TITLE WIDTH HEIGHT]. */)
896 (Lisp_Object xwidget) 816 (Lisp_Object xwidget)
897{ 817{
898 CHECK_XWIDGET (xwidget); 818 CHECK_XWIDGET (xwidget);
899 Lisp_Object info, n;
900 struct xwidget *xw = XXWIDGET (xwidget); 819 struct xwidget *xw = XXWIDGET (xwidget);
901 820 return CALLN (Fvector, xw->type, xw->title,
902 info = Fmake_vector (make_number (4), Qnil); 821 make_natnum (xw->width), make_natnum (xw->height));
903 ASET (info, 0, xw->type);
904 ASET (info, 1, xw->title);
905 XSETFASTINT (n, xw->width);
906 ASET (info, 2, n);
907 XSETFASTINT (n, xw->height);
908 ASET (info, 3, n);
909
910 return info;
911} 822}
912 823
913DEFUN ("xwidget-view-info", 824DEFUN ("xwidget-view-info",
@@ -919,17 +830,9 @@ Currently [X Y CLIP_RIGHT CLIP_BOTTOM CLIP_TOP CLIP_LEFT]. */)
919{ 830{
920 CHECK_XWIDGET_VIEW (xwidget_view); 831 CHECK_XWIDGET_VIEW (xwidget_view);
921 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view); 832 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
922 Lisp_Object info; 833 return CALLN (Fvector, make_number (xv->x), make_number (xv->y),
923 834 make_number (xv->clip_right), make_number (xv->clip_bottom),
924 info = Fmake_vector (make_number (6), Qnil); 835 make_number (xv->clip_top), make_number (xv->clip_left));
925 ASET (info, 0, make_number (xv->x));
926 ASET (info, 1, make_number (xv->y));
927 ASET (info, 2, make_number (xv->clip_right));
928 ASET (info, 3, make_number (xv->clip_bottom));
929 ASET (info, 4, make_number (xv->clip_top));
930 ASET (info, 5, make_number (xv->clip_left));
931
932 return info;
933} 836}
934 837
935DEFUN ("xwidget-view-model", 838DEFUN ("xwidget-view-model",
@@ -963,8 +866,8 @@ DEFUN ("delete-xwidget-view",
963 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view); 866 struct xwidget_view *xv = XXWIDGET_VIEW (xwidget_view);
964 gtk_widget_destroy (xv->widgetwindow); 867 gtk_widget_destroy (xv->widgetwindow);
965 Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list); 868 Vxwidget_view_list = Fdelq (xwidget_view, Vxwidget_view_list);
966 // xv->model still has signals pointing to the view. There can be 869 /* xv->model still has signals pointing to the view. There can be
967 // several views. Find the matching signals and delete them all. 870 several views. Find the matching signals and delete them all. */
968 g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr, 871 g_signal_handlers_disconnect_matched (XXWIDGET (xv->model)->widgetwindow_osr,
969 G_SIGNAL_MATCH_DATA, 872 G_SIGNAL_MATCH_DATA,
970 0, 0, 0, 0, 873 0, 0, 0, 0,
@@ -1002,7 +905,7 @@ DEFUN ("xwidget-plist",
1002 Fxwidget_plist, Sxwidget_plist, 905 Fxwidget_plist, Sxwidget_plist,
1003 1, 1, 0, 906 1, 1, 0,
1004 doc: /* Return the plist of XWIDGET. */) 907 doc: /* Return the plist of XWIDGET. */)
1005 (register Lisp_Object xwidget) 908 (Lisp_Object xwidget)
1006{ 909{
1007 CHECK_XWIDGET (xwidget); 910 CHECK_XWIDGET (xwidget);
1008 return XXWIDGET (xwidget)->plist; 911 return XXWIDGET (xwidget)->plist;
@@ -1012,7 +915,7 @@ DEFUN ("xwidget-buffer",
1012 Fxwidget_buffer, Sxwidget_buffer, 915 Fxwidget_buffer, Sxwidget_buffer,
1013 1, 1, 0, 916 1, 1, 0,
1014 doc: /* Return the buffer of XWIDGET. */) 917 doc: /* Return the buffer of XWIDGET. */)
1015 (register Lisp_Object xwidget) 918 (Lisp_Object xwidget)
1016{ 919{
1017 CHECK_XWIDGET (xwidget); 920 CHECK_XWIDGET (xwidget);
1018 return XXWIDGET (xwidget)->buffer; 921 return XXWIDGET (xwidget)->buffer;
@@ -1023,7 +926,7 @@ DEFUN ("set-xwidget-plist",
1023 2, 2, 0, 926 2, 2, 0,
1024 doc: /* Replace the plist of XWIDGET with PLIST. 927 doc: /* Replace the plist of XWIDGET with PLIST.
1025Returns PLIST. */) 928Returns PLIST. */)
1026 (register Lisp_Object xwidget, Lisp_Object plist) 929 (Lisp_Object xwidget, Lisp_Object plist)
1027{ 930{
1028 CHECK_XWIDGET (xwidget); 931 CHECK_XWIDGET (xwidget);
1029 CHECK_LIST (plist); 932 CHECK_LIST (plist);
@@ -1059,7 +962,6 @@ DEFUN ("xwidget-query-on-exit-flag",
1059void 962void
1060syms_of_xwidget (void) 963syms_of_xwidget (void)
1061{ 964{
1062
1063 defsubr (&Smake_xwidget); 965 defsubr (&Smake_xwidget);
1064 defsubr (&Sxwidgetp); 966 defsubr (&Sxwidgetp);
1065 DEFSYM (Qxwidgetp, "xwidgetp"); 967 DEFSYM (Qxwidgetp, "xwidgetp");
@@ -1111,7 +1013,6 @@ syms_of_xwidget (void)
1111 Vxwidget_view_list = Qnil; 1013 Vxwidget_view_list = Qnil;
1112 1014
1113 Fprovide (intern ("xwidget-internal"), Qnil); 1015 Fprovide (intern ("xwidget-internal"), Qnil);
1114
1115} 1016}
1116 1017
1117 1018
@@ -1125,19 +1026,13 @@ syms_of_xwidget (void)
1125bool 1026bool
1126valid_xwidget_spec_p (Lisp_Object object) 1027valid_xwidget_spec_p (Lisp_Object object)
1127{ 1028{
1128 int valid_p = false; 1029 return CONSP (object) && EQ (XCAR (object), Qxwidget);
1129
1130 if (CONSP (object) && EQ (XCAR (object), Qxwidget))
1131 valid_p = true;
1132
1133 return valid_p;
1134} 1030}
1135 1031
1136 1032
1137
1138/* Find a value associated with key in spec. */ 1033/* Find a value associated with key in spec. */
1139static Lisp_Object 1034static Lisp_Object
1140xwidget_spec_value (Lisp_Object spec, Lisp_Object key, int *found) 1035xwidget_spec_value (Lisp_Object spec, Lisp_Object key)
1141{ 1036{
1142 Lisp_Object tail; 1037 Lisp_Object tail;
1143 1038
@@ -1147,15 +1042,9 @@ xwidget_spec_value (Lisp_Object spec, Lisp_Object key, int *found)
1147 CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail))) 1042 CONSP (tail) && CONSP (XCDR (tail)); tail = XCDR (XCDR (tail)))
1148 { 1043 {
1149 if (EQ (XCAR (tail), key)) 1044 if (EQ (XCAR (tail), key))
1150 { 1045 return XCAR (XCDR (tail));
1151 if (found)
1152 *found = 1;
1153 return XCAR (XCDR (tail));
1154 }
1155 } 1046 }
1156 1047
1157 if (found)
1158 *found = 0;
1159 return Qnil; 1048 return Qnil;
1160} 1049}
1161 1050
@@ -1195,19 +1084,17 @@ lookup_xwidget (Lisp_Object spec)
1195{ 1084{
1196 /* When a xwidget lisp spec is found initialize the C struct that is 1085 /* When a xwidget lisp spec is found initialize the C struct that is
1197 used in the C code. This is done by redisplay so values change 1086 used in the C code. This is done by redisplay so values change
1198 if the spec changes. So, take special care of one-shot events. 1087 if the spec changes. So, take special care of one-shot events. */
1199 */
1200 int found = 0;
1201 Lisp_Object value; 1088 Lisp_Object value;
1202 struct xwidget *xw; 1089 struct xwidget *xw;
1203 1090
1204 value = xwidget_spec_value (spec, QCxwidget, &found); 1091 value = xwidget_spec_value (spec, QCxwidget);
1205 xw = XXWIDGET (value); 1092 xw = XXWIDGET (value);
1206 1093
1207 return xw; 1094 return xw;
1208} 1095}
1209 1096
1210/* Set up detection of touched xwidget */ 1097/* Set up detection of touched xwidget. */
1211static void 1098static void
1212xwidget_start_redisplay (void) 1099xwidget_start_redisplay (void)
1213{ 1100{
@@ -1215,7 +1102,7 @@ xwidget_start_redisplay (void)
1215 tail = XCDR (tail)) 1102 tail = XCDR (tail))
1216 { 1103 {
1217 if (XWIDGET_VIEW_P (XCAR (tail))) 1104 if (XWIDGET_VIEW_P (XCAR (tail)))
1218 XXWIDGET_VIEW (XCAR (tail))->redisplayed = 0; 1105 XXWIDGET_VIEW (XCAR (tail))->redisplayed = false;
1219 } 1106 }
1220} 1107}
1221 1108
@@ -1224,57 +1111,48 @@ xwidget_start_redisplay (void)
1224static void 1111static void
1225xwidget_touch (struct xwidget_view *xv) 1112xwidget_touch (struct xwidget_view *xv)
1226{ 1113{
1227 xv->redisplayed = 1; 1114 xv->redisplayed = true;
1228} 1115}
1229 1116
1230static int 1117static bool
1231xwidget_touched (struct xwidget_view *xv) 1118xwidget_touched (struct xwidget_view *xv)
1232{ 1119{
1233 return xv->redisplayed; 1120 return xv->redisplayed;
1234} 1121}
1235 1122
1236/* Redisplay has ended, now we should hide untouched xwidgets 1123/* Redisplay has ended, now we should hide untouched xwidgets. */
1237*/
1238void 1124void
1239xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) 1125xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1240{ 1126{
1241
1242 int i; 1127 int i;
1243 int area; 1128 int area;
1244 1129
1245 xwidget_start_redisplay (); 1130 xwidget_start_redisplay ();
1246 // Iterate desired glyph matrix of window here, hide gtk widgets 1131 /* Iterate desired glyph matrix of window here, hide gtk widgets
1247 // not in the desired matrix. 1132 not in the desired matrix.
1248 1133
1249 // This only takes care of xwidgets in active windows. If a window 1134 This only takes care of xwidgets in active windows. If a window
1250 // goes away from screen xwidget views wust be deleted 1135 goes away from screen xwidget views wust be deleted.
1251 1136
1252 // dump_glyph_matrix (matrix, 2); 1137 dump_glyph_matrix (matrix, 2); */
1253 for (i = 0; i < matrix->nrows; ++i) 1138 for (i = 0; i < matrix->nrows; ++i)
1254 { 1139 {
1255 // dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs); 1140 /* dump_glyph_row (MATRIX_ROW (matrix, i), i, glyphs); */
1256 struct glyph_row *row; 1141 struct glyph_row *row;
1257 row = MATRIX_ROW (matrix, i); 1142 row = MATRIX_ROW (matrix, i);
1258 if (row->enabled_p != 0) 1143 if (row->enabled_p)
1259 { 1144 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
1260 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) 1145 {
1261 { 1146 struct glyph *glyph = row->glyphs[area];
1262 struct glyph *glyph = row->glyphs[area]; 1147 struct glyph *glyph_end = glyph + row->used[area];
1263 struct glyph *glyph_end = glyph + row->used[area]; 1148 for (; glyph < glyph_end; ++glyph)
1264 for (; glyph < glyph_end; ++glyph) 1149 if (glyph->type == XWIDGET_GLYPH)
1265 { 1150 {
1266 if (glyph->type == XWIDGET_GLYPH) 1151 /* The only call to xwidget_end_redisplay is in dispnew.
1267 { 1152 xwidget_end_redisplay (w->current_matrix); */
1268 /* 1153 xwidget_touch (xwidget_view_lookup (glyph->u.xwidget, w));
1269 The only call to xwidget_end_redisplay is in dispnew 1154 }
1270 xwidget_end_redisplay (w->current_matrix); 1155 }
1271 */
1272 xwidget_touch (xwidget_view_lookup (glyph->u.xwidget,
1273 w));
1274 }
1275 }
1276 }
1277 }
1278 } 1156 }
1279 1157
1280 for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail); 1158 for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail);
@@ -1284,8 +1162,8 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix)
1284 { 1162 {
1285 struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail)); 1163 struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
1286 1164
1287 // "touched" is only meaningful for the current window, so 1165 /* "touched" is only meaningful for the current window, so
1288 // disregard other views. 1166 disregard other views. */
1289 if (XWINDOW (xv->w) == w) 1167 if (XWINDOW (xv->w) == w)
1290 { 1168 {
1291 if (xwidget_touched (xv)) 1169 if (xwidget_touched (xv))
@@ -1306,7 +1184,7 @@ kill_buffer_xwidgets (Lisp_Object buffer)
1306 { 1184 {
1307 xwidget = XCAR (tail); 1185 xwidget = XCAR (tail);
1308 Vxwidget_list = Fdelq (xwidget, Vxwidget_list); 1186 Vxwidget_list = Fdelq (xwidget, Vxwidget_list);
1309 /* TODO free the GTK things in xw */ 1187 /* TODO free the GTK things in xw. */
1310 { 1188 {
1311 CHECK_XWIDGET (xwidget); 1189 CHECK_XWIDGET (xwidget);
1312 struct xwidget *xw = XXWIDGET (xwidget); 1190 struct xwidget *xw = XXWIDGET (xwidget);
diff --git a/src/xwidget.h b/src/xwidget.h
index fdcf40d8cbb..1e11f110379 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -20,60 +20,62 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#ifndef XWIDGET_H_INCLUDED 20#ifndef XWIDGET_H_INCLUDED
21#define XWIDGET_H_INCLUDED 21#define XWIDGET_H_INCLUDED
22 22
23void x_draw_xwidget_glyph_string (struct glyph_string *s); 23#include "lisp.h"
24void syms_of_xwidget (void);
25
26//extern Lisp_Object Qxwidget;
27 24
25struct glyph_matrix;
26struct glyph_string;
27struct xwidget;
28struct xwidget_view;
29struct window;
28 30
29bool valid_xwidget_spec_p (Lisp_Object object); 31#ifdef HAVE_XWIDGETS
32# include <gtk/gtk.h>
30 33
31#include <gtk/gtk.h> 34struct xwidget
35{
36 struct vectorlike_header header;
32 37
38 /* Auxiliary data. */
39 Lisp_Object plist;
33 40
34/* 41 /* The widget type. */
35each xwidget instance/model is described by this struct. 42 Lisp_Object type;
36 43
37lisp pseudovector. 44 /* The buffer where the xwidget lives. */
45 Lisp_Object buffer;
38 46
47 /* A title used for button labels, for instance. */
48 Lisp_Object title;
39 49
40 */ 50 /* Here ends the Lisp part. "height" is the marker field. */
41struct xwidget
42{
43 struct vectorlike_header header;
44 Lisp_Object plist; //auxilliary data
45 Lisp_Object type; //the widget type
46 Lisp_Object buffer; //buffer where xwidget lives
47 Lisp_Object title; //a title that is used for button labels for instance
48 51
49 //here ends the lisp part.
50 //"height" is the marker field
51 int height; 52 int height;
52 int width; 53 int width;
53 54
54 //for offscreen widgets, unused if not osr 55 /* For offscreen widgets, unused if not osr. */
55 GtkWidget *widget_osr; 56 GtkWidget *widget_osr;
56 GtkWidget *widgetwindow_osr; 57 GtkWidget *widgetwindow_osr;
57 //this is used if the widget (webkit) is to be wrapped in a scrolled window, 58
59 /* Used if the widget (webkit) is to be wrapped in a scrolled window. */
58 GtkWidget *widgetscrolledwindow_osr; 60 GtkWidget *widgetscrolledwindow_osr;
59 /* Non-nil means kill silently if Emacs is exited. */
60 unsigned int kill_without_query:1;
61 61
62 /* Kill silently if Emacs is exited. */
63 bool_bf kill_without_query : 1;
62}; 64};
63 65
64
65//struct for each xwidget view
66struct xwidget_view 66struct xwidget_view
67{ 67{
68 struct vectorlike_header header; 68 struct vectorlike_header header;
69 Lisp_Object model; 69 Lisp_Object model;
70 Lisp_Object w; 70 Lisp_Object w;
71 71
72 //here ends the lisp part. 72 /* Here ends the lisp part. "redisplayed" is the marker field. */
73 //"redisplayed" is the marker field 73
74 int redisplayed; //if touched by redisplay 74 /* If touched by redisplay. */
75 bool redisplayed;
75 76
76 int hidden; //if the "live" instance isnt drawn 77 /* The "live" instance isn't drawn. */
78 bool hidden;
77 79
78 GtkWidget *widget; 80 GtkWidget *widget;
79 GtkWidget *widgetwindow; 81 GtkWidget *widgetwindow;
@@ -85,48 +87,47 @@ struct xwidget_view
85 int clip_top; 87 int clip_top;
86 int clip_left; 88 int clip_left;
87 89
88
89 long handler_id; 90 long handler_id;
90}; 91};
92#endif
91 93
92/* Test for xwidget pseudovector*/ 94/* Test for xwidget pseudovector. */
93#define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET) 95#define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
94#define XXWIDGET(a) (eassert (XWIDGETP(a)), \ 96#define XXWIDGET(a) (eassert (XWIDGETP (a)), \
95 (struct xwidget *) XUNTAG(a, Lisp_Vectorlike)) 97 (struct xwidget *) XUNTAG (a, Lisp_Vectorlike))
96 98
97#define CHECK_XWIDGET(x) \ 99#define CHECK_XWIDGET(x) \
98 CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x) 100 CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
99 101
100/* Test for xwidget_view pseudovector */ 102/* Test for xwidget_view pseudovector. */
101#define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW) 103#define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
102#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P(a)), \ 104#define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
103 (struct xwidget_view *) XUNTAG(a, Lisp_Vectorlike)) 105 (struct xwidget_view *) XUNTAG (a, Lisp_Vectorlike))
104 106
105#define CHECK_XWIDGET_VIEW(x) \ 107#define CHECK_XWIDGET_VIEW(x) \
106 CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x) 108 CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)
107 109
108struct xwidget_type
109{
110 /* A symbol uniquely identifying the xwidget type, */
111 Lisp_Object *type;
112
113 /* Check that SPEC is a valid image specification for the given
114 image type. Value is non-zero if SPEC is valid. */
115 int (*valid_p) (Lisp_Object spec);
116
117 /* Next in list of all supported image types. */
118 struct xwidget_type *next;
119};
120
121
122struct xwidget *xwidget_from_id (int id);
123
124void xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix);
125
126struct xwidget *lookup_xwidget (Lisp_Object spec);
127#define XG_XWIDGET "emacs_xwidget" 110#define XG_XWIDGET "emacs_xwidget"
128#define XG_XWIDGET_VIEW "emacs_xwidget_view" 111#define XG_XWIDGET_VIEW "emacs_xwidget_view"
129void xwidget_view_delete_all_in_window (struct window *w);
130 112
131void kill_buffer_xwidgets (Lisp_Object buffer); 113#ifdef HAVE_XWIDGETS
114void syms_of_xwidget (void);
115bool valid_xwidget_spec_p (Lisp_Object);
116void xwidget_view_delete_all_in_window (struct window *);
117void x_draw_xwidget_glyph_string (struct glyph_string *);
118struct xwidget *lookup_xwidget (Lisp_Object spec);
119void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
120void kill_buffer_xwidgets (Lisp_Object);
121#else
122INLINE_HEADER_BEGIN
123INLINE void syms_of_xwidget (void) {}
124INLINE bool valid_xwidget_spec_p (Lisp_Object obj) { return false; }
125INLINE void xwidget_view_delete_all_in_window (struct window *w) {}
126INLINE void x_draw_xwidget_glyph_string (struct glyph_string *s) { eassume (0); }
127INLINE struct xwidget *lookup_xwidget (Lisp_Object obj) { eassume (0); }
128INLINE void xwidget_end_redisplay (struct window *w, struct glyph_matrix *m) {}
129INLINE void kill_buffer_xwidgets (Lisp_Object buf) {}
130INLINE_HEADER_END
131#endif
132
132#endif /* XWIDGET_H_INCLUDED */ 133#endif /* XWIDGET_H_INCLUDED */