无法将gnuplot x11窗口嵌入到Gtk3套接字中 [英] Cannot embed gnuplot x11 window into Gtk3 socket

查看:202
本文介绍了无法将gnuplot x11窗口嵌入到Gtk3套接字中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Gtk3(实际上是gtkmm)应用程序中创建Gtk :: Socket,并尝试将gnuplot的窗口嵌入其中.但这是行不通的:套接字保持为黑色矩形,而gnuplot窗口在其他位置单独显示.

I'm creating Gtk::Socket in my Gtk3 (actually, gtkmm) application and trying to embed gnuplot's window into it. But it does not work: the socket remains to stay as a black rectangle, while gnuplot window appears standalone elsewhere.

同时,Gtk :: Plug可以完美地插入此套接字.在Gtk2中,使用gnuplot的技巧也很有效.

Meanwhile, Gtk::Plug plugs into this socket perfectly. In Gtk2 this trick with gnuplot works well too.

这是socket.cpp

Here is socket.cpp

#include <iostream>
#include <fstream>
#include <gtkmm.h>
#include <gtkmm/socket.h>

using namespace std;

void plug_added(){
  cout << "A plug was added" << endl;
}

bool plug_removed(){
  cout << "A Plug was removed" << endl;
  return true;
}

class MySocketWindow : public Gtk::Window
{
  public:
    MySocketWindow()
    {
        auto socket = Gtk::manage(new Gtk::Socket());
        add(*socket);
        socket->signal_plug_added().connect(sigc::ptr_fun(plug_added));
        socket->signal_plug_removed().connect(sigc::ptr_fun(plug_removed));
        cout << "Socket id is: " << hex << socket->get_id() << endl;
        show_all();
    }
};

int main(int argc, char** argv)
{
  auto app =
    Gtk::Application::create(argc, argv, "org.gtkmm.example.socket");
  MySocketWindow win;
  app->run(win);
  return 0;
}

编译并运行:

$ g++ --std=c++0x socket.cpp -o socket `pkg-config gtkmm-3.0 --cflags --libs`
$ ./socket &
[1] 22832
$ Socket id is: 2c00007

启动gnuplot:

gnuplot> set term x11 window "2c00007"
Terminal type set to 'x11'
Options are 'XID 0x2C00007 nopersist enhanced'
gnuplot> plot sin(x)

那么,与Gtk2相比,Gtk3套接字中是否存在阻止gnuplot连接的任何差异?

So, are there any differences in Gtk3 sockets over Gtk2 which prevent gnuplot from connecting?

Ubuntu Xenial 16.04.1 x64,gnuplot-4.6.6,libgtkmm-3.0-dev 3.18.0,g ++ 5.4.0 不起作用

Ubuntu Xenial 16.04.1 x64, gnuplot-4.6.6, libgtkmm-3.0-dev 3.18.0, g++ 5.4.0 doesn't work

Ubuntu Trusty 14.04.4 x86,gnuplot-4.6.4,libgtkmm-3.0-dev 3.10.1,g ++ 4.8.4 有效

Ubuntu Trusty 14.04.4 x86, gnuplot-4.6.4, libgtkmm-3.0-dev 3.10.1, g++ 4.8.4 works

UPD:

更深入地研究gnuplot源表明,Gnuplot为它的窗口创建了"X11 Visual"结构,该结构与套接字的窗口不同.要解决此问题,请更改以下行:

Digging deeper into gnuplot sources reveal that Gnuplot creates "X11 Visual" structure for its window that is different to socket's one. To fix this, change the line:

    plot->window = XCreateWindow(dpy, plot->external_container, plot->x, plot->y, plot->width,
                 plot->height, 0, dep, InputOutput, vis, 0, NULL);

    plot->window = XCreateWindow(dpy, plot->external_container, plot->x, plot->y, plot->width,
                 plot->height, 0, dep, InputOutput, gattr.visual, 0, NULL);

(gplt_x11.c(第5.5.2版)的第6339行)

(line 6339 of gplt_x11.c (at version 5.5.2))

推荐答案

似乎最近的更新允许通过#define修复此问题.拉gnuplot(我拥有5.2.5),并在构建之前在config.hin文件中进行以下更改,以本地方式构建:

It seems that recent updates allow this to be fixed via a #define. Pull gnuplot (5.2.5 is what I have) and build locally with the following changed in the config.hin file before you build:

#undef EXTERNAL_X11_WINDOW#define EXTERNAL_X11_WINDOW

然后按照提供的说明进行安装,您应该已经设置好!

Then follow the provided instructions to install and you should be set!

这篇关于无法将gnuplot x11窗口嵌入到Gtk3套接字中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆