diff options
| author | Jan Djärv | 2014-05-24 10:41:19 +0200 |
|---|---|---|
| committer | Jan Djärv | 2014-05-24 10:41:19 +0200 |
| commit | a235163a6908136abd3f4574caf6e8b9a0c7dcf9 (patch) | |
| tree | 0d385b569bd5b4e550f3cf8c72a3c50454175012 /src | |
| parent | e4829cb8d789abc8ac72080ba412f90328e44990 (diff) | |
| download | emacs-a235163a6908136abd3f4574caf6e8b9a0c7dcf9.tar.gz emacs-a235163a6908136abd3f4574caf6e8b9a0c7dcf9.zip | |
* xfns.c (x_window_property_intern): New function (code from
x_window_property).
(Fx_window_property): Call x_window_property_intern. If property
not found and NILP (source) and outer window != inner window,
check outer window for property.
Fixes: debbugs:17537
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/xfns.c | 147 |
2 files changed, 103 insertions, 52 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5c3486d131a..7f83681e0a3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2014-05-24 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xfns.c (x_window_property_intern): New function (code from | ||
| 4 | x_window_property). | ||
| 5 | (Fx_window_property): Call x_window_property_intern. If property | ||
| 6 | not found and NILP (source) and outer window != inner window, | ||
| 7 | check outer window for property (Bug#17537). | ||
| 8 | |||
| 1 | 2014-05-22 Paul Eggert <eggert@cs.ucla.edu> | 9 | 2014-05-22 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 10 | ||
| 3 | Supply malloc and alloc_size attributes for extern allocators. | 11 | Supply malloc and alloc_size attributes for extern allocators. |
diff --git a/src/xfns.c b/src/xfns.c index 8e00a1cfbd6..81496f35bfc 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -4550,75 +4550,43 @@ FRAME nil or omitted means use the selected frame. Value is PROP. */) | |||
| 4550 | } | 4550 | } |
| 4551 | 4551 | ||
| 4552 | 4552 | ||
| 4553 | DEFUN ("x-window-property", Fx_window_property, Sx_window_property, | 4553 | static Lisp_Object |
| 4554 | 1, 6, 0, | 4554 | x_window_property_intern (struct frame *f, |
| 4555 | doc: /* Value is the value of window property PROP on FRAME. | 4555 | Window target_window, |
| 4556 | If FRAME is nil or omitted, use the selected frame. | 4556 | Atom prop_atom, |
| 4557 | 4557 | Atom target_type, | |
| 4558 | On X Windows, the following optional arguments are also accepted: | 4558 | Lisp_Object delete_p, |
| 4559 | If TYPE is nil or omitted, get the property as a string. | 4559 | Lisp_Object vector_ret_p, |
| 4560 | Otherwise TYPE is the name of the atom that denotes the type expected. | 4560 | bool *found) |
| 4561 | If SOURCE is non-nil, get the property on that window instead of from | ||
| 4562 | FRAME. The number 0 denotes the root window. | ||
| 4563 | If DELETE-P is non-nil, delete the property after retrieving it. | ||
| 4564 | If VECTOR-RET-P is non-nil, don't return a string but a vector of values. | ||
| 4565 | |||
| 4566 | On MS Windows, this function accepts but ignores those optional arguments. | ||
| 4567 | |||
| 4568 | Value is nil if FRAME hasn't a property with name PROP or if PROP has | ||
| 4569 | no value of TYPE (always string in the MS Windows case). */) | ||
| 4570 | (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, | ||
| 4571 | Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p) | ||
| 4572 | { | 4561 | { |
| 4573 | struct frame *f = decode_window_system_frame (frame); | ||
| 4574 | Atom prop_atom; | ||
| 4575 | int rc; | ||
| 4576 | Lisp_Object prop_value = Qnil; | ||
| 4577 | unsigned char *tmp_data = NULL; | 4562 | unsigned char *tmp_data = NULL; |
| 4563 | Lisp_Object prop_value = Qnil; | ||
| 4578 | Atom actual_type; | 4564 | Atom actual_type; |
| 4579 | Atom target_type = XA_STRING; | ||
| 4580 | int actual_format; | 4565 | int actual_format; |
| 4581 | unsigned long actual_size, bytes_remaining; | 4566 | unsigned long actual_size, bytes_remaining; |
| 4582 | Window target_window = FRAME_X_WINDOW (f); | 4567 | int rc; |
| 4583 | struct gcpro gcpro1; | 4568 | struct gcpro gcpro1; |
| 4584 | 4569 | ||
| 4585 | GCPRO1 (prop_value); | 4570 | GCPRO1 (prop_value); |
| 4586 | CHECK_STRING (prop); | ||
| 4587 | |||
| 4588 | if (! NILP (source)) | ||
| 4589 | { | ||
| 4590 | CONS_TO_INTEGER (source, Window, target_window); | ||
| 4591 | if (! target_window) | ||
| 4592 | target_window = FRAME_DISPLAY_INFO (f)->root_window; | ||
| 4593 | } | ||
| 4594 | |||
| 4595 | block_input (); | ||
| 4596 | if (STRINGP (type)) | ||
| 4597 | { | ||
| 4598 | if (strcmp ("AnyPropertyType", SSDATA (type)) == 0) | ||
| 4599 | target_type = AnyPropertyType; | ||
| 4600 | else | ||
| 4601 | target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False); | ||
| 4602 | } | ||
| 4603 | 4571 | ||
| 4604 | prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); | ||
| 4605 | rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, | 4572 | rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, |
| 4606 | prop_atom, 0, 0, False, target_type, | 4573 | prop_atom, 0, 0, False, target_type, |
| 4607 | &actual_type, &actual_format, &actual_size, | 4574 | &actual_type, &actual_format, &actual_size, |
| 4608 | &bytes_remaining, &tmp_data); | 4575 | &bytes_remaining, &tmp_data); |
| 4609 | if (rc == Success) | ||
| 4610 | { | ||
| 4611 | int size = bytes_remaining; | ||
| 4612 | 4576 | ||
| 4577 | *found = actual_format != 0; | ||
| 4578 | |||
| 4579 | if (rc == Success && *found) | ||
| 4580 | { | ||
| 4613 | XFree (tmp_data); | 4581 | XFree (tmp_data); |
| 4614 | tmp_data = NULL; | 4582 | tmp_data = NULL; |
| 4615 | 4583 | ||
| 4616 | rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, | 4584 | rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, |
| 4617 | prop_atom, 0, bytes_remaining, | 4585 | prop_atom, 0, bytes_remaining, |
| 4618 | ! NILP (delete_p), target_type, | 4586 | ! NILP (delete_p), target_type, |
| 4619 | &actual_type, &actual_format, | 4587 | &actual_type, &actual_format, |
| 4620 | &actual_size, &bytes_remaining, | 4588 | &actual_size, &bytes_remaining, |
| 4621 | &tmp_data); | 4589 | &tmp_data); |
| 4622 | if (rc == Success && tmp_data) | 4590 | if (rc == Success && tmp_data) |
| 4623 | { | 4591 | { |
| 4624 | /* The man page for XGetWindowProperty says: | 4592 | /* The man page for XGetWindowProperty says: |
| @@ -4646,7 +4614,7 @@ no value of TYPE (always string in the MS Windows case). */) | |||
| 4646 | } | 4614 | } |
| 4647 | 4615 | ||
| 4648 | if (NILP (vector_ret_p)) | 4616 | if (NILP (vector_ret_p)) |
| 4649 | prop_value = make_string ((char *) tmp_data, size); | 4617 | prop_value = make_string ((char *) tmp_data, actual_size); |
| 4650 | else | 4618 | else |
| 4651 | prop_value = x_property_data_to_lisp (f, | 4619 | prop_value = x_property_data_to_lisp (f, |
| 4652 | tmp_data, | 4620 | tmp_data, |
| @@ -4658,6 +4626,81 @@ no value of TYPE (always string in the MS Windows case). */) | |||
| 4658 | if (tmp_data) XFree (tmp_data); | 4626 | if (tmp_data) XFree (tmp_data); |
| 4659 | } | 4627 | } |
| 4660 | 4628 | ||
| 4629 | UNGCPRO; | ||
| 4630 | return prop_value; | ||
| 4631 | } | ||
| 4632 | |||
| 4633 | DEFUN ("x-window-property", Fx_window_property, Sx_window_property, | ||
| 4634 | 1, 6, 0, | ||
| 4635 | doc: /* Value is the value of window property PROP on FRAME. | ||
| 4636 | If FRAME is nil or omitted, use the selected frame. | ||
| 4637 | |||
| 4638 | On X Windows, the following optional arguments are also accepted: | ||
| 4639 | If TYPE is nil or omitted, get the property as a string. | ||
| 4640 | Otherwise TYPE is the name of the atom that denotes the type expected. | ||
| 4641 | If SOURCE is non-nil, get the property on that window instead of from | ||
| 4642 | FRAME. The number 0 denotes the root window. | ||
| 4643 | If DELETE-P is non-nil, delete the property after retrieving it. | ||
| 4644 | If VECTOR-RET-P is non-nil, don't return a string but a vector of values. | ||
| 4645 | |||
| 4646 | On MS Windows, this function accepts but ignores those optional arguments. | ||
| 4647 | |||
| 4648 | Value is nil if FRAME hasn't a property with name PROP or if PROP has | ||
| 4649 | no value of TYPE (always string in the MS Windows case). */) | ||
| 4650 | (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, | ||
| 4651 | Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p) | ||
| 4652 | { | ||
| 4653 | struct frame *f = decode_window_system_frame (frame); | ||
| 4654 | Atom prop_atom; | ||
| 4655 | int rc; | ||
| 4656 | Lisp_Object prop_value = Qnil; | ||
| 4657 | Atom target_type = XA_STRING; | ||
| 4658 | Window target_window = FRAME_X_WINDOW (f); | ||
| 4659 | struct gcpro gcpro1; | ||
| 4660 | bool found; | ||
| 4661 | |||
| 4662 | GCPRO1 (prop_value); | ||
| 4663 | CHECK_STRING (prop); | ||
| 4664 | |||
| 4665 | if (! NILP (source)) | ||
| 4666 | { | ||
| 4667 | CONS_TO_INTEGER (source, Window, target_window); | ||
| 4668 | if (! target_window) | ||
| 4669 | target_window = FRAME_DISPLAY_INFO (f)->root_window; | ||
| 4670 | } | ||
| 4671 | |||
| 4672 | block_input (); | ||
| 4673 | if (STRINGP (type)) | ||
| 4674 | { | ||
| 4675 | if (strcmp ("AnyPropertyType", SSDATA (type)) == 0) | ||
| 4676 | target_type = AnyPropertyType; | ||
| 4677 | else | ||
| 4678 | target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False); | ||
| 4679 | } | ||
| 4680 | |||
| 4681 | prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); | ||
| 4682 | prop_value = x_window_property_intern (f, | ||
| 4683 | target_window, | ||
| 4684 | prop_atom, | ||
| 4685 | target_type, | ||
| 4686 | delete_p, | ||
| 4687 | vector_ret_p, | ||
| 4688 | &found); | ||
| 4689 | if (NILP (prop_value) | ||
| 4690 | && ! found | ||
| 4691 | && NILP (source) | ||
| 4692 | && target_window != FRAME_OUTER_WINDOW (f)) | ||
| 4693 | { | ||
| 4694 | prop_value = x_window_property_intern (f, | ||
| 4695 | FRAME_OUTER_WINDOW (f), | ||
| 4696 | prop_atom, | ||
| 4697 | target_type, | ||
| 4698 | delete_p, | ||
| 4699 | vector_ret_p, | ||
| 4700 | &found); | ||
| 4701 | } | ||
| 4702 | |||
| 4703 | |||
| 4661 | unblock_input (); | 4704 | unblock_input (); |
| 4662 | UNGCPRO; | 4705 | UNGCPRO; |
| 4663 | return prop_value; | 4706 | return prop_value; |