Пример #1
0
void HandleMessage_DrawRect(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	uint16_t	x = message.ReadU16();
	uint16_t	y = message.ReadU16();
	uint16_t	w = message.ReadU16();
	uint16_t	h = message.ReadU16();
	uint32_t	colour = message.ReadU32();
	_SysDebug("_DrawRect: (%i (%i,%i) %ix%i %06x)", win_id, x, y, w, h, colour);
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_DrawRect: Bad window");
	}
	
	if(h == 0) {
	}
	else if(h == 1) {
		win->FillScanline(y, x, w, colour);
	}
	else if(h == 2) {
		win->FillScanline(y++, x, w, colour);
		win->FillScanline(y++, x, w, colour);
	}
	else {
		win->FillScanline(y++, x, w, colour);
		while( h -- > 2 ) {
			win->FillScanline(y, x, 1, colour);
			win->FillScanline(y, x+w-1, 1, colour);
			y ++;
		}
		win->FillScanline(y++, x, w, colour);
	}
}
Пример #2
0
void HandleMessage_PushData(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	uint16_t	x = message.ReadU16();
	uint16_t	y = message.ReadU16();
	uint16_t	w = message.ReadU16();
	uint16_t	h = message.ReadU16();
	_SysDebug("_PushData: (%i, (%i,%i) %ix%i)", win_id, x, y, w, h);
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_PushData: Bad window");
	}
	
	for( unsigned int row = 0; row < h; row ++ )
	{
		const ::std::vector<uint8_t> scanline_data = message.ReadBuffer();
		if( scanline_data.size() != w * 4 ) {
			_SysDebug("ERROR _PushData: Scanline buffer size mismatch (%i,%i)",
				scanline_data.size(), w*4);
			continue ;
		}
		win->DrawScanline(y+row, x, w, scanline_data.data());
	}
}
Пример #3
0
void HandleMessage_DestroyWindow(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	_SysDebug("_DestroyWindow: (%i)", win_id);
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_DestroyWindow: Bad window");
	}
	client.SetWindow(win_id, 0);	
	
	// TODO: Directly inform compositor?
	delete win;
}
Пример #4
0
void HandleMessage_DamageRect(CClient& client, CDeserialiser& message)
{
	uint16_t	winid = message.ReadU16();
	uint16_t	x = message.ReadU16();
	uint16_t	y = message.ReadU16();
	uint16_t	w = message.ReadU16();
	uint16_t	h = message.ReadU16();
	
	_SysDebug("_DamageRect: (%i %i,%i %ix%i)", winid, x, y, w, h);
	
	CWindow*	win = client.GetWindow(winid);
	if(!win) {
		throw IPC::CClientFailure("_PushData: Bad window");
	}
	
	CRect	area(x,y,w,h);
	
	win->Repaint(area);
}
Пример #5
0
void HandleMessage_GetWindowBuffer(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	_SysDebug("_GetWindowBuffer: (%i)", win_id);
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_PushData: Bad window");
	}
	
	uint64_t handle = win->m_surface.GetSHMHandle();
	
	CSerialiser	reply;
	reply.WriteU8(IPCMSG_REPLY);
	reply.WriteU8(IPCMSG_GETWINBUF);
	reply.WriteU16(win_id);
	reply.WriteU64(handle);
	client.SendMessage(reply);
}
Пример #6
0
void HandleMessage_DrawText(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	uint16_t	x = message.ReadU16();
	uint16_t	y = message.ReadU16();
	uint16_t	w = message.ReadU16();
	uint16_t	h = message.ReadU16();
	uint16_t	font_id = message.ReadU16();
	::std::string	str = message.ReadString();
	_SysDebug("_DrawText: (%i (%i,%i) %ix%i Font%i \"%s\")", win_id, x, y, w, h, font_id, str.c_str());
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_DrawText: Bad window");
	}
	
	// 1. Get font from client structure
	IFontFace& fontface = client.GetFont(font_id);
	
	// 2. Render
	CRect	area(x, y, w, h);
	fontface.Render(win->m_surface, area, str, h);
}
Пример #7
0
void HandleMessage_SetWindowAttr(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	uint16_t	attr_id = message.ReadU16();
	_SysDebug("_SetWindowAttr: (Win=%i, ID=%i)", win_id, attr_id);
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_SetWindowAttr - Bad window");
	}
	
	switch(attr_id)
	{
	case IPC_WINATTR_DIMENSIONS: {
		uint16_t new_w = message.ReadU16();
		uint16_t new_h = message.ReadU16();
		win->Resize(new_w, new_h);
		break; }
	case IPC_WINATTR_POSITION: {
		int16_t new_x = message.ReadS16();
		int16_t new_y = message.ReadS16();
		win->Move(new_x, new_y);
		break; }
	case IPC_WINATTR_SHOW:
		win->Show( message.ReadU8() != 0 );
		break;
	case IPC_WINATTR_FLAGS:
		win->SetFlags( message.ReadU8() );	// TODO: U8? why so small?
		break;
	case IPC_WINATTR_TITLE:
		assert(!"TODO: IPC_WINATTR_TITLE");
		break;
	default:
		_SysDebug("HandleMessage_SetWindowAttr - Bad attr %u", attr_id);
		throw IPC::CClientFailure("Bad window attr");
	}
}
Пример #8
0
void HandleMessage_DrawCtl(CClient& client, CDeserialiser& message)
{
	uint16_t	win_id = message.ReadU16();
	uint16_t	x = message.ReadU16();
	uint16_t	y = message.ReadU16();
	uint16_t	w = message.ReadU16();
	uint16_t	h = message.ReadU16();
	uint16_t	ctrl_id = message.ReadU16();
	uint16_t 	frame = message.ReadU16();
	_SysDebug("_DrawCtl: (%i, (%i,%i) %ix%i Ctl%i frame?=0x%04x)", win_id, x, y, w, h, ctrl_id, frame);
	
	CWindow*	win = client.GetWindow(win_id);
	if(!win) {
		throw IPC::CClientFailure("_DrawCtl: Bad window");
	}
	
	const CControl* ctrl = CControl::GetByID(ctrl_id);
	if(!ctrl) {
		throw IPC::CClientFailure("_DrawCtl: Invalid control ID");
	}
	
	CRect	area(x,y,w,h);
	ctrl->Render(win->m_surface, area);
}