Hi Larry and Friends,
Fedora 28
`NativeCall` is a total mystery to me.
I asked the guys on they "C" newsgroup how they
did it and they only got crabby with me.
Sometimes an example is work a 1000 words. Would you mind
throwing together an example of how to use NativeCall
to talk to XGetWindowAttributes?
man XGetWindowAttributes
https://tronche.com/gui/x/xlib/window-information/XGetWindowAttributes.html
The last time I tried this, I had to press Power On Reset
(POR) on my CPU. So I stopped trying.
So far, I have managed to get this to work, but more
complicated than that and it is the magic one finger
reset:
sub GetXDisplay () is export {
#`{
reference: man XDisplayName
char *XDisplayName(char *string);
sub display-name(Str:D $name) is native('X11') is
symbol("XDisplayName") { * }
reference:
https://tronche.com/gui/x/xlib/event-handling/protocol-errors/XDisplayName.html
The XDisplayName() function returns the name of the display
that XOpenDisplay()
would attempt to use. If a NULL string is specified,
XDisplayName() looks in the
environment for the display and returns the display name that
XOpenDisplay() would
attempt to use. This makes it easier to report to the user
precisely which display
the program attempted to open when the initial connection
attempt failed.
}
my $Display;
my $NullStr; # Do not initialize this guy!
# char *XDisplayName(char *string);
sub XDisplayName(Str:D $name) is native('X11') returns Str { * };
$Display = XDisplayName( $NullStr );
return $Display;
}
Many thanks,
-T
XGetWindowAttributes:
typedef struct {
int x, y; /* location of window */
int width, height; /* width and height of window */
int border_width; /* border width of window */
int depth; /* depth of window */
Visual *visual; /* the associated visual structure */
Window root; /* root of screen containing window */
int class; /* InputOutput, InputOnly*/
int bit_gravity; /* one of the bit gravity values */
int win_gravity; /* one of the window gravity values */
int backing_store; /* NotUseful, WhenMapped, Always */
unsigned long backing_planes; /* planes to be preserved if possible */
unsigned long backing_pixel; /* value to be used when restoring
planes */
Bool save_under; /* boolean, should bits under be saved?
*/
Colormap colormap; /* color map to be associated with
window */
Bool map_installed; /* boolean, is color map currently
installed*/
int map_state; /* IsUnmapped, IsUnviewable, IsViewable
*/
long all_event_masks; /* set of events all people have
interest in*/
long your_event_mask; /* my event mask */
long do_not_propagate_mask; /* set of events that should not
propagate */
Bool override_redirect; /* boolean value for override-redirect
*/
Screen *screen; /* back pointer to correct screen */
} XWindowAttributes;