st_side = Math.max(window.innerWidth,window.innerHeight);
			csize = Math.min(csize, longest_side * 2/3);
		}

		// pixel perfect: quantize to closest multiple of 128
		// only when large display (desktop)
		if (frame_width >= 512 && frame_height >= 512)
		{
			csize = (csize+1) & ~0x7f;
		}

		// csize should never be higher than parent frame
		// (otherwise stretched large when fullscreen and then return)
		if (!is_fullscreen && p8_frame) 
			csize = Math.min(csize, last_windowed_container_height); // p8_