## windowsystem-to-xserver.pkg
#
# Requests from app/widget code to xserver-ximp and
# ultimately the X server.
#
#
# For the big picture see the imp dataflow diagrams in
#
#
src/lib/x-kit/xclient/src/window/xclient-ximps.pkg#
# Compiled by:
#
src/lib/x-kit/xclient/xclient-internals.sublibstipulate
include package threadkit; # threadkit is from
src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg #
# package xet = xevent_types; # xevent_types is from
src/lib/x-kit/xclient/src/wire/xevent-types.pkg package pg = pen_guts; # pen_guts is from
src/lib/x-kit/xclient/src/window/pen-guts.pkg package v1u = vector_of_one_byte_unts; # vector_of_one_byte_unts is from
src/lib/std/src/vector-of-one-byte-unts.pkg package g2d = geometry2d; # geometry2d is from
src/lib/std/2d/geometry2d.pkg package xt = xtypes; # xtypes is from
src/lib/x-kit/xclient/src/wire/xtypes.pkg package vu8 = vector_of_one_byte_unts; # vector_of_one_byte_unts is from
src/lib/std/src/vector-of-one-byte-unts.pkg package fb = font_base; # font_base is from
src/lib/x-kit/xclient/src/window/font-base.pkg package x2s = xclient_to_sequencer; # xclient_to_sequencer is from
src/lib/x-kit/xclient/src/wire/xclient-to-sequencer.pkg package pp = standard_prettyprinter; # standard_prettyprinter is from
src/lib/prettyprint/big/src/standard-prettyprinter.pkgherein
# This port is implemented in:
#
#
src/lib/x-kit/xclient/src/window/xserver-ximp.pkg #
package windowsystem_to_xserver {
#
package s {
#
Mapped_State
= HOSTWINDOW_IS_NOW_UNMAPPED
| HOSTWINDOW_IS_NOW_MAPPED
| FIRST_EXPOSE
;
};
package t {
#
Poly_Text
= TEXT (Int, String) # The Int is 'delta', extra space inserted before string -- see PolyText8 doc in http://mythryl.org/pub/exene/X-protocol-R6.pdf
| FONT xt::Font_Id
;
};
package x {
#
Image = { to_point: g2d::Point,
size: g2d::Size,
depth: Int,
lpad: Int,
format: xt::Image_Format,
data: vu8::Vector
};
#
Op
= POLY_POINT (Bool, List( g2d::Point )) # For docs see PolyPoint, PolyLine etc in http://mythryl.org/pub/exene/X-protocol-R6.pdf
| POLY_LINE (Bool, List( g2d::Point ))
#
| FILL_POLY (xt::Shape, Bool, List( g2d::Point ))
#
| POLY_SEG List( g2d::Line )
#
| POLY_BOX List( g2d::Box )
| POLY_FILL_BOX List( g2d::Box )
#
| POLY_ARC List( g2d::Arc64 )
| POLY_FILL_ARC List( g2d::Arc64 )
#
| COPY_PMAREA (g2d::Point, xt::Xid, g2d::Box)
| COPY_PMPLANE (g2d::Point, xt::Xid, g2d::Box, Int)
| CLEAR_AREA g2d::Box
| COPY_AREA (g2d::Point, xt::Xid, g2d::Box)
# In Reppy's version COPY_AREA/COPY_PLANE had List(g2d::Box) oneshots to handle GraphicsExpose events.
| COPY_PLANE (g2d::Point, xt::Xid, g2d::Box, Int)
# That's complex and ugly, so I'm eliminating them and crossing my fingers that we can live without them.
#
| PUT_IMAGE List (Image)
# The main reason to support a list here is that the X protocol limits the length of a single request;
# # the list makes it easy for low-level logic to transparently break one request up into multiple requests.
# # E.g. copy_from_clientside_pixmat_to_pixmap_request() in
src/lib/x-kit/xclient/src/window/cs-pixmat.pkg
| POLY_TEXT8 (xt::Font_Id, g2d::Point, List(t::Poly_Text))
| POLY_TEXT16 (xt::Font_Id, g2d::Point, List(t::Poly_Text))
| IMAGE_TEXT8 (xt::Font_Id, g2d::Point, String)
;
};
package i {
#
Destroy_Item
= WINDOW xt::Window_Id
| PIXMAP xt::Pixmap_Id
;
};
Draw_Op = { to: xt::Xid,
pen: pg::Pen,
op: x::Op
};
Windowsystem_To_Xserver
=
{
xclient_to_sequencer: x2s::Xclient_To_Sequencer, # Xsequencer-forwarding port. The point of including this facility
# is that clients can avoid race conditions by always talking to us;
# if they talk both to us and directly to the xsequencer subtle
# race conditions may arise in which behavior is non-deterministic,
# depending on whether we or the xsequencer run next.
# The point of renaming the port (xclient_to_sequencer instead of
# xclient_to_sequencer) is to make it easy to grep for clients who
# are (incorrectly) directly bypassing our tunnel by directly using
# the xclient_to_sequencer port exported by
src/lib/x-kit/xclient/src/wire/xsequencer-ximp.pkg draw_ops: List( Draw_Op ) -> Void,
#
destroy_window: xt::Window_Id -> Void,
destroy_pixmap: xt::Pixmap_Id -> Void,
#
find_else_open_font: String -> Null_Or( fb::Font ) # This is a quick local lookup if the font is already in our client-side font-index.pkg cache.
#
# Returns THE opened font.
# Returns NULL if the font cannot be
# found on the X server's font path.
# flush ?
# thread_id ?
};
# Typical call looks like:
#
# fg = pp::prettyprint_to_string [] {. w2x::prettyprint_drawop_list #pp (map (\\ { op: windowsystem_to_xserver::x::Op, pen: pen_guts::Pen, to: xtypes::Window_Id } = op) ops); };
# print ("\nwindowsystem-imp-for-x: convert_displaylist_to_drawoplist/ZZZ ops:\n" + fg + "\n");
#
fun prettyprint_drawop_list
#
(pp: pp::Prettyprinter)
(ops: List(x::Op))
=
pp::listx pp do_op "" ops
where
fun point_to_string { row, col } = sprintf "{ row => %d, col => %d }" row col;
fun line_to_string (p1, p2) = sprintf "(%s, %s)" (point_to_string p1) (point_to_string p2);
fun box_to_string { row, col, high, wide } = sprintf "{ row => %d, col => %d, high => %d, wide => %d }" row col high wide;
fun arc_to_string { row, col, high, wide, angle1, angle2 } = sprintf "{ row => %d, col => %d, high => %d, wide => %d, angle1 => %d, angle2 => %d }" row col high wide angle1 angle2;
fun do_op (x::POLY_POINT (_,p)) => pp::listx pp (\\ pt = pp.lit (point_to_string pt)) "POLY_POINT" p;
do_op (x::POLY_LINE (_,p)) => pp::listx pp (\\ pt = pp.lit (point_to_string pt)) "POLY_LINE" p;
do_op (x::FILL_POLY (_,_,p)) => pp::listx pp (\\ pt = pp.lit (point_to_string pt)) "FILL_POLY" p;
#
do_op (x::POLY_SEG l ) => pp::listx pp (\\ pt = pp.lit (line_to_string pt)) "POLY_SEG" l;
do_op (x::POLY_BOX b ) => pp::listx pp (\\ pt = pp.lit ( box_to_string pt)) "POLY_BOX" b;
do_op (x::POLY_FILL_BOX b ) => pp::listx pp (\\ pt = pp.lit ( box_to_string pt)) "POLY_FILL_BOX" b;
do_op (x::POLY_ARC a ) => pp::listx pp (\\ pt = pp.lit ( arc_to_string pt)) "POLY_ARC" a;
do_op (x::POLY_FILL_ARC a ) => pp::listx pp (\\ pt = pp.lit ( arc_to_string pt)) "POLY_FILL_ARC" a;
#
do_op (x::COPY_PMAREA a ) => pp.lit "COPY_PMAREA" ;
do_op (x::COPY_PMPLANE a ) => pp.lit "COPY_PMPLANE" ;
do_op (x::CLEAR_AREA a ) => pp.lit "CLEAR_AREA" ;
do_op (x::COPY_AREA a ) => pp.lit "COPY_AREA" ;
do_op (x::COPY_PLANE a ) => pp.lit "COPY_PLANE" ;
do_op (x::PUT_IMAGE a ) => pp.lit "PUT_IMAGE" ;
do_op (x::POLY_TEXT8 a ) => pp.lit "POLY_TEXT8" ;
do_op (x::POLY_TEXT16 a ) => pp.lit "POLY_TEXT16" ;
do_op (x::IMAGE_TEXT8 a ) => pp.lit "IMAGE_TEXT8" ;
end;
end;
}; # package windowsystem_to_xserver
end;