context
我正在和其他人一起编码参考系统 http://refpersys.org/,C++17 上的 GPLv3+ 项目gitlab https://gitlab.com/bstarynk/refpersys适用于 GNU/Linux/x86-64/Debian/Sid。它是fltk分支git分支 https://gitlab.com/bstarynk/refpersys/-/tree/fltk-branch正在使用FLTK 1.4 https://www.fltk.org/software.php?VERSION=1.4.x#developer,从源代码编译,带有Xorg https://en.wikipedia.org/wiki/X.Org_Server显示服务器。
我有 C++ 类,例如(在file headfltk_rps.hh https://gitlab.com/bstarynk/refpersys/-/blob/fltk-branch/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
我正在使用旧的 C++ 宏进行调试,输出到std::cerr
(定义于refpersys.hh第 315 行 https://gitlab.com/bstarynk/refpersys/-/blob/fltk-branch/refpersys.hh#L315以及以下)这样的as below https://gitlab.com/bstarynk/refpersys/-/blob/fltk-branch/fltklo_rps.cc#L381:
RPS_DEBUG_LOG(GUI, "RpsGui_CommandWindow::initialize_pack this:"
<< RpsGui_ShowWidget(this)
<< std::endl << "... cmdwin_pack:"
<< RpsGui_ShowWidget(cmdwin_pack));
屏幕上仍然有问题。
看RefPerSys 问题 #33 https://gitlab.com/bstarynk/refpersys/-/issues/33了解更多详细信息(带有屏幕截图)。
我想输出给定 FLTK 小部件的位置。我的 X11 根窗口。快速加权加权平均法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
question
换句话说,我想编码(用于调试目的)
int RpsGui_Window::x_wrt_root() const;
as 返回左上角水平坐标的成员函数this
w.r.t. X11 根窗口但我不确定如何编写代码。
致电给XGetWindowAttributes
在功能上fl_handle
FLTK(file src/Fl_x.cxx https://github.com/fltk/fltk/blob/master/src/Fl_x.cxx,靠近第 2159 行)可能与我的问题有关,也是如此top_window_offset成员函数 https://www.fltk.org/doc-1.4/classFl__Widget.html#afc4478714ca51d4533bf062c54c44a2b of Fl_Widget