cspctec:

At first, I was going to suggest that you add the RaiseWindow function to X11::Protocol, but it turns out that the function doesn't exist. (The stuff below the line shows what I was going to suggest.

It seems that to raise a window to the top of the stack, you call the ConfigureRequest function, giving it the stack mode "Above" to bring it to the top. Since ConfigureRequest is in the X11::Protocol package, you should be able to call that to take care of it.


I did a brief review of the X11::Protocol code, and it looks like it wouldn't be too difficult to add XRaiseWindow. The code appears to simply format binary packets according to the X11 protocol, and it seems to do so in a straightforward manner. So it may be an easy matter to simply add the function(s) you want. If you do so, be sure to submit a patch to the author for inclusion.

For example, here's the bit of code that packs up the "CreateWindow" message:

['CreateWindow', sub { my $self = shift; my($wid, $parent, $class, $depth, $visual, $x, $y, $width, $height, $border_width, %values) = @_; my($mask, $i, @values); $mask = 0; for $i (0 .. 14) { if (exists $values{$Attributes_ValueMask[$i][0]}) { $mask |= (1 << $i); push @values, &{$Attributes_ValueMask[$i][1]} ($self, $values{$Attributes_ValueMask[$i][0]}); } } $visual = 0 if $visual eq 'CopyFromParent'; $class = $self->num('Class', $class); return pack("LLssSSSSLL", $wid, $parent, $x, $y, $width, $height, $border_width, $class, $visual, $mask) . join("", @values), $depth; }],

Notice how similar the parameter list is to the X11 specification:

CreateWindow

wid, parent: WINDOW class: { InputOutput, InputOnly, CopyFromParent} depth: CARD8 visual: VISUALID or CopyFromParent x, y: INT16 width, height, border-width: CARD16 value-mask: BITMASK value-list: LISTofVALUE Errors: Alloc, Colormap, Cursor, IDChoice, Match, Pixmap, Value, Window

So all we need to do is find the interface for the raise window function, and create a similar packing routine to do the job.

Hmmm ... let me see ... RaiseWindow ... doesn't seem to exist....

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: x window programming in perl by roboticus
in thread x window programming in perl by cspctec

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.