Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGClient.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 27/12/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGClient
25 \ingroup guiwidgets
26
27Window client. In client server windowing systems, like X11 this
28class is used to make the initial connection to the window server.
29
30*/
31
32
33#include "RConfigure.h"
34
35#include "TGClient.h"
36#include "TROOT.h"
37#include "TApplication.h"
38#include "TSystem.h"
39#include "TEnv.h"
40#include "THashList.h"
41#include "TSysEvtHandler.h"
42#include "TVirtualX.h"
43#include "TGWindow.h"
44#include "TGResourcePool.h"
45#include "TGGC.h"
46#include "TGFont.h"
47#include "TGMimeTypes.h"
48#include "TGFrame.h"
49#include "TGIdleHandler.h"
50#include "TError.h"
51#include "TGlobal.h"
52#include "snprintf.h"
53
54// Global pointer to the TGClient object
55static TGClient *gClientGlobal = nullptr;
56
57namespace {
58static struct AddPseudoGlobals {
59AddPseudoGlobals() {
60 // User "gCling" as synonym for "libCore static initialization has happened".
61 // This code here must not trigger it
62 TGlobalMappedFunction::MakeFunctor("gClient", "TGClient*", TGClient::Instance, [] {
63 TGClient::Instance(); // first ensure object is created;
64 return (void *) &gClientGlobal;
65 });
66}
67} gAddPseudoGlobals;
68}
69
70// Initialize gClient in case libGui is loaded in batch mode
73public:
76 if (rootlocal && rootlocal->IsBatch()) {
77 // For now check if the header files (or the module containing them)
78 // has been loaded in Cling.
79 // This is required because the dictionaries must be initialized
80 // __before__ the TGClient creation which will induce the creation
81 // of a TClass object which will need the dictionary for TGClient!
83 new TGClient();
84 }
86 }
87};
89
90////////////////////////////////////////////////////////////////////////////////
91/// Returns global gClient (initialize graphics first, if not already done)
92
94{
97 return gClientGlobal;
98}
99
100//----- Graphics Input handler -------------------------------------------------
101////////////////////////////////////////////////////////////////////////////////
102
104private:
105 TGClient *fClient; // connection to display server
106public:
108 Bool_t Notify() override;
109 // Important: don't override ReadNotify()
110};
111
112////////////////////////////////////////////////////////////////////////////////
113/// Notify input from the display server.
114
116{
117 return fClient->HandleInput();
118}
119
120
122
123////////////////////////////////////////////////////////////////////////////////
124/// Create a connection with the display sever on host dpyName and setup
125/// the complete GUI system, i.e., graphics contexts, fonts, etc. for all
126/// widgets.
127
128TGClient::TGClient(const char *dpyName)
129{
130 fRoot = 0;
131 fPicturePool = 0;
132 fMimeTypeList = 0;
133 fWlist = 0;
134 fPlist = 0;
135 fUWHandlers = 0;
136 fIdleHandlers = 0;
137
138 if (gClientGlobal) {
139 Error("TGClient", "only one instance of TGClient allowed");
140 MakeZombie();
141 return;
142 }
143
144 // Set DISPLAY based on utmp (only if DISPLAY is not yet set).
146
147 // Open the connection to the display
148 if ((fXfd = gVirtualX->OpenDisplay(dpyName)) < 0) {
149 MakeZombie();
150 return;
151 }
152
153 if (fXfd >= 0 && !ROOT::Internal::gROOTLocal->IsBatch()) {
154 TGInputHandler *xi = new TGInputHandler(this, fXfd);
155 if (fXfd) gSystem->AddFileHandler(xi);
156 // X11 events are handled via gXDisplay->Notify() in
157 // TUnixSystem::DispatchOneEvent(). When no events available we wait for
158 // events on all TFileHandlers including this one via a select() call.
159 // However, X11 events are always handled via gXDisplay->Notify() and not
160 // via the ReadNotify() (therefore TGInputHandler should not override
161 // TFileHandler::ReadNotify()).
162 gXDisplay = xi;
163 }
164
165 // Initialize internal window list. Use a THashList for fast
166 // finding of windows based on window id (see GetWindowById()).
167
168 fWlist = new THashList(200);
169 fPlist = new TList;
170
171 // Create root window
172
173 fDefaultRoot = fRoot = new TGFrame(this, gVirtualX->GetDefaultRootWindow());
174
175 // Setup some atoms (defined in TVirtualX)...
176
177 gWM_DELETE_WINDOW = gVirtualX->InternAtom("WM_DELETE_WINDOW", kFALSE);
178 gMOTIF_WM_HINTS = gVirtualX->InternAtom("_MOTIF_WM_HINTS", kFALSE);
179 gROOT_MESSAGE = gVirtualX->InternAtom("_ROOT_MESSAGE", kFALSE);
180
181 // Create the graphics event handler, an object for the root window,
182 // a picture pool, mimetype list, etc...
183
188
189 fResourcePool = new TGResourcePool(this);
190
194
197
198 // Set some color defaults...
199
208
209 fStyle = 0;
210 TString style = gEnv->GetValue("Gui.Style", "modern");
211 if (style.Contains("flat", TString::kIgnoreCase))
212 fStyle = 2;
213 else if (style.Contains("modern", TString::kIgnoreCase))
214 fStyle = 1;
215
216 gClientGlobal = this;
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Returns current root (i.e. base) window. By changing the root
221/// window one can change the window hierarchy, e.g. a top level
222/// frame (TGMainFrame) can be embedded in another window.
223
225{
226 return fRoot;
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Returns the root (i.e. desktop) window. Should only be used as parent
231/// for frames that will never be embedded, like popups, message boxes,
232/// etc. (like TGToolTips, TGMessageBox, etc.).
233
235{
236 return fDefaultRoot;
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// Sets the current root (i.e. base) window. By changing the root
241/// window one can change the window hierarchy, e.g. a top level
242/// frame (TGMainFrame) can be embedded in another window.
243
245{
246 fRoot = root ? root : fDefaultRoot;
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Set the button style (modern or classic).
251
252void TGClient::SetStyle(const char *style)
253{
254 fStyle = 0;
255 if (style && strstr(style, "modern"))
256 fStyle = 1;
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Get display width.
261
263{
264 Int_t x, y;
265 UInt_t w, h;
266
267 gVirtualX->GetGeometry(-1, x, y, w, h);
268
269 return w;
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Get display height.
274
276{
277 Int_t x, y;
278 UInt_t w, h;
279
280 gVirtualX->GetGeometry(-1, x, y, w, h);
281
282 return h;
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Get picture from the picture pool. Picture must be freed using
287/// TGClient::FreePicture(). If picture is not found 0 is returned.
288
290{
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// Get picture with specified size from pool (picture will be scaled if
296/// necessary). Picture must be freed using TGClient::FreePicture(). If
297/// picture is not found 0 is returned.
298
300 UInt_t new_width, UInt_t new_height)
301{
302 return fPicturePool->GetPicture(name, new_width, new_height);
303}
304
305////////////////////////////////////////////////////////////////////////////////
306/// Free picture resource.
307
309{
310 if (pic) fPicturePool->FreePicture(pic);
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Get graphics context from the gc pool. Context must be freed via
315/// TGClient::FreeGC(). If rw is true a new read/write-able GC
316/// is returned, otherwise a shared read-only context is returned.
317/// For historical reasons it is also possible to create directly a
318/// TGGC object, but it is advised to use this new interface only.
319
321{
322 return fGCPool->GetGC(values, rw);
323}
324
325////////////////////////////////////////////////////////////////////////////////
326/// Free a graphics context.
327
329{
330 fGCPool->FreeGC(gc);
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Free a graphics context.
335
337{
338 fGCPool->FreeGC(gc);
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Get a font from the font pool. Fonts must be freed via
343/// TGClient::FreeFont(). Returns 0 in case of error or if font
344/// does not exist. If fixedDefault is false the "fixed" font
345/// will not be substituted as fallback when the asked for font
346/// does not exist.
347
348TGFont *TGClient::GetFont(const char *font, Bool_t fixedDefault)
349{
350 return fFontPool->GetFont(font, fixedDefault);
351}
352
353////////////////////////////////////////////////////////////////////////////////
354/// Get again specified font. Will increase its usage count.
355
357{
358 return fFontPool->GetFont(font);
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Free a font.
363
364void TGClient::FreeFont(const TGFont *font)
365{
366 fFontPool->FreeFont(font);
367}
368
369////////////////////////////////////////////////////////////////////////////////
370/// Set redraw flags.
371
373{
374 if (!w) return;
375 if (gVirtualX->NeedRedraw((ULongptr_t)w,force)) return;
376 if (force) {
377 w->DoRedraw();
378 return;
379 }
380 w->fNeedRedraw = kTRUE;
382}
383
384////////////////////////////////////////////////////////////////////////////////
385
387{
388 w->fNeedRedraw = kFALSE;
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Get a color by name. If color is found return kTRUE and pixel is
393/// set to the color's pixel value, kFALSE otherwise.
394
396{
397 ColorStruct_t color;
399 Bool_t status = kTRUE;
400
401 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
402 color.fPixel = 0;
403 if (!gVirtualX->ParseColor(attributes.fColormap, name, color)) {
404 Error("GetColorByName", "couldn't parse color %s", name);
405 status = kFALSE;
406 } else if (!gVirtualX->AllocColor(attributes.fColormap, color)) {
407 Warning("GetColorByName", "couldn't retrieve color %s.\n"
408 "Please close any other application, like web browsers, "
409 "that might exhaust\nthe colormap and start ROOT again", name);
410 status = kFALSE;
411 }
412
413 pixel = color.fPixel;
414
415 return status;
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Get a font by name. If font is not found, fixed font is returned,
420/// if fixed font also does not exist return 0 and print error.
421/// The loaded font needs to be freed using TVirtualX::DeleteFont().
422/// If fixedDefault is false the "fixed" font will not be substituted
423/// as fallback when the asked for font does not exist.
424
425FontStruct_t TGClient::GetFontByName(const char *name, Bool_t fixedDefault) const
426{
427 if (gROOT->IsBatch())
428 return (FontStruct_t) -1;
429
430 FontStruct_t font = gVirtualX->LoadQueryFont(name);
431
432 if (!font && fixedDefault) {
433 font = gVirtualX->LoadQueryFont("fixed");
434 if (font)
435 Warning("GetFontByName", "couldn't retrieve font %s, using \"fixed\"", name);
436 }
437 if (!font) {
438 if (fixedDefault)
439 Error("GetFontByName", "couldn't retrieve font %s nor backup font \"fixed\"", name);
440 else
441 Warning("GetFontByName", "couldn't retrieve font %s", name);
442 }
443
444 return font;
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Return pixel value of hilite color based on base_color.
449
451{
452 ColorStruct_t color, white_p;
454
455 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
456
457 color.fPixel = base_color;
458 gVirtualX->QueryColor(attributes.fColormap, color);
459
460 GetColorByName("white", white_p.fPixel);
461 gVirtualX->QueryColor(attributes.fColormap, white_p);
462
463 color.fRed = TMath::Max((UShort_t)(white_p.fRed/5), color.fRed);
464 color.fGreen = TMath::Max((UShort_t)(white_p.fGreen/5), color.fGreen);
465 color.fBlue = TMath::Max((UShort_t)(white_p.fBlue/5), color.fBlue);
466
467 color.fRed = (UShort_t)TMath::Min((Int_t)white_p.fRed, (Int_t)(color.fRed*140)/100);
468 color.fGreen = (UShort_t)TMath::Min((Int_t)white_p.fGreen, (Int_t)(color.fGreen*140)/100);
469 color.fBlue = (UShort_t)TMath::Min((Int_t)white_p.fBlue, (Int_t)(color.fBlue*140)/100);
470
471 if (!gVirtualX->AllocColor(attributes.fColormap, color))
472 Error("GetHilite", "couldn't allocate hilight color");
473
474 return color.fPixel;
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Return pixel value of shadow color based on base_color.
479/// Shadow is 60% of base_color intensity.
480
482{
483 ColorStruct_t color;
485
486 gVirtualX->GetWindowAttributes(fRoot->GetId(), attributes);
487
488 color.fPixel = base_color;
489 gVirtualX->QueryColor(attributes.fColormap, color);
490
491 color.fRed = (UShort_t)((color.fRed*60)/100);
492 color.fGreen = (UShort_t)((color.fGreen*60)/100);
493 color.fBlue = (UShort_t)((color.fBlue*60)/100);
494
495 if (!gVirtualX->AllocColor(attributes.fColormap, color))
496 Error("GetShadow", "couldn't allocate shadow color");
497
498 return color.fPixel;
499}
500
501////////////////////////////////////////////////////////////////////////////////
502/// Free color.
503
505{
506 gVirtualX->FreeColor(fDefaultColormap, color);
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Add a TGWindow to the clients list of windows.
511
513{
514 fWlist->Add(w);
515
516 // Emits signal
517 RegisteredWindow(w->GetId());
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Remove a TGWindow from the list of windows.
522
524{
525 fWlist->Remove(w);
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Add a popup menu to the list of popups. This list is used to pass
530/// events to popup menus that are popped up over a transient window which
531/// is waited for (see WaitFor()).
532
534{
535 fPlist->Add(w);
536
537 // Emits signal
538 RegisteredWindow(w->GetId());
539}
540
541////////////////////////////////////////////////////////////////////////////////
542/// Remove a popup menu from the list of popups.
543
545{
546 fPlist->Remove(w);
547}
548
549////////////////////////////////////////////////////////////////////////////////
550/// Add handler for unknown (i.e. unregistered) windows.
551
553{
554 if (!fUWHandlers) {
555 fUWHandlers = new TList;
557 }
558
559 fUWHandlers->Add(h);
560}
561
562////////////////////////////////////////////////////////////////////////////////
563/// Remove handler for unknown (i.e. unregistered) windows.
564
566{
568}
569
570////////////////////////////////////////////////////////////////////////////////
571/// Add handler for idle events.
572
574{
575 if (!fIdleHandlers) {
576 fIdleHandlers = new TList;
578 }
579
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Remove handler for idle events.
585
587{
589}
590
591////////////////////////////////////////////////////////////////////////////////
592/// Find a TGWindow via its handle. If window is not found return 0.
593
595{
596 TGWindow wt(wid);
597
598 return (TGWindow *) fWlist->FindObject(&wt);
599}
600
601////////////////////////////////////////////////////////////////////////////////
602/// Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
603/// If window is not found return 0.
604
606{
607 TIter next(fWlist);
608
609 TObject *obj;
610 while ((obj = next())) {
611 TString n = obj->GetName();
612 if (n == name) {
613 return (TGWindow*)obj;
614 }
615 }
616 return 0;
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Closing down client: cleanup and close X connection.
621
623{
624 if (IsZombie())
625 return;
626
627 if (fWlist)
628 fWlist->Delete("slow");
629 delete fWlist;
630 delete fPlist;
631 delete fUWHandlers;
632 delete fIdleHandlers;
633 delete fResourcePool;
634
635 gVirtualX->CloseDisplay(); // this should do a cleanup of the remaining
636 // X allocated objects...
637}
638
639////////////////////////////////////////////////////////////////////////////////
640/// Process one event. This method should only be called when there is
641/// a GUI event ready to be processed. If event has been processed
642/// kTRUE is returned. If processing of a specific event type for a specific
643/// window was requested kFALSE is returned when specific event has been
644/// processed, kTRUE otherwise. If no more pending events return kFALSE.
645
647{
648 Event_t event;
649
650 if (!fRoot) return kFALSE;
651 if (gVirtualX->EventsPending()) {
652 gVirtualX->NextEvent(event);
653 if (fWaitForWindow == kNone) {
654 HandleEvent(&event);
655 if (fForceRedraw)
656 DoRedraw();
657 return kTRUE;
658 } else {
660 if ((event.fType == fWaitForEvent) && (event.fWindow == fWaitForWindow))
662 if (fForceRedraw)
663 DoRedraw();
664 return kTRUE;
665 }
666 }
667
668 // if nothing else to do redraw windows that need redrawing
669 if (DoRedraw()) return kTRUE;
670
671 // process one idle event if there is nothing else to do
672 if (ProcessIdleEvent()) return kTRUE;
673
674 return kFALSE;
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// Process one idle event.
679
681{
682 if (fIdleHandlers) {
684 if (ih) {
686 ih->HandleEvent();
687 return kTRUE;
688 }
689 }
690 return kFALSE;
691}
692
693////////////////////////////////////////////////////////////////////////////////
694/// Handles input from the display server. Returns kTRUE if one or more
695/// events have been processed, kFALSE otherwise.
696
698{
699 Bool_t handledevent = kFALSE;
700
701 while (ProcessOneEvent())
702 handledevent = kTRUE;
703 return handledevent;
704}
705
706////////////////////////////////////////////////////////////////////////////////
707/// Wait for window to be destroyed.
708
710{
711 Window_t wsave = fWaitForWindow;
713
714 fWaitForWindow = w->GetId();
716
717 //Let VirtualX know, that we are
718 //in a nested loop for a window w.
719 //Noop on X11/win32gdk.
720 if (gVirtualX)
721 gVirtualX->BeginModalSessionFor(w->GetId());
722
723 while (fWaitForWindow != kNone) {
724 if (esave == kUnmapNotify)
725 wsave = kNone;
726 gSystem->ProcessEvents();//gSystem->InnerLoop();
727 gSystem->Sleep(5);
728 }
729
730 fWaitForWindow = wsave;
731 fWaitForEvent = esave;
732}
733
734////////////////////////////////////////////////////////////////////////////////
735/// Wait for window to be unmapped.
736
738{
739 Window_t wsave = fWaitForWindow;
741
742 fWaitForWindow = w->GetId();
744
745 //Let VirtualX know, that we are
746 //in a nested loop for a window w.
747 //Noop on X11/win32gdk.
748 if (gVirtualX)
749 gVirtualX->BeginModalSessionFor(w->GetId());
750
751 while (fWaitForWindow != kNone) {
752 gSystem->ProcessEvents();//gSystem->InnerLoop();
753 gSystem->Sleep(5);
754 }
755
756 fWaitForWindow = wsave;
757 fWaitForEvent = esave;
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// reset waiting
762
764{
765 if (fWaitForWindow == w->GetId()) fWaitForWindow = kNone;
766}
767
768////////////////////////////////////////////////////////////////////////////////
769/// Like gSystem->ProcessEvents() but then only allow events for w to
770/// be processed. For example to interrupt the processing and destroy
771/// the window, call gROOT->SetInterrupt() before destroying the window.
772
774{
775 Window_t wsave = fWaitForWindow;
777
778 fWaitForWindow = w->GetId();
780
781 Bool_t intr = gSystem->ProcessEvents();
782
783 fWaitForWindow = wsave;
784 fWaitForEvent = esave;
785
786 return intr;
787}
788
789////////////////////////////////////////////////////////////////////////////////
790/// Redraw all windows that need redrawing. Returns kFALSE if no redraw
791/// was needed, kTRUE otherwise.
792/// Only redraw the application's windows when the event queue
793/// does not contain expose event anymore.
794
796{
797 if (!fGlobalNeedRedraw) return kFALSE;
798
799 TGWindow *w;
800 TObjLink *lnk = fWlist->FirstLink();
801 while (lnk) {
802 w = (TGWindow *) lnk->GetObject();
803 if (w->fNeedRedraw) {
804 w->DoRedraw();
805 w->fNeedRedraw = kFALSE;
806 }
807 lnk = lnk->Next();
808 }
809
812
813 return kTRUE;
814}
815
816////////////////////////////////////////////////////////////////////////////////
817/// Handle a GUI event.
818
820{
821 TGWindow *w;
822
823 // Emit signal for event recorder(s)
824 if (event->fType != kConfigureNotify) {
825 ProcessedEvent(event, 0);
826 }
827
828 // Find window where event happened
829 if ((w = GetWindowById(event->fWindow)) == 0) {
830 if (fUWHandlers && fUWHandlers->GetSize() > 0) {
833 while ((unkwh = (TGUnknownWindowHandler*)it.Next())) {
834 if (unkwh->HandleEvent(event))
835 return kTRUE;
836 }
837 }
838 //Warning("HandleEvent", "unknown window %ld not handled\n",
839 // event->fWindow);
840 return kFALSE;
841 }
842
843 // and let it handle the event
844 w->HandleEvent(event);
845
846 return kTRUE;
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Handle masked events only if window wid is the window for which the
851/// event was reported or if wid is a parent of the event window. The not
852/// masked event are handled directly. The masked events are:
853/// kButtonPress, kButtonRelease, kKeyPress, kKeyRelease, kEnterNotify,
854/// kLeaveNotify, kMotionNotify.
855
857{
858 TGWindow *w, *ptr, *pop;
859
860 if ((w = GetWindowById(event->fWindow)) == 0) return kFALSE;
861
862 // Emit signal for event recorder(s)
863 if (event->fType != kConfigureNotify) {
864 ProcessedEvent(event, wid);
865 }
866
867 // This breaks class member protection, but TGClient is a friend of
868 // TGWindow and _should_ know what to do and what *not* to do...
869
870 for (ptr = w; ptr->fParent != 0; ptr = (TGWindow *) ptr->fParent) {
871 if ((ptr->fId == wid) ||
872 ((event->fType != kButtonPress) &&
873 (event->fType != kButtonRelease) &&
874 (event->fType != kGKeyPress) &&
875 (event->fType != kKeyRelease) &&
876 (event->fType != kEnterNotify) &&
877 (event->fType != kLeaveNotify) &&
878 (event->fType != kMotionNotify))) {
879 w->HandleEvent(event);
880 return kTRUE;
881 }
882 }
883
884 // check if this is a popup menu
885 TIter next(fPlist);
886 while ((pop = (TGWindow *) next())) {
887 for (ptr = w; ptr->fParent != 0; ptr = (TGWindow *) ptr->fParent) {
888 if ((ptr->fId == pop->fId) &&
889 ((event->fType == kButtonPress) ||
890 (event->fType == kButtonRelease) ||
891 (event->fType == kGKeyPress) ||
892 (event->fType == kKeyRelease) ||
893 (event->fType == kEnterNotify) ||
894 (event->fType == kLeaveNotify) ||
895 (event->fType == kMotionNotify))) {
896 w->HandleEvent(event);
897 return kTRUE;
898 }
899 }
900 }
901
902 if (event->fType == kButtonPress || event->fType == kGKeyPress)
903 gVirtualX->Bell(0);
904
905 return kFALSE;
906}
907
908////////////////////////////////////////////////////////////////////////////////
909/// Execute string "cmd" via the interpreter. Before executing replace
910/// in the command string the token $MSG, $PARM1 and $PARM2 by msg,
911/// parm1 and parm2, respectively. The function in cmd string must accept
912/// these as longs.
913
915{
916 if (cmd.IsNull()) return;
917
918 char s[32];
919
920 snprintf(s, sizeof(s), "%ld", msg);
921 cmd.ReplaceAll("$MSG", s);
922
923 snprintf(s, sizeof(s), "%ld", parm1);
924 cmd.ReplaceAll("$PARM1", s);
925
926 snprintf(s, sizeof(s), "%ld", parm2);
927 cmd.ReplaceAll("$PARM2", s);
928
929 gROOT->ProcessLine(cmd.Data());
930}
931
932////////////////////////////////////////////////////////////////////////////////
933/// Returns kTRUE if edit/guibuilding is forbidden.
934
936{
937 return (fDefaultRoot->GetEditDisabled() == 1);
938}
939
940////////////////////////////////////////////////////////////////////////////////
941/// If on is kTRUE editting/guibuilding is forbidden.
942
944{
946}
947
948////////////////////////////////////////////////////////////////////////////////
949/// Emits a signal when an event has been processed.
950/// Used in TRecorder.
951
953{
954 Longptr_t args[2];
955 args[0] = (Longptr_t) event;
956 args[1] = (Longptr_t) wid;
957
958 Emit("ProcessedEvent(Event_t*, Window_t)", args);
959}
960
961////////////////////////////////////////////////////////////////////////////////
962/// Emits a signal when a Window has been registered in TGClient.
963/// Used in TRecorder.
964
966{
967 Emit("RegisteredWindow(Window_t)", w);
968}
EGEventType
Definition GuiTypes.h:59
@ kConfigureNotify
Definition GuiTypes.h:62
@ kGKeyPress
Definition GuiTypes.h:60
@ kUnmapNotify
Definition GuiTypes.h:62
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kDestroyNotify
Definition GuiTypes.h:62
@ kMotionNotify
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:61
@ kOtherEvent
Definition GuiTypes.h:64
@ kKeyRelease
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:75
long Long_t
Definition RtypesCore.h:54
unsigned long ULongptr_t
Definition RtypesCore.h:76
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassImp(name)
Definition Rtypes.h:382
R__EXTERN TApplication * gApplication
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
static TGClient * gClientGlobal
Definition TGClient.cxx:55
static TGClientInit gClientInit
Definition TGClient.cxx:88
void TriggerDictionaryInitialization_libGui()
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:406
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
R__EXTERN TFileHandler * gXDisplay
Definition TSystem.h:562
#define gVirtualX
Definition TVirtualX.h:337
R__EXTERN Atom_t gROOT_MESSAGE
Definition TVirtualX.h:40
R__EXTERN Atom_t gMOTIF_WM_HINTS
Definition TVirtualX.h:39
R__EXTERN Atom_t gWM_DELETE_WINDOW
Definition TVirtualX.h:38
#define snprintf
Definition civetweb.c:1540
void InitializeGraphics(Bool_t only_web=kFALSE)
Initialize the graphics environment.
static void NeedGraphicsLibs()
Static method.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
Window client.
Definition TGClient.h:37
Pixel_t fBackColor
default background color
Definition TGClient.h:42
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
EGEventType fWaitForEvent
event to wait for
Definition TGClient.h:65
TGGCPool * fGCPool
graphics context pool
Definition TGClient.h:54
Bool_t ProcessIdleEvent()
Process one idle event.
Definition TGClient.cxx:680
Bool_t HandleMaskEvent(Event_t *event, Window_t wid)
Handle masked events only if window wid is the window for which the event was reported or if wid is a...
Definition TGClient.cxx:856
void FreeColor(Pixel_t color) const
Free color.
Definition TGClient.cxx:504
Pixel_t fWhite
white color index
Definition TGClient.h:48
void CancelRedraw(TGWindow *w)
Definition TGClient.cxx:386
Pixel_t fHilite
default highlight color
Definition TGClient.h:44
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:914
Window_t fWaitForWindow
window in which to wait for event
Definition TGClient.h:66
static TGClient * Instance()
Returns global gClient (initialize graphics first, if not already done)
Definition TGClient.cxx:93
void RegisterPopup(TGWindow *w)
Add a popup menu to the list of popups.
Definition TGClient.cxx:533
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition TGClient.cxx:737
TGFontPool * fFontPool
font pool
Definition TGClient.h:55
void UnregisterPopup(TGWindow *w)
Remove a popup menu from the list of popups.
Definition TGClient.cxx:544
void ResetWaitFor(TGWindow *w)
reset waiting
Definition TGClient.cxx:763
~TGClient() override
Closing down client: cleanup and close X connection.
Definition TGClient.cxx:622
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition TGClient.cxx:320
Colormap_t fDefaultColormap
default colormap
Definition TGClient.h:58
TGResourcePool * fResourcePool
global GUI resource pool
Definition TGClient.h:53
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:348
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition TGClient.cxx:328
void AddUnknownWindowHandler(TGUnknownWindowHandler *h)
Add handler for unknown (i.e. unregistered) windows.
Definition TGClient.cxx:552
Pixel_t fForeColor
default foreground color
Definition TGClient.h:43
void SetStyle(UInt_t newstyle)
Definition TGClient.h:142
void RemoveUnknownWindowHandler(TGUnknownWindowHandler *h)
Remove handler for unknown (i.e. unregistered) windows.
Definition TGClient.cxx:565
UInt_t fStyle
GUI style (modern or classic)
Definition TGClient.h:67
void AddIdleHandler(TGIdleHandler *h)
Add handler for idle events.
Definition TGClient.cxx:573
void FreeFont(const TGFont *font)
Free a font.
Definition TGClient.cxx:364
TGWindow * fDefaultRoot
default root window (base window of display)
Definition TGClient.h:50
void SetEditDisabled(Bool_t on=kTRUE)
If on is kTRUE editting/guibuilding is forbidden.
Definition TGClient.cxx:943
Bool_t ProcessEventsFor(TGWindow *w)
Like gSystem->ProcessEvents() but then only allow events for w to be processed.
Definition TGClient.cxx:773
Bool_t HandleEvent(Event_t *event)
Handle a GUI event.
Definition TGClient.cxx:819
Bool_t ProcessOneEvent()
Process one event.
Definition TGClient.cxx:646
Pixel_t fSelBackColor
default selection background color
Definition TGClient.h:46
TGClient(const TGClient &)=delete
void ProcessedEvent(Event_t *event, Window_t wid)
Emits a signal when an event has been processed.
Definition TGClient.cxx:952
TGMimeTypes * fMimeTypeList
mimetype list
Definition TGClient.h:57
Bool_t DoRedraw()
Redraw all windows that need redrawing.
Definition TGClient.cxx:795
UInt_t GetDisplayHeight() const
Get display height.
Definition TGClient.cxx:275
Pixel_t fSelForeColor
default selection foreground color
Definition TGClient.h:47
std::atomic< Bool_t > fGlobalNeedRedraw
true if at least one window needs to be redrawn
Definition TGClient.h:59
void WaitFor(TGWindow *w)
Wait for window to be destroyed.
Definition TGClient.cxx:709
void RegisterWindow(TGWindow *w)
Add a TGWindow to the clients list of windows.
Definition TGClient.cxx:512
TList * fIdleHandlers
list of idle handlers
Definition TGClient.h:64
TGWindow * GetWindowById(Window_t sw) const
Find a TGWindow via its handle. If window is not found return 0.
Definition TGClient.cxx:594
void RegisteredWindow(Window_t w)
Emits a signal when a Window has been registered in TGClient.
Definition TGClient.cxx:965
Pixel_t fBlack
black color index
Definition TGClient.h:49
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
Pixel_t fShadow
default shadow color
Definition TGClient.h:45
Bool_t GetColorByName(const char *name, Pixel_t &pixel) const
Get a color by name.
Definition TGClient.cxx:395
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:244
Bool_t fForceRedraw
redraw widgets as soon as possible
Definition TGClient.h:60
TGWindow * fRoot
current root window (changing root window allows embedding)
Definition TGClient.h:51
void RemoveIdleHandler(TGIdleHandler *h)
Remove handler for idle events.
Definition TGClient.cxx:586
Bool_t IsEditDisabled() const
Returns kTRUE if edit/guibuilding is forbidden.
Definition TGClient.cxx:935
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
TList * fPlist
list of popup windows used in HandleMaskEvent()
Definition TGClient.h:62
Pixel_t GetHilite(Pixel_t base_color) const
Return pixel value of hilite color based on base_color.
Definition TGClient.cxx:450
FontStruct_t GetFontByName(const char *name, Bool_t fixedDefault=kTRUE) const
Get a font by name.
Definition TGClient.cxx:425
TList * fUWHandlers
list of event handlers for unknown windows
Definition TGClient.h:63
TGPicturePool * fPicturePool
pixmap pool
Definition TGClient.h:56
Bool_t HandleInput()
Handles input from the display server.
Definition TGClient.cxx:697
UInt_t GetDisplayWidth() const
Get display width.
Definition TGClient.cxx:262
THashList * fWlist
list of frames
Definition TGClient.h:61
Pixel_t GetShadow(Pixel_t base_color) const
Return pixel value of shadow color based on base_color.
Definition TGClient.cxx:481
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:308
Int_t fXfd
file descriptor of connection to server
Definition TGClient.h:52
void UnregisterWindow(TGWindow *w)
Remove a TGWindow from the list of windows.
Definition TGClient.cxx:523
TGWindow * GetWindowByName(const char *name) const
Find a TGWindow via its name (unique name used in TGWindow::SavePrimitive).
Definition TGClient.cxx:605
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get the specified font.
Definition TGFont.cxx:1558
void FreeFont(const TGFont *font)
Free font. If ref count is 0 delete font.
Definition TGFont.cxx:1718
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition TGGC.cxx:987
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition TGGC.cxx:918
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
Handle idle events, i.e.
virtual Bool_t HandleEvent()
Handle the idle event.
TGClient * fClient
Definition TGClient.cxx:105
Bool_t Notify() override
Notify input from the display server.
Definition TGClient.cxx:115
TGInputHandler(TGClient *c, Int_t fd)
Definition TGClient.cxx:107
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
void FreePicture(const TGPicture *pic)
Remove picture from cache if nobody is using it anymore.
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:82
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
This class implements a pool for the default GUI resource set, like GC's, colors, fonts,...
Colormap_t GetDefaultColormap() const
Pixel_t GetSelectedBgndColor() const
Pixel_t GetFrameFgndColor() const
TGPicturePool * GetPicturePool() const
Pixel_t GetBlackColor() const
Pixel_t GetWhiteColor() const
TGFontPool * GetFontPool() const
TGGCPool * GetGCPool() const
TGMimeTypes * GetMimeTypes() const
Pixel_t GetSelectedFgndColor() const
Pixel_t GetFrameBgndColor() const
Handle events for windows that are not part of the native ROOT GUI.
Definition TGWindow.h:141
virtual Bool_t HandleEvent(Event_t *)=0
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual UInt_t GetEditDisabled() const
Definition TGWindow.h:112
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:113
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
static void MakeFunctor(const char *name, const char *type, GlobFunc &func)
Definition TGlobal.h:73
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * FindObject(const char *name) const override
Find object using its name.
Iterator of linked list.
Definition TList.h:193
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
Definition TList.cxx:1109
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:83
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:657
virtual TObjLink * FirstLink() const
Definition TList.h:104
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:444
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:979
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:153
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:993
void MakeZombie()
Definition TObject.h:53
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
ROOT top level object description.
Definition TROOT.h:94
Bool_t IsBatch() const
Definition TROOT.h:279
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
@ kIgnoreCase
Definition TString.h:277
Bool_t IsNull() const
Definition TString.h:414
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
Definition TSystem.cxx:554
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition TSystem.cxx:235
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:437
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__EXTERN TROOT * gROOTLocal
Definition TROOT.h:379
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
ULong_t fPixel
color pixel value (index in color table)
Definition GuiTypes.h:311
UShort_t fRed
red component (0..65535)
Definition GuiTypes.h:312
UShort_t fGreen
green component (0..65535)
Definition GuiTypes.h:313
UShort_t fBlue
blue component (0..65535)
Definition GuiTypes.h:314
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
Graphics context structure.
Definition GuiTypes.h:224
Window attributes that can be inquired.
Definition GuiTypes.h:114
Colormap_t fColormap
color map to be associated with window
Definition GuiTypes.h:128