PreviousUpNext

15.4.1481  src/lib/x-kit/xclient/pkg/window/rw-pixmap.pkg

## rw-pixmap.pkg
#
#   The three kinds of X server rectangular arrays of pixels
#   supported by x-kit are window, rw_pixmap and ro_pixmap.
#
#      o 'window': are on-screen  and on the X-server.
#      o 'rw_pixmap': are off-screen and on the X-server.
#      o 'ro_pixmap': offscreeen, immutable and on the X-server.
#
#   These all have 'depth' (bits per pixel) and
#   'size' (in pixel rows and cols) information.
#   Windows have in addition 'upperleft' position
#   (relative to parent window) and border width in pixels.
#
#   (A fourth kind of rectangular array of pixels is the
#   client-side 'cs_pixmap'.  These are not 'drawable', but
#   pixels can be bitblt-ed between them and server-side
#   windows and pixmaps.)
#
# See also:
#     src/lib/x-kit/xclient/pkg/window/ro-pixmap.pkg
#     src/lib/x-kit/xclient/pkg/window/window.pkg
#     src/lib/x-kit/xclient/pkg/window/cs-pixmap.pkg

# Compiled by:
#     src/lib/x-kit/xclient/xclient-internals.sublib


stipulate
    package di  =  draw_imp;                                    # draw_imp      is from   src/lib/x-kit/xclient/pkg/window/draw-imp.pkg
    package dt  =  draw_types;                                  # draw_types    is from   src/lib/x-kit/xclient/pkg/window/draw-types.pkg
    package dy  =  display;                                     # display       is from   src/lib/x-kit/xclient/pkg/wire/display.pkg
    package xg  =  xgeometry;                                   # xgeometry     is from   src/lib/std/2d/xgeometry.pkg
    package sn  =  xsession;                                    # xsession      is from   src/lib/x-kit/xclient/pkg/window/xsession.pkg
    package xok =  xsocket;                                     # xsocket       is from   src/lib/x-kit/xclient/pkg/wire/xsocket.pkg
herein

    package rw_pixmap {

        exception BAD_PIXMAP_PARAMETER;

        # Create uninitialized pixel array:
        #
        fun make_readwrite_pixmap  screen  (size, depth)
            =
            {   screen -> sn::SCREEN
                            {
                              screen_info =>  sn::SCREEN_INFO { xscreen  => dy::XSCREEN  { root_window_id, ... }, ... },
                              xsession    =>  sn::XSESSION    { xdisplay => dy::XDISPLAY { xsocket, next_xid, ... }, ... }
                            };

                screen_pen_and_draw_imps = sn::screen_pen_and_draw_imps_for_depth (screen, depth)
                except
                    xgripe::XERROR _   = raise exception BAD_PIXMAP_PARAMETER;

                pixmap_id =  next_xid ();

                if (not (xg::valid_size  size))
                    #
                    raise exception BAD_PIXMAP_PARAMETER;
                fi;

                xok::send_xrequest  xsocket
                  ( value_to_wire::encode_create_pixmap
                      {
                        pixmap_id,
                        drawable_id =>  root_window_id,
                        size,
                        depth
                      }
                  );

                dt::RW_PIXMAP { pixmap_id, screen, size, screen_pen_and_draw_imps };
            };

        # Destroy an offscreen window.
        # We do this via draw_imp to avoid a race with
        # any pending draw requests on the window.
        #
        fun destroy_rw_pixmap  (dt::RW_PIXMAP { pixmap_id, screen_pen_and_draw_imps => sn::SCREEN_PEN_AND_DRAW_IMPS { to_screen_drawimp, ... }, ... } )
            =
            to_screen_drawimp (di::d::DESTROY (di::i::PIXMAP pixmap_id));

    };                                          # package pixmap 
end;



## COPYRIGHT (c) 1990, 1991 by John H. Reppy.  See COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext