DrawingArea opens a new window.



Hi,

I'm trying to draw video on a DrawingArea widget. The video is shown OK in 
drawingare. But when the drawing area widget is built into a window, another 
window for the DrawingArea is opened, instead of containing the 
DrawingArea widget in the original window.

Is there some specific container that should be used for DrawingArea, or does 
it require some options set to correctly contain the widget in a container?
Here is the essential code: 


// PlayerWidget.h. Inherited from Gtk::DrawingArea

PlayerWidget::PlayerWidget() : Gtk::DrawingArea(), xWindowId_(0)
{
	on_realize();
}


PlayerWidget::~PlayerWidget() 
{
}

void PlayerWidget::on_realize()
{
	int xwin;
	Gtk::DrawingArea::on_realize();
	Glib::RefPtr<Gdk::Window> gwindow = get_window();
	
	if (gwindow)
	{
		xWindowId_ = GDK_WINDOW_XID(Glib::unwrap(get_window()));
		
		std::cout<< "Playerwidget xwin id: "<< xWindowId_ <<"\n";
	}
	
	//std::cout<<"on_realize occured\n";    
	//std::cout<<"xwin id: "<<xwin<<"\n";
}


int PlayerWidget::getXwindowId() 
{
	return xWindowId_;
}


//==============================================

MainWindow::MainWindow() : Gtk::Window(), m_vbox(), m_pWidget() 
{
	
	set_default_size(500,500);
	
	// m_pWidget is an instance of PlayerWidget (Gtk::DrawingArea)
	m_pWidget.set_size_request(400, 400); 
	m_vbox.pack_start(m_pWidget, Gtk::PACK_EXPAND_WIDGET, 5);
	
	add(m_vbox);
			
	show_all_children();
}

//================================================

When instantiating a MainWindow object after this, the DrawingArea is built 
into a new window on desktop, instead of being contained in the MainWindow. 
When the window containing drawing area is closed I get:

"The application 'demo' lost its connection to the display :0.0;
most likely the X server was shut down or you killed/destroyed
the application."

But when I close the MainWindow, both of the windows close correctly without 
any errors.

What seems to be the problem?


-- 
Lassi Väätämöinen
Researcher
Tampere University of Technology / Department of Communications Engineering
Room TH209, tel. 03-3115 5124
-- 
Lassi Väätämöinen
M.Sc., Researcher
Tampere University of Technology / Department of Communications Engineering
Room TH209, tel. 03-3115 5124


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]