This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Console Hiding (was:xterm is a console program?)


"Harold L Hunt II" <huntharo@msu.edu> wrote:
> In general reply, could you repost (in a new thread) a description of
> your work-around and any source code involved?  The source code doesn't
> have to be readily compilable (i.e., we don't need a Makefile), but I
> would like to see it to be able to evaluate the nature of the solution.

The code is attached.

It demonstrates a few techniques:

1. A portable GetConsoleWindow function (GetConsoleHWND) that should work on
all Cygwin-supported flavors of Windows.

2. A function for determining if the console window is "owned" by the
calling process (OwnTheConsole).

3. A function that hides the console window if (and only if) the calling
process owns it (HideTheConsoleIfOwner).

4. A simple main() that calls HideTheConsoleIfOwner, writes to the console
using std::clog, and then displays a MessagBox.

If you launch this application using start->run, by double clicking it in
explorer, or in a similar manner where you would expect it to not display a
console/terminal, the console will appear momentarily and then disappear.
This is not exactly the behavior you would see on a Unix box, but at least
the console doesn't stick around for the lifetime of the application.

If you launch this application from a console program or from an xterm, no
console will appear, AND the output that it sends to the console will be
visible.

My suggestion was to insert a call to HideTheConsoleIfOwner into the startup
for some library that only X clients use, thereby making all X clients
instantaneously have the same behavior as the sample code.  I suggested the
X11 client library

Another possibility which you would be better able to evaluate, since you
are the XWin guru, is to have XWin detect if a program requesting a window
owns its console and hide the console on that program's behalf.  I doubt
this is very feasible because you wouldn't have access to SetConsoleTitle
unless you did something wacky like a StartRemoteThread (yech).  And
besides, that wouldn't help if you were running an X client on one windows
box but displaying it on another.  Never mind on the whole notion of having
it in XWin.

--
-- Early Ehlinger CEO, ResPower Inc - Toll-Free : 866-737-7697
-- www.respower.com -- 500+ GHz Supercomputer Starting At USD$0.50/GHz*Hour




begin 666 test.cpp
M(VEN8VQU9&4@/'=I;F1O=W,N:#X-"@T*(VEN8VQU9&4@/&EO<W1R96%M/@T*
M#0IC:&%R(&-O;G-T('1I=&QE6UT@/2 B.#@V9&4P-SDM.&1F,"TT-#@T+6$T
M-S(M83!D8F$V8C@X-&1E(CL-"@T*2%=.1"!'971#;VYS;VQE5VEN9&]W4')E
M,FLH("D-"B @>PT*(" @(&-H87(@8G5F9F5R6R!-05A?4$%42"!=.PT*(" @
M(&EF("@@(4=E=$-O;G-O;&54:71L92@@8G5F9F5R("P@34%87U!!5$@@*2 I
M#0H@(" @("!R971U<FX@3E5,3#L@+R\@;F\@8V]N<V]L92X-"B @(" -"B @
M(" O+PT*(" @("\O($Y/5$4Z(%1H97)E(&ES(&$@<&]S<VEB;&4@<F%C92!C
M;VYD:71I;VX@:&5R93H-"B @(" O+PT*(" @("\O($ET(&ES(&-O;F-E:79A
M8FQE('1H870@86YO=&AE<B!P<F]C97-S(&EN('1H:7,@<')O8V5S<R!G<F]U
M< T*(" @("\O('=I;&P@8VAA;F=E('1H92!C;VYS;VQE('1I=&QE(&)E9F]R
M92!&:6YD5VEN9&]W+"!L96%V:6YG('5S#0H@(" @+R\@8F5L:65V:6YG('1H
M870@=V4@9&\@;F]T(&AA=F4@82!C;VYS;VQE+@T*(" @("\O#0H@(" @+R\@
M270@:7,@86QS;R!P;W-S:6)L92!T:&%T(&%N;W1H97(@<')O8V5S<R!W:6QL
M('-E="!T:&4@8V]N<V]L90T*(" @("\O('1I=&QE(&%N9"!W92!W:6QL(&-L
M;V)B97(@=&AA="!C:&%N9V4@=VET:"!T:&4@;W)I9VEN86P@8V]N<V]L92!T
M:71L92X-"B @(" O+PT*(" @("\O($)O=&@@;V8@=&AE<V4@<V-E;F%R:6]S
M('-E96T@<F%T:&5R('5N;&EK96QY+"!B=70@:70@=V]U;&0@8F4-"B @(" O
M+R!W;W)T:'=H:6QE('1O(&9I;F0@<V]L=71I;VYS(&EF(&%T(&%L;"!P;W-S
M:6)L92 M(%-E='1I;F<@<')I;W)I='D-"B @(" O+R!F;W(@=&AE(&1U<F%T
M:6]N(&]F('1H:7,@8V%L;"!A;F0@=7-I;F<@82!M=71E>"!T;R!E;G-U<F4@
M=&AA="!A="!L96%S= T*(" @("\O(&YO(&]T:&5R("AC;VUP;&EA;G0I('!R
M;V-E<W,@;6]D:69I97,@82!C;VYS;VQE('1I=&QE('-I;75L=&%N96]U<VQY
M#0H@(" @+R\@87)E('1W;R!P;W-S:6)L92!S;VQU=&EO;G,N#0H@(" @+R\@
M#0H@(" @4V5T0V]N<V]L951I=&QE*"!T:71L92 I.PT*(" @($A73D0@:$-O
M;G-O;&4@/2!&:6YD5VEN9&]W*"!.54Q,("P@=&ET;&4@*3L-"B @("!3971#
M;VYS;VQE5&ET;&4H(&)U9F9E<B I.PT*#0H@(" @<F5T=7)N(&A#;VYS;VQE
M.PT*("!]#0H-"DA73D0@1V5T0V]N<V]L94A73D0H("D-"B @>PT*(" @("\O
M(%!S975D;RUC;V1E.@T*(" @("\O(&EF("@@<G5N;FEN9U]O;E]R96-E;G1?
M=VEN9&]W<R I#0H@(" @+R\@("!,;V%D3&EB<F%R>2]'9710<F]C061D<F5S
M<R!T;R!F:6YD($=E=$-O;G-O;&57:6YD;W<@=VEN,S(@87!I#0H@(" @+R\@
M("!C86QL('1H870@86YD(')E='5R;B!T:&4@<F5S=6QT+@T*(" @(')E='5R
M;B!'971#;VYS;VQE5VEN9&]W4')E,FLH("D[#0H@('T-"@T*8F]O;"!/=VY4
M:&5#;VYS;VQE*"!(5TY$*B!P:$-O;G-O;&4@*0T*("![#0H@(" @2%=.1"!H
M0V]N<V]L92 ]($=E=$-O;G-O;&5(5TY$*" I.PT*(" @(&EF("@@<&A#;VYS
M;VQE("D-"B @(" @("IP:$-O;G-O;&4@/2!H0V]N<V]L93L-"@T*(" @(&EF
M("@@(6A#;VYS;VQE("D-"B @(" @(')E='5R;B!F86QS93L-"@T*(" @($17
M3U)$(&1W4')O8V5S<TED.PT*(" @($173U)$(&1W5&AR96%D260@/2!'9717
M:6YD;W=4:')E8610<F]C97-S260H(&A#;VYS;VQE("P@)F1W4')O8V5S<TED
M("D[#0H@(" @:68@*"!D=U!R;V-E<W-)9" ]/2!'971#=7)R96YT4')O8V5S
M<TED*" I("D-"B @(" @(')E='5R;B!T<G5E.PT*(" @(&5L<V4-"B @(" @
M(')E='5R;B!F86QS93L-"B @?0T*#0IV;VED($AI9&54:&5#;VYS;VQE269/
M=VYE<B@@*0T*("![#0H@(" @2%=.1"!H0V]N<V]L93L-"@T*(" @("\J($EF
M('1H:7,@87!P(&ES('1H92!O=VYE<B!O9B!T:&4@8V]N<V]L92P@=&AE;B!I
M="!W87,@;&%U;F-H960-"B @(" @("!V:6$@<VAO<G1C=70L(&1O=6)L92!C
M;&EC:R!I;B!E>'!L;W)E<BP@;W(@<VEM:6QA<BP@86YD('=E(&YE960-"B @
M(" @("!T;R!H:61E('1H92!C;VYS;VQE('=I;F1O=RX@($]T:&5R=VES92P@
M:70@:7,@8F5I;F<@;&%U;F-H960@#0H@(" @(" @9G)O;2!A(&-O;G-O;&4@
M86YD(&ET<R!T97AT($DO3R!F=6YC=&EO;G,@<VAO=6QD('=O<FL@86-C;W)D
M:6YG;'DN("HO#0H@(" @:68@*"!/=VY4:&5#;VYS;VQE*" F:$-O;G-O;&4@
M*2 I#0H@(" @("!3:&]W5VEN9&]W*"!H0V]N<V]L92 L(%-77TA)1$4@*3L-
M"B @?0T*#0II;G0@;6%I;B@@*0T*("![#0H@(" @2&ED951H94-O;G-O;&5)
M9D]7;F5R*" I.PT*(" @('-T9#HZ8VQO9R \/" B2&5R92!I<R!S;VUE(&1E
M8G5G('-T=69F+B(@/#P@<W1D.CIE;F1L.PT*(" @($UE<W-A9V5";W@H($Y5
I3$P@+" B2&5L;&\@5V]R;&0B("P@(DAA:&$B("P@," I.PT*("!]#0H`
`
end



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]