【发布时间】:2020-09-07 22:04:11
【问题描述】:
上下文
我正在与其他人 RefPerSys 编码,这是一个 GPLv3+ 项目,使用 C++17 在 gitlab 上用于 GNU/Linux/x86-64/Debian/Sid。它的fltk-branch git branch 使用FLTK 1.4,从源代码编译,带有Xorg 显示服务器。
我有 C++ 类,例如(file headfltk_rps.hh):
class RpsGui_Window: public Fl_Double_Window
{
static std::set<RpsGui_Window*> _set_of_gui_windows_;
public:
virtual int handle(int);
protected:
Fl_Menu_Bar *guiwin_menubar;
std::string guiwin_label;
virtual void initialize_menubar(void) =0;
RpsGui_Window(int w, int h, const std::string& lab);
RpsGui_Window(int x, int y, int w, int h, const std::string& lab);
public:
virtual ~RpsGui_Window();
/// .... skipping irrelevant code
const std::string label_str(void) const {
return guiwin_label;
};
}; /// end class RpsGui_Window
class RpsGui_CommandWindow : public RpsGui_Window
{
static constexpr int right_menu_gap = 16;
static constexpr int menu_height = 20;
Fl_Pack* cmdwin_pack;
friend void rps_fltk_initialize(int &,char**);
virtual void initialize_menubar(void);
virtual void initialize_pack(void);
static void menu_dump_cb(Fl_Widget*, void*);
static void menu_exit_cb(Fl_Widget*, void*);
public:
RpsGui_CommandWindow(int w, int h, const std::string& lab);
RpsGui_CommandWindow(int x, int y, int w, int h, const std::string& lab);
virtual ~RpsGui_CommandWindow();
}; // end class RpsGui_CommandWindow
我正在使用输出到std::cerr(在refpersys.hh lines 315 及以下定义)的旧C++ 宏进行调试,例如as below:
RPS_DEBUG_LOG(GUI, "RpsGui_CommandWindow::initialize_pack this:"
<< RpsGui_ShowWidget(this)
<< std::endl << "... cmdwin_pack:"
<< RpsGui_ShowWidget(cmdwin_pack));
屏幕上仍然有问题。 有关更多详细信息(附屏幕截图),请参阅RefPerSys issue#33。
我想输出给定 FLTK 小部件 w.r.t 的位置。我的 X11 根窗口。 FWIW xdpyinfo 正在给予(跳过了很多输出)
name of display: :0
version number: 11.0
vendor string: The X.Org Foundation
vendor release number: 12008000
X.Org version: 1.20.8
screen #0:
dimensions: 5360x1440 pixels (1418x381 millimeters)
resolution: 96x96 dots per inch
问题
换句话说,我想编码(用于调试目的)
int RpsGui_Window::x_wrt_root() const;
作为返回thisw.r.t的左上角水平坐标的成员函数。 X11 根窗口,但我不确定如何编写代码。
在 FLTK 的函数 fl_handle(file src/Fl_x.cxx,靠近第 2159 行)中对 XGetWindowAttributes 的调用可能与我的问题有关,top_window_offset member function 的 Fl_Widget 也是如此
【问题讨论】: