home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>X11::Protocol - Perl module for the X Window System Protocol, version 11</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> X11::Protocol - Perl module for the X Window System Protocol, version 11</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#disclaimer">DISCLAIMER</A></LI>
- <LI><A HREF="#basic methods">BASIC METHODS</A></LI>
- <UL>
-
- <LI><A HREF="#new">new</A></LI>
- <LI><A HREF="#new_rsrc">new_rsrc</A></LI>
- <LI><A HREF="#handle_input">handle_input</A></LI>
- <LI><A HREF="#atom_name">atom_name</A></LI>
- <LI><A HREF="#atom">atom</A></LI>
- <LI><A HREF="#choose_screen">choose_screen</A></LI>
- </UL>
-
- <LI><A HREF="#symbolic constants">SYMBOLIC CONSTANTS</A></LI>
- <UL>
-
- <LI><A HREF="#num">num</A></LI>
- <LI><A HREF="#interp">interp</A></LI>
- </UL>
-
- <LI><A HREF="#server information">SERVER INFORMATION</A></LI>
- <LI><A HREF="#requests">REQUESTS</A></LI>
- <UL>
-
- <LI><A HREF="#request">request</A></LI>
- <LI><A HREF="#add_reply">add_reply</A></LI>
- <LI><A HREF="#delete_reply">delete_reply</A></LI>
- <LI><A HREF="#send">send</A></LI>
- <LI><A HREF="#unpack_reply">unpack_reply</A></LI>
- </UL>
-
- <LI><A HREF="#events">EVENTS</A></LI>
- <UL>
-
- <LI><A HREF="#pack_event_mask">pack_event_mask</A></LI>
- <LI><A HREF="#unpack_event_mask">unpack_event_mask</A></LI>
- <LI><A HREF="#dequeue_event">dequeue_event</A></LI>
- <LI><A HREF="#next_event">next_event</A></LI>
- <LI><A HREF="#pack_event">pack_event</A></LI>
- <LI><A HREF="#unpack_event">unpack_event</A></LI>
- </UL>
-
- <LI><A HREF="#extensions">EXTENSIONS</A></LI>
- <UL>
-
- <LI><A HREF="#init_extension">init_extension</A></LI>
- <LI><A HREF="#init_extensions">init_extensions</A></LI>
- </UL>
-
- <LI><A HREF="#writing extensions">WRITING EXTENSIONS</A></LI>
- <UL>
-
- <LI><A HREF="#padding">padding</A></LI>
- <LI><A HREF="#pad">pad</A></LI>
- <LI><A HREF="#padded">padded</A></LI>
- <LI><A HREF="#hexi">hexi</A></LI>
- <LI><A HREF="#make_num_hash">make_num_hash</A></LI>
- </UL>
-
- <LI><A HREF="#bugs">BUGS</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>X11::Protocol - Perl module for the X Window System Protocol, version 11</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- use X11::Protocol;
- $x = X11::Protocol->new();
- $win = $x->new_rsrc;
- $x->CreateWindow($win, $x->root, 'InputOutput',
- $x->root_depth, 'CopyFromParent',
- ($x_coord, $y_coord), $width,
- $height, $border_w);
- ...</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>X11::Protocol is a client-side interface to the X11 Protocol (see <CODE>X(1)</CODE> for
- information about X11), allowing perl programs to display windows and
- graphics on X11 servers.</P>
- <P>A full description of the protocol is beyond the scope of this documentation;
- for complete information, see the <EM>X Window System Protocol, X Version 11</EM>,
- available as Postscript or *roff source from <CODE>ftp://ftp.x.org</CODE>, or
- <EM>Volume 0: X Protocol Reference Manual</EM> of O'Reilly & Associates's series of
- books about X (ISBN 1-56592-083-X, <CODE>http://www.oreilly.com</CODE>), which contains
- most of the same information.</P>
- <P>
- <HR>
- <H1><A NAME="disclaimer">DISCLAIMER</A></H1>
- <P>``The protocol contains many management mechanisms that are
- not intended for normal applications. Not all mechanisms
- are needed to build a particular user interface. It is
- important to keep in mind that the protocol is intended to
- provide mechanism, not policy.'' -- Robert W. Scheifler</P>
- <P>
- <HR>
- <H1><A NAME="basic methods">BASIC METHODS</A></H1>
- <P>
- <H2><A NAME="new">new</A></H2>
- <PRE>
- $x = X11::Protocol->new();
- $x = X11::Protocol->new($display_name);
- $x = X11::Protocol->new($connection);
- $x = X11::Protocol->new($display_name, [$auth_type, $auth_data]);
- $x = X11::Protocol->new($connection, [$auth_type, $auth_data]);</PRE>
- <P>Open a connection to a server. $display_name should be an X display
- name, of the form 'host:display_num.screen_num'; if no arguments are
- supplied, the contents of the DISPLAY environment variable are
- used. Alternatively, a pre-opened connection, of one of the
- X11::Protocol::Connection classes (see
- <A HREF="../../../site/lib/X11/Protocol/Connection.html">the X11::Protocol::Connection manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Connection/FileHandle.html">the X11::Protocol::Connection::FileHandle manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Connection/Socket.html">the X11::Protocol::Connection::Socket manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Connection/UNIXFH.html">the X11::Protocol::Connection::UNIXFH manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Connection/INETFH.html">the X11::Protocol::Connection::INETFH manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Connection/UNIXSocket.html">the X11::Protocol::Connection::UNIXSocket manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Connection/INETSocket.html">the X11::Protocol::Connection::INETSocket manpage</A>) can be given. The
- authorization data is obtained using X11::Auth or the second
- argument. If the display is specified by $display_name, rather than
- $connection, a <CODE>choose_screen()</CODE> is also performed, defaulting to screen
- 0 if the '.screen_num' of the display name is not present. Returns
- the new protocol object.</P>
- <P>
- <H2><A NAME="new_rsrc">new_rsrc</A></H2>
- <PRE>
- $x->new_rsrc;</PRE>
- <P>Returns a new resource identifier. A unique resource ID is required for every
- object that the server creates on behalf of the client: windows, fonts,
- cursors, etc. (IDs are chosen by the client instead of the server for
- efficiency -- the client doesn't have to wait for the server to acknowledge
- the creation before starting to use the object).</P>
- <P>
- <H2><A NAME="handle_input">handle_input</A></H2>
- <PRE>
- $x->handle_input;</PRE>
- <P>Get one chunk of information from the server, and do something with it. If it's
- an error, handle it using the protocol object's handler ('error_handler'
- -- default is kill the program with an explanatory message). If it's an event,
- pass it to the chosen event handler, or put it in a queue if the handler is
- 'queue'. If it's a reply to a request, save using the object's 'replies' hash
- for further processing.</P>
- <P>
- <H2><A NAME="atom_name">atom_name</A></H2>
- <PRE>
- $name = $x->atom_name($atom);</PRE>
- <P>Return the string corresponding to the atom $atom. This is similar to the
- GetAtomName request, but caches the result for efficiency.</P>
- <P>
- <H2><A NAME="atom">atom</A></H2>
- <PRE>
- $atom = $x->atom($name);</PRE>
- <P>The inverse operation; Return the (numeric) atom correspoding to $name.
- This is similar to the InternAtom request, but caches the result.</P>
- <P>
- <H2><A NAME="choose_screen">choose_screen</A></H2>
- <PRE>
- $x->choose_screen($screen_num);</PRE>
- <P>Indicate that you prefer to use a particular screen of the display. Per-screen
- information, such as 'root', 'width_in_pixels', and 'white_pixel' will be
- made avaliable as</P>
- <PRE>
- $x->{'root'}</PRE>
- <P>instead of</P>
- <PRE>
- $x->{'screens'}[$screen_num]{'root'}</PRE>
- <P>
- <HR>
- <H1><A NAME="symbolic constants">SYMBOLIC CONSTANTS</A></H1>
- <P>Generally, symbolic constants used by the protocol, like 'CopyFromParent'
- or 'PieSlice' are passed to methods as strings, and
- converted into numbers by the module. Their names are the same as
- those in the protocol specification, including capitalization, but
- with hyphens ('-') changed to underscores ('_') to look more
- perl-ish. If you want to do the conversion yourself for some reason,
- the following methods are avaliable:</P>
- <P>
- <H2><A NAME="num">num</A></H2>
- <PRE>
- $num = $x->num($type, $str)</PRE>
- <P>Given a string representing a constant and a string specifying what
- type of constant it is, return the corresponding number. $type should
- be a name like 'VisualClass' or 'GCLineStyle'. If the name is not
- recognized, it is returned intact.</P>
- <P>
- <H2><A NAME="interp">interp</A></H2>
- <PRE>
- $name = $x->interp($type, $num)</PRE>
- <P>The inverse operation; given a number and string specifying its type, return
- a string representing the constant.</P>
- <P>You can disable <CODE>interp()</CODE> and the module's internal interpretation of
- numbers by setting $x->{'do_interp'} to zero. Of course, this isn't
- very useful, unless you have you own definitions for all the
- constants.</P>
- <P>Here is a list of available constant types:</P>
- <PRE>
- AccessMode, AllowEventsMode, AutoRepeatMode, BackingStore,
- BitGravity, Bool, ChangePropertyMode, CirculateDirection,
- CirculatePlace, Class, ClipRectangleOrdering, CloseDownMode,
- ColormapNotifyState, CoordinateMode, CrossingNotifyDetail,
- CrossingNotifyMode, DeviceEvent, DrawDirection, Error, EventMask,
- Events, FocusDetail, FocusMode, GCArcMode, GCCapStyle, GCFillRule,
- GCFillStyle, GCFunction, GCJoinStyle, GCLineStyle, GCSubwindowMode,
- GrabStatus, HostChangeMode, HostFamily, ImageFormat,
- InputFocusRevertTo, KeyMask, LedMode, MapState, MappingChangeStatus,
- MappingNotifyRequest, PointerEvent, PolyShape, PropertyNotifyState,
- Request, ScreenSaver, ScreenSaverAction, Significance, SizeClass,
- StackMode, SyncMode, VisibilityState, VisualClass, WinGravity</PRE>
- <P>
- <HR>
- <H1><A NAME="server information">SERVER INFORMATION</A></H1>
- <P>At connection time, the server sends a large amount of information about
- itself to the client. This information is stored in the protocol object
- for future reference. It can be read directly, like</P>
- <PRE>
- $x->{'release_number'}</PRE>
- <P>or, for object oriented True Believers, using a method:</P>
- <PRE>
- $x->release_number</PRE>
- <P>The method method also has a one argument form for setting variables, but
- it isn't really useful for some of the more complex structures.</P>
- <P>Here is an example of what the object's information might look like:</P>
- <PRE>
- 'connection' => X11::Connection::UNIXSocket(0x814526fd),
- 'byte_order' => 'l',
- 'protocol_major_version' => 11,
- 'protocol_minor_version' => 0,
- 'authorization_protocol_name' => 'MIT-MAGIC-COOKIE-1',
- 'release_number' => 3110,
- 'resource_id_base' => 0x1c000002,
- 'motion_buffer_size' => 0,
- 'maximum_request_length' => 65535, # units of 4 bytes
- 'image_byte_order' => 'LeastSiginificant',
- 'bitmap_bit_order' => 'LeastSiginificant',
- 'bitmap_scanline_unit' => 32,
- 'bitmap_scanline_pad' => 32,
- 'min_keycode' => 8,
- 'max_keycode' => 134,
- 'vendor' => 'The XFree86 Project, Inc',
- 'pixmap_formats' => {1 => {'bits_per_pixel' => 1,
- 'scanline_pad' => 32},
- 8 => {'bits_per_pixel' => 8,
- 'scanline_pad' => 32}},
- 'screens' => [{'root' => 43, 'width_in_pixels' => 800,
- 'height_in_pixels' => 600,
- 'width_in_millimeters' => 271,
- 'height_in_millmerters' => 203,
- 'root_depth' => 8,
- 'root_visual' => 34,
- 'default_colormap' => 33,
- 'white_pixel' => 0, 'black_pixel' => 1,
- 'min_installed_maps' => 1,
- 'max_installed_maps' => 1,
- 'backing_stores' => 'Always',
- 'save_unders' => 1,
- 'current_input_masks' => 0x58003d,
- 'allowed_depths' =>
- [{'depth' => 1, 'visuals' => []},
- {'depth' => 8, 'visuals' => [
- {'visual_id' => 34, 'blue_mask' => 0,
- 'green_mask' => 0, 'red_mask' => 0,
- 'class' => 'PseudoColor',
- 'bits_per_rgb_value' => 6,
- 'colormap_entries' => 256},
- {'visual_id' => 35, 'blue_mask' => 0xc0,
- 'green_mask' => 0x38, 'red_mask' => 0x7,
- 'class' => 'DirectColor',
- 'bits_per_rgb_value' => 6,
- 'colormap_entries' => 8}, ...]}]],
- 'visuals' => {34 => {'depth' => 8, 'class' => 'PseudoColor',
- 'red_mask' => 0, 'green_mask' => 0,
- 'blue_mask'=> 0, 'bits_per_rgb_value' => 6,
- 'colormap_entries' => 256},
- 35 => {'depth' => 8, 'class' => 'DirectColor',
- 'red_mask' => 0x7, 'green_mask' => 0x38,
- 'blue_mask'=> 0xc0, 'bits_per_rgb_value' => 6,
- 'colormap_entries' => 8}, ...}
- 'error_handler' => &\X11::Protocol::default_error_handler,
- 'event_handler' => sub {},
- 'do_interp' => 1</PRE>
- <P>
- <HR>
- <H1><A NAME="requests">REQUESTS</A></H1>
- <P>
- <H2><A NAME="request">request</A></H2>
- <PRE>
- $x->request('CreateWindow', ...);
- $x->req('CreateWindow', ...);
- $x->CreateWindow(...);</PRE>
- <P>Send a protocol request to the server, and get the reply. For names of and
- information about individual requests, see below and/or
- the protocol reference manual.</P>
- <P>
- <H2><A NAME="add_reply">add_reply</A></H2>
- <PRE>
- $x->add_reply($sequence_num, \$var);</PRE>
- <P>Add a stub for an expected reply to the object's 'replies' hash. When a reply
- numbered $sequence_num comes, it will be stored in $var.</P>
- <P>
- <H2><A NAME="delete_reply">delete_reply</A></H2>
- <PRE>
- $x->delete_reply($sequence_num);</PRE>
- <P>Delete the entry in 'replies' for the specified reply. (This should be done
- after the reply is recieved).</P>
- <P>
- <H2><A NAME="send">send</A></H2>
- <PRE>
- $x->send('CreateWindow', ...);</PRE>
- <P>Send a request, but do not wait for a reply. You must handle the reply, if any,
- yourself, using add_reply(), handle_input(), delete_reply(), and
- unpack_reply(), generally in that order.</P>
- <P>
- <H2><A NAME="unpack_reply">unpack_reply</A></H2>
- <PRE>
- $x->unpack_reply('GetWindowAttributes', $data);</PRE>
- <P>Interpret the raw reply data $data, according to the reply format for the named
- request. Returns data in the same format as <CODE>request($request_name, ...)</CODE>.</P>
- <P>This section includes only a short calling summary for each request; for
- full descriptions, see the protocol standard. Argument order is usually the
- same as listed in the spec, but you generally don't have to pass lengths of
- strings or arrays, since perl keeps track. Symbolic constants are generally
- passed as strings. Most replies are returned as lists, but when there are
- many values, a hash is used. Lists usually come last; when there is more than
- one, each is passed by reference. In lists of multi-part structures, each
- element is a list ref. Parenthesis are inserted in arg lists for clarity,
- but are optional. Requests are listed in order by major opcode, so related
- requests are usually close together. Replies follow the '=>'.</P>
- <PRE>
- $x->CreateWindow($wid, $parent, $class, $depth, $visual, ($x, $y),
- $width, $height, $border_width,
- 'attribute' => $value, ...)</PRE>
- <PRE>
- $x->ChangeWindowAttributes($window, 'attribute' => $value, ...)</PRE>
- <PRE>
- $x->GetWindowAttributes($window)
- =>
- ('backing_store' => $backing_store, ...)</PRE>
- <P>This is an example of a return value that is meant to be assigned to a hash.</P>
- <PRE>
- $x->DestroyWindow($win)</PRE>
- <PRE>
- $x->DestroySubwindows($win)</PRE>
- <PRE>
- $x->ChangeSaveSet($window, $mode)</PRE>
- <PRE>
- $x->ReparentWindow($win, $parent, ($x, $y))</PRE>
- <PRE>
- $x->MapWindow($win)</PRE>
- <PRE>
- $x->MapSubwindows($win)</PRE>
- <PRE>
- $x->UnmapWindow($win)</PRE>
- <PRE>
- $x->UnmapSubwindows($win)</PRE>
- <PRE>
- $x->ConfigureWindow($win, 'attribute' => $value, ...)</PRE>
- <PRE>
- $x->CirculateWindow($win, $direction)</PRE>
- <P>Note that this request actually circulates the subwindows of $win,
- not the window itself.</P>
- <PRE>
- $x->GetGeometry($drawable)
- =>
- ('root' => $root, ...)</PRE>
- <PRE>
- $x->QueryTree($win)
- =>
- ($root, $parent, @kids)</PRE>
- <PRE>
- $x->InternAtom($name, $only_if_exists)
- =>
- $atom</PRE>
- <PRE>
- $x->GetAtomName($atom)
- =>
- $name</PRE>
- <PRE>
- $x->ChangeProperty($window, $property, $type, $format, $mode, $data)</PRE>
- <PRE>
- $x->DeleteProperty($win, $atom)</PRE>
- <PRE>
- $x->GetProperty($window, $property, $type, $offset, $length, $delete)
- =>
- ($value, $type, $format, $bytes_after)</PRE>
- <P>Notice that the value comes first, so you can easily ignore the rest.</P>
- <PRE>
- $x->ListProperties($window)
- =>
- (@atoms)</PRE>
- <PRE>
- $x->SetSelectionOwner($selection, $owner, $time)</PRE>
- <PRE>
- $x->GetSelectionOwner($selection)
- =>
- $owner</PRE>
- <PRE>
- $x->ConvertSelection($selection, $target, $property, $requestor, $time)</PRE>
- <PRE>
- $x->SendEvent($destination, $propagate, $event_mask, $event)</PRE>
- <P>The $event argument should be the result of a <CODE>pack_event()</CODE> (see <A HREF="#events">EVENTS</A>)</P>
- <PRE>
- $x->GrabPointer($grab_window, $owner_events, $event_mask,
- $pointer_mode, $keyboard_mode, $confine_to,
- $cursor, $time)
- =>
- $status</PRE>
- <PRE>
- $x->UngrabPointer($time)</PRE>
- <PRE>
- $x->GrabButton($modifiers, $button, $grab_window, $owner_events,
- $event_mask, $pointer_mode, $keyboard_mode,
- $confine_to, $cursor)</PRE>
- <PRE>
- $x->UngrabButton($modifiers, $button, $grab_window)</PRE>
- <PRE>
- $x->ChangeActivePointerGrab($event_mask, $cursor, $time)</PRE>
- <PRE>
- $x->GrabKeyboard($grab_window, $owner_events, $pointer_mode,
- $keyboard_mode, $time)
- =>
- $status</PRE>
- <PRE>
- $x->UngrabKeyboard($time)</PRE>
- <PRE>
- $x->GrabKey($key, $modifiers, $grab_window, $owner_events,
- $pointer_mode, $keyboard_mode)</PRE>
- <PRE>
- $x->UngrabKey($key, $modifiers, $grab_window)</PRE>
- <PRE>
- $x->AllowEvents($mode, $time)</PRE>
- <PRE>
- $x->GrabServer</PRE>
- <PRE>
- $x->UngrabServer</PRE>
- <PRE>
- $x->QueryPointer($window)
- =>
- ('root' => $root, ...)</PRE>
- <PRE>
- $x->GetMotionEvents($start, $stop, $window)
- =>
- ([$time, ($x, $y)], [$time, ($x, $y)], ...)</PRE>
- <PRE>
- $x->TranslateCoordinates($src_window, $dst_window, $src_x, $src_y)
- =>
- ($same_screen, $child, $dst_x, $dst_y)</PRE>
- <PRE>
- $x->WarpPointer($src_window, $dst_window, $src_x, $src_y, $src_width,
- $src_height, $dst_x, $dst_y)</PRE>
- <PRE>
- $x->SetInputFocus($focus, $revert_to, $time)</PRE>
- <PRE>
- $x->GetInputFocus
- =>
- ($focus, $revert_to)</PRE>
- <PRE>
- $x->QueryKeymap
- =>
- $keys</PRE>
- <P>$keys is a bit vector, so you should use <A HREF="../../../lib/Pod/perlfunc.html#item_vec"><CODE>vec()</CODE></A> to read it.</P>
- <PRE>
- $x->OpenFont($fid, $name)</PRE>
- <PRE>
- $x->CloseFont($font)</PRE>
- <PRE>
- $x->QueryFont($font)
- =>
- ('min_char_or_byte2' => $min_char_or_byte2,
- ...,
- 'min_bounds' =>
- [$left_side_bearing, $right_side_bearing, $character_width, $ascent,
- $descent, $attributes],
- ...,
- 'char_infos' =>
- [[$left_side_bearing, $right_side_bearing, $character_width, $ascent,
- $descent, $attributes],
- ...],
- 'properties' => {$prop => $value, ...}
- )</PRE>
- <PRE>
- $x->QueryTextExtents($font, $string)
- =>
- ('draw_direction' => $draw_direction, ...)</PRE>
- <PRE>
- $x->ListFonts($pattern, $max_names)
- =>
- @names</PRE>
- <PRE>
- $x->ListFontsWithInfo($pattern, $max_names)
- =>
- ({'name' => $name, ...}, {'name' => $name, ...}, ...)</PRE>
- <P>The information in each hash is the same as the the information returned by
- QueryFont, but without per-character size information. This request is
- special in that it is the only request that can have more than one reply.
- This means you should probably only use <CODE>request()</CODE> with it, not send(), as
- the reply counting is complicated. Luckily, you never need this request
- anyway, as its function is completely duplicated by other requests.</P>
- <PRE>
- $x->SetFontPath(@strings)</PRE>
- <PRE>
- $x->GetFontPath
- =>
- @strings</PRE>
- <PRE>
- $x->CreatePixmap($pixmap, $drawable, $depth, $width, $height)</PRE>
- <PRE>
- $x->FreePixmap($pixmap)</PRE>
- <PRE>
- $x->CreateGC($cid, $drawable, 'attribute' => $value, ...)</PRE>
- <PRE>
- $x->ChangeGC($gc, 'attribute' => $value, ...)</PRE>
- <PRE>
- $x->CopyGC($src, $dest, 'attribute', 'attribute', ...)</PRE>
- <PRE>
- $x->SetDashes($gc, $dash_offset, (@dashes))</PRE>
- <PRE>
- $x->SetClipRectangles($gc, ($clip_x_origin, $clip_y_origin),
- $ordering, [$x, $y, $width, $height], ...)</PRE>
- <PRE>
- $x->ClearArea($window, ($x, $y), $width, $height, $exposures)</PRE>
- <PRE>
- $x->CopyArea($src_drawable, $dst_drawable, $gc, ($src_x, $src_y),
- $width, $height, ($dst_x, $dst_y))</PRE>
- <PRE>
- $x->CopyPlane($src_drawable, $dst_drawable, $gc, ($src_x, $src_y),
- $width, $height, ($dst_x, $dst_y), $bit_plane)</PRE>
- <PRE>
- $x->PolyPoint($drawable, $gc, $coordinate_mode,
- ($x, $y), ($x, $y), ...)</PRE>
- <PRE>
- $x->PolyLine($drawable, $gc, $coordinate_mode,
- ($x, $y), ($x, $y), ...)</PRE>
- <PRE>
- $x->PolySegment($drawable, $gc, ($x, $y) => ($x, $y),
- ($x, $y) => ($x, $y), ...)</PRE>
- <PRE>
- $x->PolyRectangle($drawable, $gc,
- [($x, $y), $width, $height], ...)</PRE>
- <PRE>
- $x->PolyArc($drawable, $gc,
- [($x, $y), $width, $height, $angle1, $angle2], ...)</PRE>
- <PRE>
- $x->FillPoly($drawable, $gc, $shape, $coordinate_mode,
- ($x, $y), ...)</PRE>
- <PRE>
- $x->PolyFillRectangle($drawable, $gc,
- [($x, $y), $width, $height], ...)</PRE>
- <PRE>
- $x->PolyFillArc($drawable, $gc,
- [($x, $y), $width, $height, $angle1, $angle2], ...)</PRE>
- <PRE>
- $x->PutImage($drawable, $gc, $depth, $width, $height,
- ($dst_x, $dst_y), $left_pad, $format, $data)</PRE>
- <P>Currently, the module has no code to handle the various bitmap formats that
- the server might specify. Therefore, this request will not work portably
- without a lot of work.</P>
- <PRE>
- $x->GetImage($drawable, ($x, $y), $width, $height, $plane_mask,
- $format)</PRE>
- <PRE>
- $x->PolyText8($drawable, $gc, ($x, $y),
- ($font OR [$delta, $string]), ...)</PRE>
- <PRE>
- $x->PolyText16($drawable, $gc, ($x, $y),
- ($font OR [$delta, $string]), ...)</PRE>
- <PRE>
- $x->ImageText8($drawable, $gc, ($x, $y), $string)</PRE>
- <PRE>
- $x->ImageText16($drawable, $gc, ($x, $y), $string)</PRE>
- <PRE>
- $x->CreateColormap($mid, $visual, $window, $alloc)</PRE>
- <PRE>
- $x->FreeColormap($cmap)</PRE>
- <PRE>
- $x->CopyColormapAndFree($mid, $src_cmap)</PRE>
- <PRE>
- $x->InstallColormap($cmap)</PRE>
- <PRE>
- $x->UninstallColormap($cmap)</PRE>
- <PRE>
- $x->ListInstalledColormaps($window)
- =>
- @cmaps</PRE>
- <PRE>
- $x->AllocColor($cmap, ($red, $green, $blue))
- =>
- ($pixel, ($red, $green, $blue))</PRE>
- <PRE>
- $x->AllocNamedColor($cmap, $name)
- =>
- ($pixel, ($exact_red, $exact_green, $exact_blue),
- ($visual_red, $visual_green, $visual_blue))</PRE>
- <PRE>
- $x->AllocColorCells($cmap, $colors, $planes, $contiguous)
- =>
- ([@pixels], [@masks])</PRE>
- <PRE>
- $x->AllocColorPlanes($cmap, $colors, ($reds, $greens, $blues),
- $contiguous)
- =>
- (($red_mask, $green_mask, $blue_mask), @pixels)</PRE>
- <PRE>
- $x->FreeColors($cmap, $plane_mask, @pixels)</PRE>
- <PRE>
- $x->StoreColors($cmap, [$pixel, $red, $green, $blue, $do_mask], ...)</PRE>
- <P>The 1, 2, and 4 bits in $mask are do-red, do-green, and do-blue. $mask can
- be omitted, defaulting to 7, the usual case -- change the whole color.</P>
- <PRE>
- $x->StoreNamedColor($cmap, $pixel, $name, $do_mask)</PRE>
- <P>$do_mask has the same interpretation as above, but is mandatory.</P>
- <PRE>
- $x->QueryColors($cmap, @pixels)
- =>
- ([$red, $green, $blue], ...)</PRE>
- <PRE>
- $x->LookupColor($cmap, $name)
- =>
- (($exact_red, $exact_green, $exact_blue),
- ($visual_red, $visual_green, $visual_blue))</PRE>
- <PRE>
- $x->CreateCursor($cid, $source, $mask,
- ($fore_red, $fore_green, $fore_blue),
- ($back_red, $back_green, $back_blue),
- ($x, $y))</PRE>
- <PRE>
- $x->CreateGlyphCursor($cid, $source_font, $mask_font,
- $source_char, $mask_char,
- ($fore_red, $fore_green, $fore_blue),
- ($back_red, $back_green, $back_blue))
- </PRE>
- <PRE>
-
- $x->FreeCursor($cursor)</PRE>
- <PRE>
- $x->RecolorCursor($cursor, ($fore_red, $fore_green, $fore_blue),
- ($back_red, $back_green, $back_blue))</PRE>
- <PRE>
- $x->QueryBestSize($class, $drawable, $width, $height)
- =>
- ($width, $height)</PRE>
- <PRE>
- $x->QueryExtension($name)
- =>
- ($major_opcode, $first_event, $first_error)</PRE>
- <P>If the extension is not present, an empty list is returned.</P>
- <PRE>
- $x->ListExtensions
- =>
- (@names)</PRE>
- <PRE>
- $x->ChangeModifierMapping($first_keycode, $keysysms_per_keycode,
- @keysyms)</PRE>
- <PRE>
- $x->GetKeyboardMapping($first_keycode, $count)
- =>
- ($keysysms_per_keycode, [$keysym, ...], [$keysym, ...], ...)</PRE>
- <PRE>
- $x->ChangeKeyboardControl('attribute' => $value, ...)</PRE>
- <PRE>
- $x->GetKeyboardControl
- =>
- ('global_auto_repeat' => $global_auto_repeat, ...)</PRE>
- <PRE>
- $x->Bell($percent)</PRE>
- <PRE>
- $x->ChangePointerControl($do_acceleration, $do_threshold,
- $acceleration_numerator,
- $acceleration_denominator, $threshold)</PRE>
- <PRE>
- $x->GetPointerControl
- =>
- ($accerleration_numerator, $acceleration_denominator, $threshold)</PRE>
- <PRE>
- $x->SetScreenSaver($timeout, $interval, $prefer_blanking,
- $allow_exposures)</PRE>
- <PRE>
- $x->GetScreenSaver
- =>
- ($timeout, $interval, $prefer_blanking, $allow_exposures)</PRE>
- <PRE>
- $x->ChangeHosts($mode, $host_family, $host_address)</PRE>
- <PRE>
- $x->ListHosts
- =>
- ($mode, [$family, $host], ...)</PRE>
- <PRE>
- $x->SetAccessControl($mode)</PRE>
- <PRE>
- $x->SetCloseDownMode($mode)</PRE>
- <PRE>
- $x->KillClient($resource)</PRE>
- <PRE>
- $x->RotateProperties($win, $delta, @props)</PRE>
- <PRE>
- $x->ForceScreenSaver($mode)</PRE>
- <PRE>
- $x->SetPointerMapping(@map)
- =>
- $status</PRE>
- <PRE>
- $x->GetPointerMapping
- =>
- @map</PRE>
- <PRE>
- $x->SetModifierMapping(@keycodes)
- =>
- $status</PRE>
- <PRE>
- $x->GetModiferMapping
- =>
- @keycodes</PRE>
- <PRE>
- $x->NoOperation($length)</PRE>
- <P>$length specifies the length of the entire useless request, in four byte units,
- and is optional.</P>
- <P>
- <HR>
- <H1><A NAME="events">EVENTS</A></H1>
- <P>To receive events, first set the 'event_mask' attribute on a window to
- indicate what types of events you desire (see
- <A HREF="#pack_event_mask">pack_event_mask</A>). Then, set the protocol object's 'event_handler'
- to a subroutine reference that will handle the events. Alternatively,
- set 'event_handler' to 'queue', and retrieve events using
- dequeue_event(). In both cases, events are returned as a hash. For
- instance, a typical MotionNotify event might look like this:</P>
- <PRE>
- %event = ('name' => 'MotionNotify', 'sequence_number' => 12,
- 'state' => 0, 'event' => 58720256, 'root' => 43,
- 'child' => None, 'same_screen' => 1, 'time' => 966080746,
- 'detail' => 'Normal', 'event_x' => 10, 'event_y' => 3,
- 'code' => 6, 'root_x' => 319, 'root_y' => 235)</PRE>
- <P>
- <H2><A NAME="pack_event_mask">pack_event_mask</A></H2>
- <PRE>
- $mask = $x->pack_event_mask('ButtonPress', 'KeyPress', 'Exposure');</PRE>
- <P>Make an event mask (suitable as the 'event_mask' of a window) from a list
- of strings specifying event types.</P>
- <P>
- <H2><A NAME="unpack_event_mask">unpack_event_mask</A></H2>
- <PRE>
- @event_types = $x->unpack_event_mask($mask);</PRE>
- <P>The inverse operation; convert an event mask obtained from the server into a
- list of names of event categories.</P>
- <P>
- <H2><A NAME="dequeue_event">dequeue_event</A></H2>
- <PRE>
- %event = $x->dequeue_event;</PRE>
- <P>If there is an event waiting in the queue, return it.</P>
- <P>
- <H2><A NAME="next_event">next_event</A></H2>
- <PRE>
- %event = $x->next_event;</PRE>
- <P>Like Xlib's XNextEvent(), this function is equivalent to</P>
- <PRE>
- $x->handle_input until %event = dequeue_event;</PRE>
- <P>
- <H2><A NAME="pack_event">pack_event</A></H2>
- <PRE>
- $data = $x->pack_event(%event);</PRE>
- <P>Given an event in hash form, pack it into a string. This is only useful as
- an argument to SendEvent().</P>
- <P>
- <H2><A NAME="unpack_event">unpack_event</A></H2>
- <PRE>
- %event = $x->unpack_event($data);</PRE>
- <P>The inverse operation; given the raw data for an event (32 bytes), unpack it
- into hash form. Normally, this is done automatically.</P>
- <P>
- <HR>
- <H1><A NAME="extensions">EXTENSIONS</A></H1>
- <P>Protocol extensions add new requests, event types, and error types to
- the protocol. Support for them is compartmentalized in modules in the
- X11::Protocol::Ext:: hierarchy. For an example, see
- <A HREF="../../../X11/Protocol/Ext:SHAPE.html">the X11::Protocol::Ext:SHAPE manpage</A>. You can tell if the module has loaded an
- extension by looking at</P>
- <PRE>
- $x->{'ext'}{$extension_name}</PRE>
- <P>If the extension has been initialized, this value will be an array reference,
- [$major_request_number, $first_event_number, $first_error_number, $obj], where
- $obj is an object containing information private to the extension.</P>
- <P>
- <H2><A NAME="init_extension">init_extension</A></H2>
- <PRE>
- $x->init_extension($name);</PRE>
- <P>Initialize an extension: query the server to find the extension's request
- number, then load the corresponding module. Returns 0 if the server does
- not support the named extension, or if no module to interface with it exists.</P>
- <P>
- <H2><A NAME="init_extensions">init_extensions</A></H2>
- <PRE>
- $x->init_extensions;</PRE>
- <P>Initialize protocol extensions. This does a ListExtensions request, then calls
- <CODE>init_extension()</CODE> for each extension that the server supports.</P>
- <P>
- <HR>
- <H1><A NAME="writing extensions">WRITING EXTENSIONS</A></H1>
- <P>Internally, the X11::Protocol module is table driven. All an extension has to
- do is to add new add entries to the protocol object's tables. An extension
- module should <CODE>use X11::Protocol</CODE>, and should define an <CODE>new()</CODE> method</P>
- <PRE>
- X11::Protocol::Ext::NAME
- ->new($x, $request_num, $event_num, $error_num)</PRE>
- <P>where $x is the protocol object and $request_num, $event_num and $error_num
- are the values returned by QueryExtension().</P>
- <P>The <CODE>new()</CODE> method should add new types of constant like</P>
- <PRE>
- $x->{'ext_const'}{'ConstantType'} = ['Constant', 'Constant', ...]</PRE>
- <P>and set up the corresponding name to number translation hashes like</P>
- <PRE>
- $x->{'ext_const_num'}{'ConstType'} =
- {make_num_hash($x->{'ext_const'}{'ConstType'})}</PRE>
- <P>Event names go in</P>
- <PRE>
- $x->{'ext_const'}{'Events'}[$event_number]</PRE>
- <P>while specifications for event contents go in</P>
- <PRE>
- $x->{'ext_event'}[$event_number]</PRE>
- <P>each element of which is either <CODE>[\&unpack_sub, \&pack_sub]</CODE> or
- <CODE>[$pack_format, $field, $field, ...]</CODE>, where each $field is <CODE>'name'</CODE>,
- <CODE>['name', 'const_type']</CODE>, or <CODE>['name', ['special_name_for_zero',
- 'special_name_for_one']]</CODE>, where <CODE>'special_name_for_one'</CODE> is optional.</P>
- <P>Finally,</P>
- <PRE>
- $x->{'ext_request'}{$major_request_number}</PRE>
- <P>should be an array of arrays, with each array either <CODE>[$name, \&packit]</CODE> or
- <CODE>[$name, \&packit, \&unpackit]</CODE>, and</P>
- <PRE>
- $x->{'ext_request_num'}{$request_name}</PRE>
- <P>should be initialized with <CODE>[$minor_num, $major_num]</CODE> for each request the
- extension defines. For examples of code that does all of this, look at
- X11::Protocol::Ext::SHAPE.</P>
- <P>X11::Protocol exports several functions that might be useful in extensions
- (note that these are <EM>not</EM> methods).</P>
- <P>
- <H2><A NAME="padding">padding</A></H2>
- <PRE>
- $p = padding $x;</PRE>
- <P>Given an integer, compute the number need to round it up to a multiple of 4.
- For instance, <CODE>padding(5)</CODE> is 3.</P>
- <P>
- <H2><A NAME="pad">pad</A></H2>
- <PRE>
- $p = pad $str;</PRE>
- <P>Given a string, return the number of extra bytes needed to make a multiple
- of 4. Equivalent to <CODE>padding(length($str))</CODE>.</P>
- <P>
- <H2><A NAME="padded">padded</A></H2>
- <PRE>
- $data = pack(padded($str), $str);</PRE>
- <P>Return a format string, suitable for pack(), for a string padded to a multiple
- of 4 bytes. For instance, <A HREF="../../../lib/Pod/perlfunc.html#item_pack"><CODE>pack(padded('Hello'), 'Hello')</CODE></A> gives
- <CODE>"Hello\0\0\0"</CODE>.</P>
- <P>
- <H2><A NAME="hexi">hexi</A></H2>
- <PRE>
- $str = hexi $n;</PRE>
- <P>Format a number in hexidecimal, and add a ``0x'' to the front.</P>
- <P>
- <H2><A NAME="make_num_hash">make_num_hash</A></H2>
- <PRE>
- %hash = make_num_hash(['A', 'B', 'C']);</PRE>
- <P>Given a reference to a list of strings, return a hash mapping the strings onto
- numbers representing their position in the list, as used by
- <CODE>$x->{'ext_const_num'}</CODE>.</P>
- <P>
- <HR>
- <H1><A NAME="bugs">BUGS</A></H1>
- <P>This module is too big (~2500 lines), too slow (10 sec to load on a slow
- machine), too inefficient (request args are copied several times), and takes
- up too much memory (3000K for basicwin).</P>
- <P>If you have more than 65535 replies outstanding at once, sequence numbers
- can collide.</P>
- <P>The protocol is too complex.</P>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Stephen McCamant <<A HREF="mailto:alias@mcs.com">alias@mcs.com</A>>.</P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><EM>perl(1)</EM>,
- <EM>X(1)</EM>,
- <A HREF="../../../site/lib/X11/Keysyms.html">the X11::Keysyms manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Ext/SHAPE.html">the X11::Protocol::Ext::SHAPE manpage</A>,
- <A HREF="../../../site/lib/X11/Protocol/Ext/BIG_REQUESTS.html">the X11::Protocol::Ext::BIG_REQUESTS manpage</A>,
- <A HREF="../../../site/lib/X11/Auth.html">the X11::Auth manpage</A>,
- <EM>X Window System Protocol (X Version 11)</EM>,
- <EM>Inter-Client Communications Conventions Manual</EM>,
- <EM>X Logical Font Description Conventions</EM>.</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> X11::Protocol - Perl module for the X Window System Protocol, version 11</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-