aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNoah Friedman2019-08-08 23:17:56 -0700
committerNoah Friedman2019-08-08 23:17:56 -0700
commitd6713add69c7a696627e68e2b84c4aa7aaf05000 (patch)
tree44c404404f70830a5bef0920c6eb1b940007cdd5 /src
parent5a904c477be1787057965bdff023d9d9d89d9870 (diff)
downloademacs-d6713add69c7a696627e68e2b84c4aa7aaf05000.tar.gz
emacs-d6713add69c7a696627e68e2b84c4aa7aaf05000.zip
Provide better target window consistency across x window property functions.
Use the argument name WINDOW-ID instead of SOURCE for same. Revise docstrings to clarify semantics of FRAME and WINDOW-ID. (Fx_change_window_property): Use `target_window' instead of `w'. This is consistent with other related functions. Finalize its value before blocking input. (Fx_window_property): (Fx_window_property_attributes): Use `window_id' instead of `source'. (Fx_delete_window_property): New optional arg window_id.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c109
1 files changed, 68 insertions, 41 deletions
diff --git a/src/xfns.c b/src/xfns.c
index bc3490d59bf..dfb48dd3a4d 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5730,14 +5730,17 @@ top bits and the cdr is the lower 16 bits.
5730 5730
5731FRAME nil or omitted means use the selected frame. 5731FRAME nil or omitted means use the selected frame.
5732If TYPE is given and non-nil, it is the name of the type of VALUE. 5732If TYPE is given and non-nil, it is the name of the type of VALUE.
5733If TYPE is not given or nil, the type is STRING. 5733 If TYPE is not given or nil, the type is STRING.
5734FORMAT gives the size in bits of each element if VALUE is a list. 5734FORMAT gives the size in bits of each element if VALUE is a list.
5735It must be one of 8, 16 or 32. 5735 It must be one of 8, 16 or 32.
5736If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8. 5736 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
5737If OUTER-P is non-nil, the property is changed for the outer X window of 5737If OUTER-P is non-nil, the property is changed for the outer X window of
5738FRAME. Default is to change on the edit X window. 5738 FRAME. Default is to change on the edit X window.
5739If WINDOW-ID is non-nil, set the property on that window instead of FRAME. 5739If WINDOW-ID is non-nil, change the property of that window instead
5740The number 0 denotes the root window. */) 5740 of FRAME; the number 0 denotes the root window. This argument is
5741 separate from FRAME because window IDs are not unique across X
5742 displays or screens on the same display, so FRAME provides context
5743 for the window ID. */)
5741 (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, 5744 (Lisp_Object prop, Lisp_Object value, Lisp_Object frame,
5742 Lisp_Object type, Lisp_Object format, Lisp_Object outer_p, 5745 Lisp_Object type, Lisp_Object format, Lisp_Object outer_p,
5743 Lisp_Object window_id) 5746 Lisp_Object window_id)
@@ -5748,7 +5751,7 @@ The number 0 denotes the root window. */)
5748 int element_format = 8; 5751 int element_format = 8;
5749 unsigned char *data; 5752 unsigned char *data;
5750 int nelements; 5753 int nelements;
5751 Window w; 5754 Window target_window;
5752 5755
5753 CHECK_STRING (prop); 5756 CHECK_STRING (prop);
5754 5757
@@ -5796,6 +5799,20 @@ The number 0 denotes the root window. */)
5796 nelements = SBYTES (value) / elsize; 5799 nelements = SBYTES (value) / elsize;
5797 } 5800 }
5798 5801
5802 if (! NILP (window_id))
5803 {
5804 CONS_TO_INTEGER (window_id, Window, target_window);
5805 if (! target_window)
5806 target_window = FRAME_DISPLAY_INFO (f)->root_window;
5807 }
5808 else
5809 {
5810 if (! NILP (outer_p))
5811 target_window = FRAME_OUTER_WINDOW (f);
5812 else
5813 target_window = FRAME_X_WINDOW (f);
5814 }
5815
5799 block_input (); 5816 block_input ();
5800 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); 5817 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
5801 if (! NILP (type)) 5818 if (! NILP (type))
@@ -5804,19 +5821,7 @@ The number 0 denotes the root window. */)
5804 target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False); 5821 target_type = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (type), False);
5805 } 5822 }
5806 5823
5807 if (! NILP (window_id)) 5824 XChangeProperty (FRAME_X_DISPLAY (f), target_window,
5808 {
5809 CONS_TO_INTEGER (window_id, Window, w);
5810 if (! w)
5811 w = FRAME_DISPLAY_INFO (f)->root_window;
5812 }
5813 else
5814 {
5815 if (! NILP (outer_p)) w = FRAME_OUTER_WINDOW (f);
5816 else w = FRAME_X_WINDOW (f);
5817 }
5818
5819 XChangeProperty (FRAME_X_DISPLAY (f), w,
5820 prop_atom, target_type, element_format, PropModeReplace, 5825 prop_atom, target_type, element_format, PropModeReplace,
5821 data, nelements); 5826 data, nelements);
5822 5827
@@ -5831,18 +5836,34 @@ The number 0 denotes the root window. */)
5831 5836
5832 5837
5833DEFUN ("x-delete-window-property", Fx_delete_window_property, 5838DEFUN ("x-delete-window-property", Fx_delete_window_property,
5834 Sx_delete_window_property, 1, 2, 0, 5839 Sx_delete_window_property, 1, 3, 0,
5835 doc: /* Remove window property PROP from X window of FRAME. 5840 doc: /* Remove window property PROP from X window of FRAME.
5836FRAME nil or omitted means use the selected frame. Value is PROP. */) 5841FRAME nil or omitted means use the selected frame.
5837 (Lisp_Object prop, Lisp_Object frame) 5842If WINDOW-ID is non-nil, remove property from that window instead
5843 of FRAME; the number 0 denotes the root window. This argument is
5844 separate from FRAME because window IDs are not unique across X
5845 displays or screens on the same display, so FRAME provides context
5846 for the window ID.
5847
5848Return value is PROP. */)
5849 (Lisp_Object prop, Lisp_Object frame, Lisp_Object window_id)
5838{ 5850{
5839 struct frame *f = decode_window_system_frame (frame); 5851 struct frame *f = decode_window_system_frame (frame);
5852 Window target_window = FRAME_X_WINDOW (f);
5840 Atom prop_atom; 5853 Atom prop_atom;
5841 5854
5842 CHECK_STRING (prop); 5855 CHECK_STRING (prop);
5856
5857 if (! NILP (window_id))
5858 {
5859 CONS_TO_INTEGER (window_id, Window, target_window);
5860 if (! target_window)
5861 target_window = FRAME_DISPLAY_INFO (f)->root_window;
5862 }
5863
5843 block_input (); 5864 block_input ();
5844 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); 5865 prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False);
5845 XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom); 5866 XDeleteProperty (FRAME_X_DISPLAY (f), target_window, prop_atom);
5846 5867
5847 /* Make sure the property is removed when we return. */ 5868 /* Make sure the property is removed when we return. */
5848 XFlush (FRAME_X_DISPLAY (f)); 5869 XFlush (FRAME_X_DISPLAY (f));
@@ -5936,16 +5957,19 @@ If FRAME is nil or omitted, use the selected frame.
5936 5957
5937On X Windows, the following optional arguments are also accepted: 5958On X Windows, the following optional arguments are also accepted:
5938If TYPE is nil or omitted, get the property as a string. 5959If TYPE is nil or omitted, get the property as a string.
5939Otherwise TYPE is the name of the atom that denotes the type expected. 5960 Otherwise TYPE is the name of the atom that denotes the type expected.
5940If SOURCE is non-nil, get the property on that window instead of from 5961If WINDOW-ID is non-nil, get the property of that window instead of
5941FRAME. The number 0 denotes the root window. 5962 FRAME; the number 0 denotes the root window. This argument is
5963 separate from FRAME because window IDs are not unique across X
5964 displays or screens on the same display, so FRAME provides context
5965 for the window ID.
5942If DELETE-P is non-nil, delete the property after retrieving it. 5966If DELETE-P is non-nil, delete the property after retrieving it.
5943If VECTOR-RET-P is non-nil, don't return a string but a vector of values. 5967If VECTOR-RET-P is non-nil, don't return a string but a vector of values.
5944 5968
5945Value is nil if FRAME hasn't a property with name PROP or if PROP has 5969Return value is nil if FRAME doesn't have a property with name PROP or
5946no value of TYPE (always string in the MS Windows case). */) 5970if PROP has no value of TYPE (always string in the MS Windows case). */)
5947 (Lisp_Object prop, Lisp_Object frame, Lisp_Object type, 5971 (Lisp_Object prop, Lisp_Object frame, Lisp_Object type,
5948 Lisp_Object source, Lisp_Object delete_p, Lisp_Object vector_ret_p) 5972 Lisp_Object window_id, Lisp_Object delete_p, Lisp_Object vector_ret_p)
5949{ 5973{
5950 struct frame *f = decode_window_system_frame (frame); 5974 struct frame *f = decode_window_system_frame (frame);
5951 Atom prop_atom; 5975 Atom prop_atom;
@@ -5956,11 +5980,11 @@ no value of TYPE (always string in the MS Windows case). */)
5956 5980
5957 CHECK_STRING (prop); 5981 CHECK_STRING (prop);
5958 5982
5959 if (! NILP (source)) 5983 if (! NILP (window_id))
5960 { 5984 {
5961 CONS_TO_INTEGER (source, Window, target_window); 5985 CONS_TO_INTEGER (window_id, Window, target_window);
5962 if (! target_window) 5986 if (! target_window)
5963 target_window = FRAME_DISPLAY_INFO (f)->root_window; 5987 target_window = FRAME_DISPLAY_INFO (f)->root_window;
5964 } 5988 }
5965 5989
5966 block_input (); 5990 block_input ();
@@ -5982,7 +6006,7 @@ no value of TYPE (always string in the MS Windows case). */)
5982 &found); 6006 &found);
5983 if (NILP (prop_value) 6007 if (NILP (prop_value)
5984 && ! found 6008 && ! found
5985 && NILP (source) 6009 && NILP (window_id)
5986 && target_window != FRAME_OUTER_WINDOW (f)) 6010 && target_window != FRAME_OUTER_WINDOW (f))
5987 { 6011 {
5988 prop_value = x_window_property_intern (f, 6012 prop_value = x_window_property_intern (f,
@@ -6003,17 +6027,20 @@ DEFUN ("x-window-property-attributes", Fx_window_property_attributes, Sx_window_
6003 1, 3, 0, 6027 1, 3, 0,
6004 doc: /* Retrieve metadata about window property PROP on FRAME. 6028 doc: /* Retrieve metadata about window property PROP on FRAME.
6005If FRAME is nil or omitted, use the selected frame. 6029If FRAME is nil or omitted, use the selected frame.
6006If SOURCE is non-nil, get the property on that window instead of from 6030If WINDOW-ID is non-nil, get the property of that window instead of
6007FRAME. The number 0 denotes the root window. 6031 FRAME; the number 0 denotes the root window. This argument is
6032 separate from FRAME because window IDs are not unique across X
6033 displays or screens on the same display, so FRAME provides context
6034 for the window ID.
6008 6035
6009Return value is nil if FRAME hasn't a property with name PROP. 6036Return value is nil if FRAME doesn't have a property with name PROP.
6010Otherwise, the return value is a vector with the following fields: 6037Otherwise, the return value is a vector with the following fields:
6011 6038
60120. The property type, as an integer. The symbolic name of 60390. The property type, as an integer. The symbolic name of
6013 the type can be obtained with `x-get-atom-name'. 6040 the type can be obtained with `x-get-atom-name'.
60141. The format of each element; one of 8, 16, or 32. 60411. The format of each element; one of 8, 16, or 32.
60152. The length of the property, in number of elements. */) 60422. The length of the property, in number of elements. */)
6016 (Lisp_Object prop, Lisp_Object frame, Lisp_Object source) 6043 (Lisp_Object prop, Lisp_Object frame, Lisp_Object window_id)
6017{ 6044{
6018 struct frame *f = decode_window_system_frame (frame); 6045 struct frame *f = decode_window_system_frame (frame);
6019 Window target_window = FRAME_X_WINDOW (f); 6046 Window target_window = FRAME_X_WINDOW (f);
@@ -6027,9 +6054,9 @@ Otherwise, the return value is a vector with the following fields:
6027 6054
6028 CHECK_STRING (prop); 6055 CHECK_STRING (prop);
6029 6056
6030 if (! NILP (source)) 6057 if (! NILP (window_id))
6031 { 6058 {
6032 CONS_TO_INTEGER (source, Window, target_window); 6059 CONS_TO_INTEGER (window_id, Window, target_window);
6033 if (! target_window) 6060 if (! target_window)
6034 target_window = FRAME_DISPLAY_INFO (f)->root_window; 6061 target_window = FRAME_DISPLAY_INFO (f)->root_window;
6035 } 6062 }
@@ -6043,7 +6070,7 @@ Otherwise, the return value is a vector with the following fields:
6043 &bytes_remaining, &tmp_data); 6070 &bytes_remaining, &tmp_data);
6044 if (rc == Success /* no invalid params */ 6071 if (rc == Success /* no invalid params */
6045 && actual_format == 0 /* but prop not found */ 6072 && actual_format == 0 /* but prop not found */
6046 && NILP (source) 6073 && NILP (window_id)
6047 && target_window != FRAME_OUTER_WINDOW (f)) 6074 && target_window != FRAME_OUTER_WINDOW (f))
6048 { 6075 {
6049 /* analogous behavior to x-window-property: if property isn't found 6076 /* analogous behavior to x-window-property: if property isn't found