CVS: rdesktop proto.h,1.61,1.62 rdp.c,1.56,1.57 secure.c,1.42,1.43 xwin.c,1.161,1.162

Peter Bystr?m <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15755

Modified Files:
	proto.h rdp.c secure.c xwin.c 
Log Message:
new: ui_resize_window() and related, which is used when resizing while shadowing. And fallback for color when connecting to a session with fewer colors than you have set in your session. Jeroen Meijer [email protected]


Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** proto.h	20 Apr 2004 07:01:17 -0000	1.61
--- proto.h	26 Apr 2004 13:48:39 -0000	1.62
***************
*** 158,161 ****
--- 158,162 ----
  void ui_deinit(void);
  BOOL ui_create_window(void);
+ void ui_resize_window(void);
  void ui_destroy_window(void);
  void xwin_toggle_fullscreen(void);

Index: rdp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** rdp.c	20 Apr 2004 07:01:21 -0000	1.56
--- rdp.c	26 Apr 2004 13:48:39 -0000	1.57
***************
*** 32,35 ****
--- 32,37 ----
  extern uint32 g_rdp5_performanceflags;
  extern int g_server_bpp;
+ extern int g_width;
+ extern int g_height;
  
  uint8 *g_next_packet;
***************
*** 369,373 ****
  
  	out_uint16(s, 0);	/* number of fonts */
! 	out_uint16_le(s, 0x3e);	/* unknown */
  	out_uint16_le(s, seq);	/* unknown */
  	out_uint16_le(s, 0x32);	/* entry size */
--- 371,375 ----
  
  	out_uint16(s, 0);	/* number of fonts */
! 	out_uint16_le(s, 0);	/* pad? */
  	out_uint16_le(s, seq);	/* unknown */
  	out_uint16_le(s, 0x32);	/* entry size */
***************
*** 417,421 ****
  	out_uint16_le(s, 600);	/* Desktop height */
  	out_uint16(s, 0);	/* Pad */
! 	out_uint16(s, 0);	/* Allow resize */
  	out_uint16_le(s, g_bitmap_compression ? 1 : 0);	/* Support compression */
  	out_uint16(s, 0);	/* Unknown */
--- 419,423 ----
  	out_uint16_le(s, 600);	/* Desktop height */
  	out_uint16(s, 0);	/* Pad */
! 	out_uint16(s, 1);	/* Allow resize */
  	out_uint16_le(s, g_bitmap_compression ? 1 : 0);	/* Support compression */
  	out_uint16(s, 0);	/* Unknown */
***************
*** 614,653 ****
  }
  
  /* Respond to a demand active PDU */
  static void
  process_demand_active(STREAM s)
  {
! 	uint8 type;
! 	uint16 i;
! 	uint16 p_bpp;
  
  	in_uint32_le(s, g_rdp_shareid);
  
! 	/* scan for prefered bpp */
! 	while (s_check_rem(s, 6))
  	{
! 		in_uint16_le(s, i);
! 		if (i == RDP_CAPSET_BITMAP)
  		{
! 			in_uint16_le(s, i);
! 			if (i == RDP_CAPLEN_BITMAP)
! 			{
! 				in_uint16_le(s, p_bpp);
! 				if (p_bpp == 8 || p_bpp == 15 || p_bpp == 16 || p_bpp == 24)
! 				{
! 					if (p_bpp < g_server_bpp)
! 					{
! 						warning("Server limited colour depth to %d bits\n",
! 							p_bpp);
! 						g_server_bpp = p_bpp;
! 					}
! 					break;
! 				}
! 			}
! 		}
! 	}
  
  
! 	DEBUG(("DEMAND_ACTIVE(id=0x%x)\n", g_rdp_shareid));
  
  	rdp_send_confirm_active();
--- 616,695 ----
  }
  
+ /* Process a general capability set */
+ static void
+ rdp_process_general_caps(STREAM s)
+ {
+ 	uint16 pad2octetsB;	/* rdp5 flags? */
+ 
+ 	in_uint8s(s, 10);
+ 	in_uint16_le(s, pad2octetsB);
+ 
+ 	if (!pad2octetsB)
+ 		g_use_rdp5 = False;
+ }
+ 
+ /* Process a bitmap capability set */
+ static void
+ rdp_process_bitmap_caps(STREAM s)
+ {
+ 	uint16 width, height, bpp;
+ 
+ 	in_uint16_le(s, bpp);
+ 	in_uint8s(s, 6);
+ 
+ 	in_uint16_le(s, width);
+ 	in_uint16_le(s, height);
+ 
+ 	DEBUG(("setting desktop size and bpp to: %dx%dx%d\n", width, height, bpp));
+ 
+ 	/*
+ 	 * The server may limit bpp and change the size of the desktop (for
+ 	 * example when shadowing another session).
+ 	 */
+ 	g_server_bpp = bpp;
+ 	g_width = width;
+ 	g_height = height;
+ 
+ 	ui_resize_window();
+ }
+ 
  /* Respond to a demand active PDU */
  static void
  process_demand_active(STREAM s)
  {
! 	int n;
! 	uint8 type, *next;
! 	uint16 len_src_descriptor, len_combined_caps, num_capsets, capset_type, capset_length;
  
  	in_uint32_le(s, g_rdp_shareid);
+ 	in_uint16_le(s, len_src_descriptor);
+ 	in_uint16_le(s, len_combined_caps);
+ 	in_uint8s(s, len_src_descriptor);
  
! 	in_uint16_le(s, num_capsets);
! 	in_uint8s(s, 2);	/* pad */
! 
! 	DEBUG(("DEMAND_ACTIVE(id=0x%x,num_caps=%d)\n", g_rdp_shareid, num_capsets));
! 
! 	for (n = 0; n < num_capsets; n++)
  	{
! 		in_uint16_le(s, capset_type);
! 		in_uint16_le(s, capset_length);
! 
! 		next = s->p + capset_length - 4;
! 
! 		switch (capset_type)
  		{
! 			case RDP_CAPSET_GENERAL:
! 				rdp_process_general_caps(s);
! 				break;
  
+ 			case RDP_CAPSET_BITMAP:
+ 				rdp_process_bitmap_caps(s);
+ 				break;
+ 		}
  
! 		s->p = next;
! 	}
  
  	rdp_send_confirm_active();
***************
*** 659,665 ****
  	rdp_recv(&type);	/* RDP_CTL_GRANT_CONTROL */
  	rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(read_keyboard_state()), 0);
! 	rdp_send_fonts(1);
! 	rdp_send_fonts(2);
! 	rdp_recv(&type);	/* RDP_PDU_UNKNOWN 0x28 */
  	reset_order_state();
  }
--- 701,716 ----
  	rdp_recv(&type);	/* RDP_CTL_GRANT_CONTROL */
  	rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, ui_get_numlock_state(read_keyboard_state()), 0);
! 
! 	if (g_use_rdp5)
! 	{
! 		rdp_send_fonts(3);
! 	}
! 	else
! 	{
! 		rdp_send_fonts(1);
! 		rdp_send_fonts(2);
! 	}
! 
! 	rdp_recv(&type);	/* RDP_PDU_UNKNOWN 0x28 (Fonts?) */
  	reset_order_state();
  }
***************
*** 998,1001 ****
--- 1049,1053 ----
  
  			case RDP_PDU_DEACTIVATE:
+ 				DEBUG(("RDP_PDU_DEACTIVATE\n"));
  				*deactivated = True;
  				break;

Index: secure.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/secure.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** secure.c	18 Mar 2004 02:32:00 -0000	1.42
--- secure.c	26 Apr 2004 13:48:39 -0000	1.43
***************
*** 450,469 ****
  	out_uint32_le(s, 12);
  	out_uint8s(s, 64);	/* reserved? 4 + 12 doublewords */
! 
! 	switch (g_server_bpp)
! 	{
! 		case 8:
! 			out_uint16_le(s, 0xca01);
! 			break;
! 		case 15:
! 			out_uint16_le(s, 0xca02);
! 			break;
! 		case 16:
! 			out_uint16_le(s, 0xca03);
! 			break;
! 		case 24:
! 			out_uint16_le(s, 0xca04);
! 			break;
! 	}
  	out_uint16_le(s, 1);
  
--- 450,454 ----
  	out_uint32_le(s, 12);
  	out_uint8s(s, 64);	/* reserved? 4 + 12 doublewords */
! 	out_uint16_le(s, 0xca01);	/* colour depth? */
  	out_uint16_le(s, 1);
  
***************
*** 772,776 ****
--- 757,764 ----
  	DEBUG_RDP5(("Server RDP version is %d\n", g_server_rdp_version));
  	if (1 == g_server_rdp_version)
+ 	{
  		g_use_rdp5 = 0;
+ 		g_server_bpp = 8;
+ 	}
  }
  

Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.161
retrieving revision 1.162
diff -C2 -d -r1.161 -r1.162
*** xwin.c	15 Apr 2004 20:12:31 -0000	1.161
--- xwin.c	26 Apr 2004 13:48:39 -0000	1.162
***************
*** 1010,1013 ****
--- 1010,1034 ----
  
  void
+ ui_resize_window()
+ {
+ 	XSizeHints *sizehints;
+ 
+ 	sizehints = XAllocSizeHints();
+ 	if (sizehints)
+ 	{
+ 		sizehints->flags = PMinSize | PMaxSize;
+ 		sizehints->min_width = sizehints->max_width = g_width;
+ 		sizehints->min_height = sizehints->max_height = g_height;
+ 		XSetWMNormalHints(g_display, g_wnd, sizehints);
+ 		XFree(sizehints);
+ 	}
+ 
+ 	if (!(g_fullscreen || g_embed_wnd))
+ 	{
+ 		XResizeWindow(g_display, g_wnd, g_width, g_height);
+ 	}
+ }
+ 
+ void
  ui_destroy_window(void)
  {



-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.