Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gui_handler_linux.cxx
Go to the documentation of this file.
1// Author: Sergey Linev <S.Linev@gsi.de>
2// Date: 2017-06-29
3
4/*************************************************************************
5 * Copyright (C) 1995-2023, 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#if !defined(_MSC_VER)
13#pragma GCC diagnostic ignored "-Wunused-parameter"
14#pragma GCC diagnostic ignored "-Wshadow"
15#endif
16
17#include "gui_handler.h"
18
19#include "include/cef_config.h"
20
21#ifdef CEF_X11
22
23#include <X11/Xatom.h>
24#include <X11/Xlib.h>
25#include <string>
26
27#include "include/base/cef_logging.h"
28#include "include/cef_browser.h"
29
30int x11_errhandler( Display *dpy, XErrorEvent *err )
31{
32 // special for modality usage: XGetWindowProperty + XQueryTree()
33 if (err->error_code == BadWindow) {
34 // if ( err->request_code == 25 && qt_xdnd_handle_badwindow() )
35 return 0;
36 } else if (err->error_code == BadMatch && err->request_code == 42) {
37 // special case for X_SetInputFocus
38 return 0;
39 } else if (err->error_code == BadDrawable && err->request_code == 14) {
40 return 0;
41 }
42
43 // here XError are forwarded
44 char errstr[512];
45 XGetErrorText( dpy, err->error_code, errstr, sizeof(errstr) );
46 printf( "X11 Error: %d opcode: %d info: %s\n", err->error_code, err->request_code, errstr );
47 return 0;
48}
49
51{
52 // install custom X11 error handler to avoid application exit in case of X11 failure
54}
55
57{
58
59 std::string titleStr(title);
60
61 // Retrieve the X11 display shared with Chromium.
62 ::Display *display = cef_get_xdisplay();
63 DCHECK(display);
64
65 // Retrieve the X11 window handle for the browser.
66 ::Window window = browser->GetHost()->GetWindowHandle();
67 DCHECK(window != kNullWindowHandle);
68
69 // Retrieve the atoms required by the below XChangeProperty call.
70 const char *kAtoms[] = {"_NET_WM_NAME", "UTF8_STRING"};
71 Atom atoms[2];
72 int result = XInternAtoms(display, const_cast<char **>(kAtoms), 2, false, atoms);
73 if (!result) NOTREACHED();
74
75 // Set the window title.
76 XChangeProperty(display, window, atoms[0], atoms[1], 8, PropModeReplace,
77 reinterpret_cast<const unsigned char *>(titleStr.c_str()), titleStr.size());
78
79 // TODO(erg): This is technically wrong. So XStoreName and friends expect
80 // this in Host Portable Character Encoding instead of UTF-8, which I believe
81 // is Compound Text. This shouldn't matter 90% of the time since this is the
82 // fallback to the UTF8 property above.
83 XStoreName(display, browser->GetHost()->GetWindowHandle(), titleStr.c_str());
84}
85
87{
88 ::Display *display = cef_get_xdisplay();
89 if (!display) return false;
90
91 // Retrieve the X11 window handle for the browser.
92 ::Window window = browser->GetHost()->GetWindowHandle();
93 if (window == kNullWindowHandle)
94 return false;
95
96 int result = XResizeWindow(display, window, width, height);
97 if (result == BadWindow) {
98 printf(" bad window in XResizeWindow\n");
99 return false;
100 }
101
102 if (result == BadValue) {
103 printf(" bad values in XResizeWindow %d %d\n", width, height);
104 return false;
105 }
106 XFlush(display);
107 return true;
108}
109
110#else
111
115
117{
118 // do nothing
119}
120
122{
123 return false;
124}
125
126
127#endif
128
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
XID Window
Definition TGX11.h:38
static bool PlatformResize(CefRefPtr< CefBrowser > browser, int width, int height)
void PlatformTitleChange(CefRefPtr< CefBrowser > browser, const CefString &title)
static void PlatformInit()
unsigned long Atom
Definition xatom.h:9