CVS: sml-dist/src/eXene/lib/iccc property-sig.sml,1.2,1.3 property.sml,1.2,1.3

Matthias Blume <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj.commits
Message-ID <[email protected]>
Update of /cvsroot/smlnj/sml-dist/src/eXene/lib/iccc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32471/lib/iccc

Modified Files:
	property-sig.sml property.sml 
Log Message:
merge Kansas changes to eXene into repository

Index: property-sig.sml
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/eXene/lib/iccc/property-sig.sml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** property-sig.sml	1 Jun 2000 18:33:39 -0000	1.2
--- property-sig.sml	3 Mar 2006 03:33:15 -0000	1.3
***************
*** 14,19 ****
      datatype raw_format = Raw8 | Raw16 | Raw32
      datatype raw_data = RAW_DATA of {
! 	format : raw_format,
! 	data : Word8Vector.vector
        }
  
--- 14,19 ----
      datatype raw_format = Raw8 | Raw16 | Raw32
      datatype raw_data = RAW_DATA of {
!     format : raw_format,
!     data : Word8Vector.vector
        }
  
***************
*** 23,34 ****
     *)
      datatype prop_val = PROP_VAL of {
! 	typ : atom,
! 	value : raw_data
        }
  
      exception PropAlloc
! 	(* raised, if there is not enough space to store a property value
! 	 * on the server.
! 	 *)
  
    (* an abstract interface to a property on a window *)
--- 23,34 ----
     *)
      datatype prop_val = PROP_VAL of {
!     typ : atom,
!     value : raw_data
        }
  
      exception PropAlloc
!     (* raised, if there is not enough space to store a property value
!      * on the server.
!      *)
  
    (* an abstract interface to a property on a window *)
***************
*** 36,93 ****
  
      val property : (Window.window * atom) -> property
! 	(* return the abstract representation of the named property on
! 	 * the specified window.
! 	 *)
  
      val unusedProperty : Window.window -> property
! 	(* generate a property on the specified window that is guaranteed
! 	 * to be unused.  Note that once this property has been "deleted"
! 	 * its name may be reused.
! 	 * NOTE: eventually, properties will be finalized, but for the
! 	 * time being, programs should delete any allocated properties they
! 	 * are not using.
! 	 *)
  
      val mkProperty : (Window.window * prop_val) -> property
! 	(* create a new property initialized to the given value *)
  
      val nameOfProp : property -> atom
! 	(* return the atom that names the given property *)
  
      val setProperty : (property * prop_val) -> unit
! 	(* set the value of the property *)
  
      val appendToProperty : (property * prop_val) -> unit
! 	(* append the property value to the property; the types
! 	 * and formats must match.
! 	 *)
  
      val prependToProperty : (property * prop_val) -> unit
! 	(* prepend the property value to the property; the types
! 	 * and formats must match.
! 	 *)
  
      val deleteProperty : property -> unit
! 	(* delete the named property *)
  
      exception RotateProps
      val rotateProperties : (property list * int) -> unit
! 	(* rotate the list of properties; raises RotateProps if the
! 	 * properties do not belong to the same window.
! 	 *)
  
      val getProperty : property -> prop_val option
! 	(* get the value of the property; if the property has not been
! 	 * set, then NONE is returned.
! 	 *)
  
      datatype prop_change = NewValue | Deleted
  
      val watchProperty : property -> (prop_change * XTime.time) CML.event
! 	(* returns an event for monitoring changes to a property's
! 	 * state.  Note that once a property has been deleted, there
! 	 * will be no more events, unless watchProperty is called again.
! 	 *)
  
    end;
  
--- 36,106 ----
  
      val property : (Window.window * atom) -> property
!     (* return the abstract representation of the named property on
!      * the specified window.
!      *)
  
      val unusedProperty : Window.window -> property
!     (* generate a property on the specified window that is guaranteed
!      * to be unused.  Note that once this property has been "deleted"
!      * its name may be reused.
!      * NOTE: eventually, properties will be finalized, but for the
!      * time being, programs should delete any allocated properties they
!      * are not using.
!      *)
  
      val mkProperty : (Window.window * prop_val) -> property
!     (* create a new property initialized to the given value *)
  
      val nameOfProp : property -> atom
!     (* return the atom that names the given property *)
  
      val setProperty : (property * prop_val) -> unit
!     (* set the value of the property *)
  
      val appendToProperty : (property * prop_val) -> unit
!     (* append the property value to the property; the types
!      * and formats must match.
!      *)
  
      val prependToProperty : (property * prop_val) -> unit
!     (* prepend the property value to the property; the types
!      * and formats must match.
!      *)
  
      val deleteProperty : property -> unit
!     (* delete the named property *)
  
      exception RotateProps
      val rotateProperties : (property list * int) -> unit
!     (* rotate the list of properties; raises RotateProps if the
!      * properties do not belong to the same window.
!      *)
  
      val getProperty : property -> prop_val option
!     (* get the value of the property; if the property has not been
!      * set, then NONE is returned.
!      *)
  
      datatype prop_change = NewValue | Deleted
  
      val watchProperty : property -> (prop_change * XTime.time) CML.event
!     (* returns an event for monitoring changes to a property's
!      * state.  Note that once a property has been deleted, there
!      * will be no more events, unless watchProperty is called again.
!      *)
  
+     (* Additions by ddeboer, May 2004. 
+      * Dusty deBoer, KSU CIS 705, Spring 2004. *)
+      
+     (* xrdbOfScr: return the list of strings contained in the
+      * XA_RESOURCE_MANAGER property of the root screen of the
+      * specified screen. 
+      * This should properly belong some other place than in ICCC,
+      * as it has nothing to do with ICCC, except that it accesses
+      * data in the screen type, and uses the GetProperty functions
+      * of ICCC.
+      *)
+     val xrdbOfScr    : Display.screen -> string list
+     (* end additions by ddeboer. *)
    end;
  

Index: property.sml
===================================================================
RCS file: /cvsroot/smlnj/sml-dist/src/eXene/lib/iccc/property.sml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** property.sml	1 Jun 2000 18:33:39 -0000	1.2
--- property.sml	3 Mar 2006 03:33:15 -0000	1.3
***************
*** 33,66 ****
   (* Various protocol requests that we need *)
      val reqGetProperty = query (
! 	  XRequest.encodeGetProperty, XReply.decodeGetPropertyReply)
      fun rotateProps dpy arg =
! 	  Dpy.dpyRequest dpy (XRequest.encodeRotateProperties arg)
      fun deleteProp dpy arg =
! 	  Dpy.dpyRequest dpy (XRequest.encodeDeleteProperty arg)
      fun changeProperty dpy arg = let
! 	  val ack = Dpy.dpyRequestAndChk dpy (XRequest.encodeChangeProperty arg)
! 	  in
! 	    (CML.sync ack)
! 	      handle XIo.ErrorReply(XErr.XErr{kind=XErr.BadAlloc, ...}) =>
! 			raise PropAlloc
! 		   | ex => raise ex
! 	  end
  
      structure XTy' : sig
! 	type atom
        (* raw data from server (in ClientMessage, property values, ...) *)
! 	datatype raw_format = Raw8 | Raw16 | Raw32
! 	datatype raw_data = RAW_DATA of {
! 	    format : raw_format,
! 	    data : Word8Vector.vector
! 	  }
        (* X property values.  A property value has a name and type, which are atoms,
         * and a value.  The value is a sequence of 8, 16 or 32-bit items, represented
         * as a format and a string.
         *)
! 	datatype prop_val = PROP_VAL of {
! 	    typ : atom,
! 	    value : raw_data
! 	  }
        end = XTy;
      open XTy
--- 33,66 ----
   (* Various protocol requests that we need *)
      val reqGetProperty = query (
!       XRequest.encodeGetProperty, XReply.decodeGetPropertyReply)
      fun rotateProps dpy arg =
!       Dpy.dpyRequest dpy (XRequest.encodeRotateProperties arg)
      fun deleteProp dpy arg =
!       Dpy.dpyRequest dpy (XRequest.encodeDeleteProperty arg)
      fun changeProperty dpy arg = let
!       val ack = Dpy.dpyRequestAndChk dpy (XRequest.encodeChangeProperty arg)
!       in
!         (CML.sync ack)
!           handle XIo.ErrorReply(XErr.XErr{kind=XErr.BadAlloc, ...}) =>
!             raise PropAlloc
!            | ex => raise ex
!       end
  
      structure XTy' : sig
!     type atom
        (* raw data from server (in ClientMessage, property values, ...) *)
!     datatype raw_format = Raw8 | Raw16 | Raw32
!     datatype raw_data = RAW_DATA of {
!         format : raw_format,
!         data : Word8Vector.vector
!       }
        (* X property values.  A property value has a name and type, which are atoms,
         * and a value.  The value is a sequence of 8, 16 or 32-bit items, represented
         * as a format and a string.
         *)
!     datatype prop_val = PROP_VAL of {
!         typ : atom,
!         value : raw_data
!       }
        end = XTy;
      open XTy
***************
*** 68,75 ****
    (* an abstract interface to a property on a window *)
      datatype property = PROP of {
! 	dpy : Dpy.display,
! 	name : atom,
! 	window : XTy.win_id,
! 	is_unique : bool
        }
  
--- 68,75 ----
    (* an abstract interface to a property on a window *)
      datatype property = PROP of {
!     dpy : Dpy.display,
!     name : atom,
!     window : XTy.win_id,
!     is_unique : bool
        }
  
***************
*** 82,86 ****
    (* get the display, window id and atom from a property *)
      fun infoOfProp (PROP{dpy, name, window, ...}) =
! 	  (dpy, window, name)
  
    (* return the abstract representation of the named property on
--- 82,86 ----
    (* get the display, window id and atom from a property *)
      fun infoOfProp (PROP{dpy, name, window, ...}) =
!       (dpy, window, name)
  
    (* return the abstract representation of the named property on
***************
*** 88,95 ****
     *)
      fun property (win, name) = let
! 	  val (dpy, winId) = infoOfWin win
! 	  in
! 	    PROP{dpy=dpy, name=name, window=winId, is_unique=false}
! 	  end
  
    (* generate a property on the specified window that is guaranteed
--- 88,95 ----
     *)
      fun property (win, name) = let
!       val (dpy, winId) = infoOfWin win
!       in
!         PROP{dpy=dpy, name=name, window=winId, is_unique=false}
!       end
  
    (* generate a property on the specified window that is guaranteed
***************
*** 97,105 ****
     *)
      fun unusedProperty win = let
! 	  val (dpy, winId) = infoOfWin win
! 	  val propName = PropS.unusedProperty (propServer dpy, winId)
! 	  in
! 	    PROP{dpy=dpy, name=propName, window=winId, is_unique=true}
! 	  end
  
    (* return the atom that names the given property *)
--- 97,105 ----
     *)
      fun unusedProperty win = let
!       val (dpy, winId) = infoOfWin win
!       val propName = PropS.unusedProperty (propServer dpy, winId)
!       in
!         PROP{dpy=dpy, name=propName, window=winId, is_unique=true}
!       end
  
    (* return the atom that names the given property *)
***************
*** 108,115 ****
    (* update a proiperty *)
      fun updateProp mode (prop, value) = let
! 	  val (dpy, winId, name) = infoOfProp prop
! 	  in
! 	    changeProperty dpy {win= winId, name= name, prop= value, mode= mode}
! 	  end
  
    (* set the value of the property *)
--- 108,115 ----
    (* update a proiperty *)
      fun updateProp mode (prop, value) = let
!       val (dpy, winId, name) = infoOfProp prop
!       in
!         changeProperty dpy {win= winId, name= name, prop= value, mode= mode}
!       end
  
    (* set the value of the property *)
***************
*** 128,142 ****
    (* delete the named property *)
      fun deleteProperty prop = let
! 	  val (dpy, wid, name) = infoOfProp prop
! 	  in
! 	    deleteProp dpy {win = wid, prop = name}
! 	  end
  
    (* create a new property initialized to the given value *)
      fun mkProperty (win, value) = let
! 	  val prop = unusedProperty win
! 	  in
! 	    setProperty (prop, value); prop
! 	  end
  
      exception RotateProps
--- 128,142 ----
    (* delete the named property *)
      fun deleteProperty prop = let
!       val (dpy, wid, name) = infoOfProp prop
!       in
!         deleteProp dpy {win = wid, prop = name}
!       end
  
    (* create a new property initialized to the given value *)
      fun mkProperty (win, value) = let
!       val prop = unusedProperty win
!       in
!         setProperty (prop, value); prop
!       end
  
      exception RotateProps
***************
*** 145,198 ****
      fun rotateProperties ([], _) = ()
        | rotateProperties (l as prop::r, n) = let
! 	  val (dpy, wid, _) = infoOfProp prop
! 	  fun chkProp prop = let
! 		val (_, w, name) = infoOfProp prop
! 		in
! 		  if (w <> wid)
! 		    then raise RotateProps
! 		    else name
! 		end
! 	  in
! 	    rotateProps dpy {win= wid, delta= n, properties= map chkProp l}
! 	  end
  
    (* get a property value, which may require several requests *)
      fun getProperty prop = let
! 	  val (dpy, win, name) = infoOfProp prop
! 	  fun sizeOf (XTy.RAW_DATA{data, ...}) = (Word8Vector.length data) div 4
! 	  fun getChunk wordsSoFar = reqGetProperty dpy {
                    win = win, prop = name,
                    typ = NONE, (* AnyPropertyType *)
                    offset = wordsSoFar, len = 1024,
! 		  delete = false
                  }
! 	  fun extendData (data', XTy.RAW_DATA{data, ...}) = data :: data'
! 	  fun flattenData (data', XTy.RAW_DATA{format, data}) = XTy.RAW_DATA{
! 		  format=format,
! 		  data=Word8Vector.concat(rev (data :: data'))
! 		}
! 	  fun getProp () = (case (getChunk 0)
! 		 of NONE => NONE
! 		  | (SOME{typ, bytes_after, value as XTy.RAW_DATA{data, ...}}) =>
! 		      if (bytes_after = 0)
! 		        then (
! 			  SOME(PROP_VAL{typ=typ, value=value}))
! 		        else getRest (sizeOf value, [data])
! 		(* end case *))
! 	  and getRest (wordsSoFar, data') = (case (getChunk wordsSoFar)
! 		 of NONE => NONE
! 		  | (SOME{typ, bytes_after, value}) => if (bytes_after = 0)
! 		      then SOME(PROP_VAL{typ=typ, value=flattenData(data', value)})
! 		      else getRest(
! 			wordsSoFar + sizeOf value,
! 			extendData (data', value))
! 		(* end case *))
! 	  in
! 	    getProp ()
! 	  end
  
    (* inherit the prop_change datatype *)
      structure PropertyServer' : sig
! 	datatype prop_change = NewValue | Deleted
        end = PropertyServer
      open PropertyServer'
--- 145,198 ----
      fun rotateProperties ([], _) = ()
        | rotateProperties (l as prop::r, n) = let
!       val (dpy, wid, _) = infoOfProp prop
!       fun chkProp prop = let
!         val (_, w, name) = infoOfProp prop
!         in
!           if (w <> wid)
!             then raise RotateProps
!             else name
!         end
!       in
!         rotateProps dpy {win= wid, delta= n, properties= map chkProp l}
!       end
  
    (* get a property value, which may require several requests *)
      fun getProperty prop = let
!       val (dpy, win, name) = infoOfProp prop
!       fun sizeOf (XTy.RAW_DATA{data, ...}) = (Word8Vector.length data) div 4
!       fun getChunk wordsSoFar = reqGetProperty dpy {
                    win = win, prop = name,
                    typ = NONE, (* AnyPropertyType *)
                    offset = wordsSoFar, len = 1024,
!           delete = false
                  }
!       fun extendData (data', XTy.RAW_DATA{data, ...}) = data :: data'
!       fun flattenData (data', XTy.RAW_DATA{format, data}) = XTy.RAW_DATA{
!           format=format,
!           data=Word8Vector.concat(rev (data :: data'))
!         }
!       fun getProp () = (case (getChunk 0)
!          of NONE => NONE
!           | (SOME{typ, bytes_after, value as XTy.RAW_DATA{data, ...}}) =>
!               if (bytes_after = 0)
!                 then (
!               SOME(PROP_VAL{typ=typ, value=value}))
!                 else getRest (sizeOf value, [data])
!         (* end case *))
!       and getRest (wordsSoFar, data') = (case (getChunk wordsSoFar)
!          of NONE => NONE
!           | (SOME{typ, bytes_after, value}) => if (bytes_after = 0)
!               then SOME(PROP_VAL{typ=typ, value=flattenData(data', value)})
!               else getRest(
!             wordsSoFar + sizeOf value,
!             extendData (data', value))
!         (* end case *))
!       in
!         getProp ()
!       end
  
    (* inherit the prop_change datatype *)
      structure PropertyServer' : sig
!     datatype prop_change = NewValue | Deleted
        end = PropertyServer
      open PropertyServer'
***************
*** 202,206 ****
     *)
      fun watchProperty (PROP{dpy, name, window, is_unique}) =
! 	  PropS.watchProperty (propServer dpy, name, window, is_unique)
  
    end (* Property *)
--- 202,228 ----
     *)
      fun watchProperty (PROP{dpy, name, window, is_unique}) =
!       PropS.watchProperty (propServer dpy, name, window, is_unique)
  
+     (* Additions by ddeboer, May 2004. 
+      * Dusty deBoer, KSU CIS 705, Spring 2004. *)
+      
+     (* xrdbOfScr: return the list of strings contained in the
+      * XA_RESOURCE_MANAGER property of the root screen of the
+      * specified screen. 
+      * This should properly belong some other place than in ICCC,
+      * as it has nothing to do with ICCC, except that it accesses
+      * data in the screen type, and uses the GetProperty functions
+      * of ICCC.
+      *)
+     fun xrdbOfScr (s: Display.screen) = 
+         let
+         val dpy = Display.displayOfScr(s)
+         val rtw = Display.rootWinOfScr(s)
+         in
+             case getProperty(PROP{dpy=dpy,name=StdAtoms.atom_RESOURCE_MANAGER,window=rtw,is_unique=false})
+             of  SOME(PROP_VAL{typ=typ,value=RAW_DATA{format=Raw8,data=data}}) => 
+                     (String.tokens (fn c => case ord(c) of 13=>true|10=>true|_=>false) (Byte.bytesToString(data)))
+               | _ => []
+         end
+     (* end additions by ddeboer *)
    end (* Property *)



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.