2003-06-06 13:10:48 +02:00
|
|
|
/* -*- c-basic-offset: 8 -*-
|
2000-07-05 09:44:21 +02:00
|
|
|
rdesktop: A Remote Desktop Protocol client.
|
2002-04-04 14:04:33 +02:00
|
|
|
User interface services - X Window System
|
2002-09-26 16:26:46 +02:00
|
|
|
Copyright (C) Matthew Chapman 1999-2002
|
2002-04-26 10:22:39 +02:00
|
|
|
|
2000-07-05 09:44:21 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2002-04-26 10:22:39 +02:00
|
|
|
|
2000-07-05 09:44:21 +02:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2002-04-26 10:22:39 +02:00
|
|
|
|
2000-07-05 09:44:21 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
#include <X11/Xlib.h>
|
2001-06-20 15:54:48 +02:00
|
|
|
#include <X11/Xutil.h>
|
2003-10-31 05:51:10 +01:00
|
|
|
#include <unistd.h>
|
2004-02-16 21:28:09 +01:00
|
|
|
#include <sys/time.h>
|
2000-08-15 12:23:24 +02:00
|
|
|
#include <time.h>
|
2001-09-15 14:34:34 +02:00
|
|
|
#include <errno.h>
|
2004-02-07 19:47:06 +01:00
|
|
|
#include <strings.h>
|
2000-08-15 12:23:24 +02:00
|
|
|
#include "rdesktop.h"
|
2003-06-06 13:10:48 +02:00
|
|
|
#include "xproto.h"
|
2000-07-05 09:44:21 +02:00
|
|
|
|
2003-08-22 01:23:15 +02:00
|
|
|
extern int g_width;
|
|
|
|
extern int g_height;
|
2004-11-18 12:18:49 +01:00
|
|
|
extern int g_xpos;
|
|
|
|
extern int g_ypos;
|
2003-08-22 01:23:15 +02:00
|
|
|
extern BOOL g_sendmotion;
|
|
|
|
extern BOOL g_fullscreen;
|
2003-08-28 00:51:33 +02:00
|
|
|
extern BOOL g_grab_keyboard;
|
|
|
|
extern BOOL g_hide_decorations;
|
|
|
|
extern char g_title[];
|
2003-08-01 19:01:58 +02:00
|
|
|
extern int g_server_bpp;
|
2003-08-28 00:51:33 +02:00
|
|
|
extern int g_win_button_size;
|
2000-08-15 12:23:24 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
Display *g_display;
|
|
|
|
Time g_last_gesturetime;
|
|
|
|
static int g_x_socket;
|
|
|
|
static Screen *g_screen;
|
|
|
|
Window g_wnd;
|
2004-04-10 11:34:52 +02:00
|
|
|
extern uint32 g_embed_wnd;
|
2003-10-09 05:28:04 +02:00
|
|
|
BOOL g_enable_compose = False;
|
2004-05-06 10:17:47 +02:00
|
|
|
BOOL g_Unobscured; /* used for screenblt */
|
2004-01-22 21:31:59 +01:00
|
|
|
static GC g_gc = NULL;
|
2004-06-27 19:51:54 +02:00
|
|
|
static GC g_create_bitmap_gc = NULL;
|
|
|
|
static GC g_create_glyph_gc = NULL;
|
2003-08-28 00:51:33 +02:00
|
|
|
static Visual *g_visual;
|
|
|
|
static int g_depth;
|
|
|
|
static int g_bpp;
|
|
|
|
static XIM g_IM;
|
|
|
|
static XIC g_IC;
|
|
|
|
static XModifierKeymap *g_mod_map;
|
|
|
|
static Cursor g_current_cursor;
|
2004-01-22 21:31:59 +01:00
|
|
|
static HCURSOR g_null_cursor = NULL;
|
2003-08-28 00:51:33 +02:00
|
|
|
static Atom g_protocol_atom, g_kill_atom;
|
2003-10-09 05:28:04 +02:00
|
|
|
static BOOL g_focused;
|
|
|
|
static BOOL g_mouse_in_wnd;
|
2004-04-15 22:12:42 +02:00
|
|
|
static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */
|
2001-09-15 05:16:05 +02:00
|
|
|
|
2001-09-15 14:34:34 +02:00
|
|
|
/* endianness */
|
2003-08-28 00:51:33 +02:00
|
|
|
static BOOL g_host_be;
|
|
|
|
static BOOL g_xserver_be;
|
2003-10-29 09:15:02 +01:00
|
|
|
static int g_red_shift_r, g_blue_shift_r, g_green_shift_r;
|
|
|
|
static int g_red_shift_l, g_blue_shift_l, g_green_shift_l;
|
2001-09-15 14:34:34 +02:00
|
|
|
|
|
|
|
/* software backing store */
|
2004-04-10 11:34:52 +02:00
|
|
|
extern BOOL g_ownbackstore;
|
2004-02-07 19:47:06 +01:00
|
|
|
static Pixmap g_backstore = 0;
|
2001-09-15 05:16:05 +02:00
|
|
|
|
2003-03-14 13:00:17 +01:00
|
|
|
/* Moving in single app mode */
|
2003-08-28 00:51:33 +02:00
|
|
|
static BOOL g_moving_wnd;
|
|
|
|
static int g_move_x_offset = 0;
|
|
|
|
static int g_move_y_offset = 0;
|
2003-03-14 13:00:17 +01:00
|
|
|
|
2003-09-30 11:11:08 +02:00
|
|
|
#ifdef WITH_RDPSND
|
|
|
|
extern int g_dsp_fd;
|
|
|
|
extern BOOL g_dsp_busy;
|
2003-10-17 10:23:47 +02:00
|
|
|
extern BOOL g_rdpsnd;
|
2003-09-30 11:11:08 +02:00
|
|
|
#endif
|
|
|
|
|
2002-11-18 16:37:20 +01:00
|
|
|
/* MWM decorations */
|
|
|
|
#define MWM_HINTS_DECORATIONS (1L << 1)
|
|
|
|
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
|
|
|
|
typedef struct
|
|
|
|
{
|
2003-01-30 12:28:50 +01:00
|
|
|
uint32 flags;
|
|
|
|
uint32 functions;
|
|
|
|
uint32 decorations;
|
|
|
|
sint32 inputMode;
|
|
|
|
uint32 status;
|
2002-11-18 16:37:20 +01:00
|
|
|
}
|
|
|
|
PropMotifWmHints;
|
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32 red;
|
|
|
|
uint32 green;
|
|
|
|
uint32 blue;
|
|
|
|
}
|
|
|
|
PixelColour;
|
2002-11-18 16:37:20 +01:00
|
|
|
|
2003-06-06 13:10:48 +02:00
|
|
|
|
2001-09-15 05:16:05 +02:00
|
|
|
#define FILL_RECTANGLE(x,y,cx,cy)\
|
|
|
|
{ \
|
2003-08-28 00:51:33 +02:00
|
|
|
XFillRectangle(g_display, g_wnd, g_gc, x, y, cx, cy); \
|
|
|
|
if (g_ownbackstore) \
|
|
|
|
XFillRectangle(g_display, g_backstore, g_gc, x, y, cx, cy); \
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2003-01-28 13:07:55 +01:00
|
|
|
#define FILL_RECTANGLE_BACKSTORE(x,y,cx,cy)\
|
2002-12-02 23:57:47 +01:00
|
|
|
{ \
|
2003-08-28 00:51:33 +02:00
|
|
|
XFillRectangle(g_display, g_ownbackstore ? g_backstore : g_wnd, g_gc, x, y, cx, cy); \
|
2002-12-02 23:57:47 +01:00
|
|
|
}
|
|
|
|
|
2001-09-15 14:34:34 +02:00
|
|
|
/* colour maps */
|
2004-04-10 11:34:52 +02:00
|
|
|
extern BOOL g_owncolmap;
|
2003-08-28 00:51:33 +02:00
|
|
|
static Colormap g_xcolmap;
|
|
|
|
static uint32 *g_colmap = NULL;
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
#define TRANSLATE(col) ( g_server_bpp != 8 ? translate_colour(col) : g_owncolmap ? col : g_colmap[col] )
|
2003-08-28 00:51:33 +02:00
|
|
|
#define SET_FOREGROUND(col) XSetForeground(g_display, g_gc, TRANSLATE(col));
|
|
|
|
#define SET_BACKGROUND(col) XSetBackground(g_display, g_gc, TRANSLATE(col));
|
2001-06-20 15:54:48 +02:00
|
|
|
|
|
|
|
static int rop2_map[] = {
|
|
|
|
GXclear, /* 0 */
|
|
|
|
GXnor, /* DPon */
|
|
|
|
GXandInverted, /* DPna */
|
|
|
|
GXcopyInverted, /* Pn */
|
|
|
|
GXandReverse, /* PDna */
|
|
|
|
GXinvert, /* Dn */
|
|
|
|
GXxor, /* DPx */
|
|
|
|
GXnand, /* DPan */
|
|
|
|
GXand, /* DPa */
|
|
|
|
GXequiv, /* DPxn */
|
|
|
|
GXnoop, /* D */
|
|
|
|
GXorInverted, /* DPno */
|
|
|
|
GXcopy, /* P */
|
|
|
|
GXorReverse, /* PDno */
|
|
|
|
GXor, /* DPo */
|
|
|
|
GXset /* 1 */
|
|
|
|
};
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
#define SET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(g_display, g_gc, rop2_map[rop2]); }
|
|
|
|
#define RESET_FUNCTION(rop2) { if (rop2 != ROP2_COPY) XSetFunction(g_display, g_gc, GXcopy); }
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2003-02-10 14:02:57 +01:00
|
|
|
static void
|
2002-11-18 16:37:20 +01:00
|
|
|
mwm_hide_decorations(void)
|
|
|
|
{
|
|
|
|
PropMotifWmHints motif_hints;
|
|
|
|
Atom hintsatom;
|
|
|
|
|
|
|
|
/* setup the property */
|
|
|
|
motif_hints.flags = MWM_HINTS_DECORATIONS;
|
|
|
|
motif_hints.decorations = 0;
|
|
|
|
|
|
|
|
/* get the atom for the property */
|
2003-08-28 00:51:33 +02:00
|
|
|
hintsatom = XInternAtom(g_display, "_MOTIF_WM_HINTS", False);
|
2002-11-18 16:37:20 +01:00
|
|
|
if (!hintsatom)
|
|
|
|
{
|
2003-01-28 13:27:28 +01:00
|
|
|
warning("Failed to get atom _MOTIF_WM_HINTS: probably your window manager does not support MWM hints\n");
|
2002-11-18 16:37:20 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XChangeProperty(g_display, g_wnd, hintsatom, hintsatom, 32, PropModeReplace,
|
2002-11-18 16:37:20 +01:00
|
|
|
(unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
|
|
|
|
}
|
|
|
|
|
2003-02-10 14:02:57 +01:00
|
|
|
static PixelColour
|
2003-02-09 18:17:37 +01:00
|
|
|
split_colour15(uint32 colour)
|
2003-02-05 15:16:33 +01:00
|
|
|
{
|
2003-02-09 18:17:37 +01:00
|
|
|
PixelColour rv;
|
2004-06-01 10:06:02 +02:00
|
|
|
rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7);
|
2004-05-27 12:19:41 +02:00
|
|
|
rv.green = ((colour >> 2) & 0xf8) | ((colour >> 8) & 0x7);
|
2004-06-01 10:06:02 +02:00
|
|
|
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);
|
2003-02-09 18:17:37 +01:00
|
|
|
return rv;
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
|
|
|
|
2003-02-10 14:02:57 +01:00
|
|
|
static PixelColour
|
2003-02-09 18:17:37 +01:00
|
|
|
split_colour16(uint32 colour)
|
2003-02-05 15:16:33 +01:00
|
|
|
{
|
2003-02-09 18:17:37 +01:00
|
|
|
PixelColour rv;
|
2004-06-01 10:06:02 +02:00
|
|
|
rv.red = ((colour >> 8) & 0xf8) | ((colour >> 13) & 0x7);
|
2004-05-27 12:19:41 +02:00
|
|
|
rv.green = ((colour >> 3) & 0xfc) | ((colour >> 9) & 0x3);
|
2004-06-01 10:06:02 +02:00
|
|
|
rv.blue = ((colour << 3) & 0xf8) | ((colour >> 2) & 0x7);
|
2003-02-09 18:17:37 +01:00
|
|
|
return rv;
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
|
|
|
|
2003-02-10 14:02:57 +01:00
|
|
|
static PixelColour
|
2003-02-09 18:17:37 +01:00
|
|
|
split_colour24(uint32 colour)
|
2003-02-05 15:16:33 +01:00
|
|
|
{
|
2003-02-09 18:17:37 +01:00
|
|
|
PixelColour rv;
|
2004-03-03 11:41:53 +01:00
|
|
|
rv.blue = (colour & 0xff0000) >> 16;
|
2004-02-25 19:28:52 +01:00
|
|
|
rv.green = (colour & 0x00ff00) >> 8;
|
2004-03-03 11:41:53 +01:00
|
|
|
rv.red = (colour & 0x0000ff);
|
2003-02-09 18:17:37 +01:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-02-10 14:02:57 +01:00
|
|
|
static uint32
|
2003-10-29 09:15:02 +01:00
|
|
|
make_colour(PixelColour pc)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
2003-10-29 09:15:02 +01:00
|
|
|
return (((pc.red >> g_red_shift_r) << g_red_shift_l)
|
|
|
|
| ((pc.green >> g_green_shift_r) << g_green_shift_l)
|
|
|
|
| ((pc.blue >> g_blue_shift_r) << g_blue_shift_l));
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }
|
2003-10-30 01:10:32 +01:00
|
|
|
#define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | (x & 0xff00)); }
|
2003-02-05 15:16:33 +01:00
|
|
|
#define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
|
|
|
|
x = (x << 16) | (x >> 16); }
|
|
|
|
|
|
|
|
static uint32
|
|
|
|
translate_colour(uint32 colour)
|
|
|
|
{
|
2003-10-29 09:15:02 +01:00
|
|
|
PixelColour pc;
|
2003-08-01 19:01:58 +02:00
|
|
|
switch (g_server_bpp)
|
2003-02-05 15:16:33 +01:00
|
|
|
{
|
2003-02-09 18:17:37 +01:00
|
|
|
case 15:
|
2003-10-29 09:15:02 +01:00
|
|
|
pc = split_colour15(colour);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
2003-02-05 15:16:33 +01:00
|
|
|
case 16:
|
2003-10-29 09:15:02 +01:00
|
|
|
pc = split_colour16(colour);
|
2003-02-05 15:16:33 +01:00
|
|
|
break;
|
|
|
|
case 24:
|
2003-10-29 09:15:02 +01:00
|
|
|
pc = split_colour24(colour);
|
2003-02-05 15:16:33 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-10-29 09:15:02 +01:00
|
|
|
return make_colour(pc);
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
|
|
|
|
2004-06-12 00:37:05 +02:00
|
|
|
/* indent is confused by UNROLL8 */
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
|
|
|
|
/* repeat and unroll, similar to bitmap.c */
|
|
|
|
/* potentialy any of the following translate */
|
|
|
|
/* functions can use repeat but just doing */
|
|
|
|
/* the most common ones */
|
|
|
|
|
2004-04-27 01:00:25 +02:00
|
|
|
#define UNROLL8(stm) { stm stm stm stm stm stm stm stm }
|
2004-06-12 00:37:05 +02:00
|
|
|
/* 2 byte output repeat */
|
|
|
|
#define REPEAT2(stm) \
|
|
|
|
{ \
|
|
|
|
while (out <= end - 8 * 2) \
|
|
|
|
UNROLL8(stm) \
|
|
|
|
while (out < end) \
|
|
|
|
{ stm } \
|
|
|
|
}
|
|
|
|
/* 4 byte output repeat */
|
|
|
|
#define REPEAT4(stm) \
|
2004-04-27 01:00:25 +02:00
|
|
|
{ \
|
|
|
|
while (out <= end - 8 * 4) \
|
|
|
|
UNROLL8(stm) \
|
|
|
|
while (out < end) \
|
|
|
|
{ stm } \
|
|
|
|
}
|
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
static void
|
2003-02-05 15:16:33 +01:00
|
|
|
translate8to8(uint8 * data, uint8 * out, uint8 * end)
|
2001-09-14 05:38:39 +02:00
|
|
|
{
|
|
|
|
while (out < end)
|
2003-08-28 00:51:33 +02:00
|
|
|
*(out++) = (uint8) g_colmap[*(data++)];
|
2001-09-14 05:38:39 +02:00
|
|
|
}
|
|
|
|
|
2001-06-20 15:54:48 +02:00
|
|
|
static void
|
2003-10-28 10:02:46 +01:00
|
|
|
translate8to16(uint8 * data, uint8 * out, uint8 * end)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2003-10-28 10:02:46 +01:00
|
|
|
uint16 value;
|
|
|
|
|
2004-04-27 01:00:25 +02:00
|
|
|
if (g_arch_match)
|
2003-10-28 10:02:46 +01:00
|
|
|
{
|
2004-06-12 00:37:05 +02:00
|
|
|
REPEAT2
|
|
|
|
(
|
|
|
|
*((uint16 *) out) = g_colmap[*(data++)];
|
|
|
|
out += 2;
|
|
|
|
)
|
2004-03-24 19:16:58 +01:00
|
|
|
}
|
2004-06-12 00:37:05 +02:00
|
|
|
else if (g_xserver_be)
|
2004-03-24 19:16:58 +01:00
|
|
|
{
|
2004-06-12 00:37:05 +02:00
|
|
|
while (out < end)
|
|
|
|
{
|
|
|
|
value = (uint16) g_colmap[*(data++)];
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (out < end)
|
|
|
|
{
|
|
|
|
value = (uint16) g_colmap[*(data++)];
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
}
|
2003-10-28 10:02:46 +01:00
|
|
|
}
|
2004-05-11 15:45:57 +02:00
|
|
|
}
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
/* little endian - conversion happens when colourmap is built */
|
2003-02-05 15:16:33 +01:00
|
|
|
static void
|
2003-02-09 18:17:37 +01:00
|
|
|
translate8to24(uint8 * data, uint8 * out, uint8 * end)
|
|
|
|
{
|
|
|
|
uint32 value;
|
|
|
|
|
2004-03-24 19:16:58 +01:00
|
|
|
if (g_xserver_be)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
2004-03-24 19:16:58 +01:00
|
|
|
while (out < end)
|
2003-10-28 10:02:46 +01:00
|
|
|
{
|
2004-03-24 19:16:58 +01:00
|
|
|
value = g_colmap[*(data++)];
|
2003-10-28 10:02:46 +01:00
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
2004-03-24 19:16:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (out < end)
|
2003-10-28 10:02:46 +01:00
|
|
|
{
|
2004-03-24 19:16:58 +01:00
|
|
|
value = g_colmap[*(data++)];
|
2003-10-28 10:02:46 +01:00
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-28 10:02:46 +01:00
|
|
|
translate8to32(uint8 * data, uint8 * out, uint8 * end)
|
2003-02-05 15:16:33 +01:00
|
|
|
{
|
2003-10-28 10:02:46 +01:00
|
|
|
uint32 value;
|
|
|
|
|
2004-04-27 01:00:25 +02:00
|
|
|
if (g_arch_match)
|
2003-10-28 10:02:46 +01:00
|
|
|
{
|
2004-06-12 00:37:05 +02:00
|
|
|
REPEAT4
|
|
|
|
(
|
|
|
|
*((uint32 *) out) = g_colmap[*(data++)];
|
|
|
|
out += 4;
|
|
|
|
)
|
2004-03-24 19:16:58 +01:00
|
|
|
}
|
2004-06-12 00:37:05 +02:00
|
|
|
else if (g_xserver_be)
|
|
|
|
{
|
|
|
|
while (out < end)
|
|
|
|
{
|
|
|
|
value = g_colmap[*(data++)];
|
|
|
|
*(out++) = value >> 24;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-03-24 19:16:58 +01:00
|
|
|
{
|
2004-06-12 00:37:05 +02:00
|
|
|
while (out < end)
|
|
|
|
{
|
|
|
|
value = g_colmap[*(data++)];
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 24;
|
|
|
|
}
|
2003-10-28 10:02:46 +01:00
|
|
|
}
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
2004-06-12 00:37:05 +02:00
|
|
|
|
|
|
|
/* *INDENT-ON* */
|
2003-02-05 15:16:33 +01:00
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
static void
|
2003-10-11 21:12:10 +02:00
|
|
|
translate15to16(uint16 * data, uint8 * out, uint8 * end)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
uint16 pixel;
|
|
|
|
uint16 value;
|
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
while (out < end)
|
2003-10-11 21:12:10 +02:00
|
|
|
{
|
|
|
|
pixel = *(data++);
|
|
|
|
|
|
|
|
if (g_host_be)
|
|
|
|
{
|
2003-10-28 10:02:46 +01:00
|
|
|
BSWAP16(pixel);
|
|
|
|
}
|
2003-10-11 21:12:10 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
value = make_colour(split_colour15(pixel));
|
2003-10-11 21:12:10 +02:00
|
|
|
|
|
|
|
if (g_xserver_be)
|
|
|
|
{
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
}
|
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
translate15to24(uint16 * data, uint8 * out, uint8 * end)
|
2001-09-14 05:38:39 +02:00
|
|
|
{
|
|
|
|
uint32 value;
|
2003-10-11 21:12:10 +02:00
|
|
|
uint16 pixel;
|
2001-09-14 05:38:39 +02:00
|
|
|
|
|
|
|
while (out < end)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
pixel = *(data++);
|
|
|
|
|
|
|
|
if (g_host_be)
|
|
|
|
{
|
2003-10-28 10:02:46 +01:00
|
|
|
BSWAP16(pixel);
|
|
|
|
}
|
2003-10-11 21:12:10 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
value = make_colour(split_colour15(pixel));
|
2003-10-11 21:12:10 +02:00
|
|
|
if (g_xserver_be)
|
|
|
|
{
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
}
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
static void
|
2003-10-11 21:12:10 +02:00
|
|
|
translate15to32(uint16 * data, uint8 * out, uint8 * end)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
2003-09-26 00:23:42 +02:00
|
|
|
uint16 pixel;
|
2003-10-11 21:12:10 +02:00
|
|
|
uint32 value;
|
2003-09-26 00:23:42 +02:00
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
while (out < end)
|
2003-09-26 00:23:42 +02:00
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
pixel = *(data++);
|
|
|
|
|
2003-09-26 00:23:42 +02:00
|
|
|
if (g_host_be)
|
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
BSWAP16(pixel);
|
|
|
|
}
|
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
value = make_colour(split_colour15(pixel));
|
2003-10-11 21:12:10 +02:00
|
|
|
|
|
|
|
if (g_xserver_be)
|
|
|
|
{
|
|
|
|
*(out++) = value >> 24;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
2003-09-26 00:23:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 24;
|
2003-09-26 00:23:42 +02:00
|
|
|
}
|
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-29 09:37:20 +01:00
|
|
|
translate16to16(uint16 * data, uint8 * out, uint8 * end)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
2003-10-29 09:37:20 +01:00
|
|
|
uint16 pixel;
|
2003-10-11 21:12:10 +02:00
|
|
|
uint16 value;
|
|
|
|
|
2003-10-29 09:37:20 +01:00
|
|
|
while (out < end)
|
2003-10-11 21:12:10 +02:00
|
|
|
{
|
2003-10-29 09:37:20 +01:00
|
|
|
pixel = *(data++);
|
|
|
|
|
|
|
|
if (g_host_be)
|
2003-10-11 21:12:10 +02:00
|
|
|
{
|
2003-10-29 09:37:20 +01:00
|
|
|
BSWAP16(pixel);
|
2003-10-11 21:12:10 +02:00
|
|
|
}
|
|
|
|
|
2003-10-29 09:37:20 +01:00
|
|
|
value = make_colour(split_colour16(pixel));
|
|
|
|
|
|
|
|
if (g_xserver_be)
|
2003-10-11 21:12:10 +02:00
|
|
|
{
|
2003-10-29 09:37:20 +01:00
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
2003-10-11 21:12:10 +02:00
|
|
|
}
|
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
|
|
|
|
2001-06-20 15:54:48 +02:00
|
|
|
static void
|
2003-02-05 15:16:33 +01:00
|
|
|
translate16to24(uint16 * data, uint8 * out, uint8 * end)
|
|
|
|
{
|
|
|
|
uint32 value;
|
2003-10-11 21:12:10 +02:00
|
|
|
uint16 pixel;
|
2003-02-05 15:16:33 +01:00
|
|
|
|
|
|
|
while (out < end)
|
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
pixel = *(data++);
|
|
|
|
|
|
|
|
if (g_host_be)
|
|
|
|
{
|
2003-10-28 10:02:46 +01:00
|
|
|
BSWAP16(pixel);
|
|
|
|
}
|
2003-10-11 21:12:10 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
value = make_colour(split_colour16(pixel));
|
2003-10-11 21:12:10 +02:00
|
|
|
|
|
|
|
if (g_xserver_be)
|
|
|
|
{
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
}
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-11 21:12:10 +02:00
|
|
|
translate16to32(uint16 * data, uint8 * out, uint8 * end)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2003-09-26 00:23:42 +02:00
|
|
|
uint16 pixel;
|
2003-10-11 21:12:10 +02:00
|
|
|
uint32 value;
|
2003-09-26 00:23:42 +02:00
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
while (out < end)
|
2003-09-26 00:23:42 +02:00
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
pixel = *(data++);
|
|
|
|
|
2003-09-26 00:23:42 +02:00
|
|
|
if (g_host_be)
|
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
BSWAP16(pixel);
|
|
|
|
}
|
2003-10-11 21:12:10 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
value = make_colour(split_colour16(pixel));
|
2003-10-11 21:12:10 +02:00
|
|
|
|
|
|
|
if (g_xserver_be)
|
2003-09-26 00:23:42 +02:00
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
*(out++) = value >> 24;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
2003-10-15 16:01:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-10-11 21:12:10 +02:00
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 24;
|
2003-10-15 16:01:32 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
|
|
|
|
2003-02-05 15:16:33 +01:00
|
|
|
static void
|
2003-10-11 21:12:10 +02:00
|
|
|
translate24to16(uint8 * data, uint8 * out, uint8 * end)
|
2003-02-05 15:16:33 +01:00
|
|
|
{
|
2003-02-09 18:17:37 +01:00
|
|
|
uint32 pixel = 0;
|
2003-10-11 21:12:10 +02:00
|
|
|
uint16 value;
|
2003-02-05 15:16:33 +01:00
|
|
|
while (out < end)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
|
|
|
pixel = *(data++) << 16;
|
|
|
|
pixel |= *(data++) << 8;
|
|
|
|
pixel |= *(data++);
|
2003-10-11 21:12:10 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
value = (uint16) make_colour(split_colour24(pixel));
|
2003-10-11 21:12:10 +02:00
|
|
|
|
|
|
|
if (g_xserver_be)
|
|
|
|
{
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
translate24to24(uint8 * data, uint8 * out, uint8 * end)
|
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
uint32 pixel;
|
|
|
|
uint32 value;
|
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
while (out < end)
|
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
pixel = *(data++) << 16;
|
|
|
|
pixel |= *(data++) << 8;
|
|
|
|
pixel |= *(data++);
|
|
|
|
|
|
|
|
value = make_colour(split_colour24(pixel));
|
2003-11-03 14:22:09 +01:00
|
|
|
|
2003-10-30 01:10:32 +01:00
|
|
|
if (g_xserver_be)
|
|
|
|
{
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-11 21:12:10 +02:00
|
|
|
translate24to32(uint8 * data, uint8 * out, uint8 * end)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
uint32 pixel;
|
|
|
|
uint32 value;
|
|
|
|
|
2003-02-09 18:17:37 +01:00
|
|
|
while (out < end)
|
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
pixel = *(data++) << 16;
|
|
|
|
pixel |= *(data++) << 8;
|
|
|
|
pixel |= *(data++);
|
|
|
|
|
|
|
|
value = make_colour(split_colour24(pixel));
|
|
|
|
|
2003-10-11 21:12:10 +02:00
|
|
|
if (g_xserver_be)
|
2003-09-26 00:23:42 +02:00
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
*(out++) = value >> 24;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value;
|
2003-09-26 00:23:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-10-30 01:10:32 +01:00
|
|
|
*(out++) = value;
|
|
|
|
*(out++) = value >> 8;
|
|
|
|
*(out++) = value >> 16;
|
|
|
|
*(out++) = value >> 24;
|
2003-09-26 00:23:42 +02:00
|
|
|
}
|
2003-02-09 18:17:37 +01:00
|
|
|
}
|
2003-02-05 15:16:33 +01:00
|
|
|
}
|
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
static uint8 *
|
2002-07-18 18:38:31 +02:00
|
|
|
translate_image(int width, int height, uint8 * data)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2004-03-25 23:58:45 +01:00
|
|
|
int size;
|
|
|
|
uint8 *out;
|
|
|
|
uint8 *end;
|
|
|
|
|
|
|
|
/* if server and xserver bpp match, */
|
|
|
|
/* and arch(endian) matches, no need to translate */
|
|
|
|
/* just return data */
|
2004-03-29 15:59:03 +02:00
|
|
|
if (g_arch_match)
|
|
|
|
{
|
|
|
|
if (g_depth == 15 && g_server_bpp == 15)
|
|
|
|
return data;
|
|
|
|
if (g_depth == 16 && g_server_bpp == 16)
|
|
|
|
return data;
|
|
|
|
}
|
2004-03-25 23:58:45 +01:00
|
|
|
|
|
|
|
size = width * height * (g_bpp / 8);
|
|
|
|
out = (uint8 *) xmalloc(size);
|
|
|
|
end = out + size;
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2003-08-01 19:01:58 +02:00
|
|
|
switch (g_server_bpp)
|
2001-09-14 05:38:39 +02:00
|
|
|
{
|
2003-02-09 18:17:37 +01:00
|
|
|
case 24:
|
2003-08-28 00:51:33 +02:00
|
|
|
switch (g_bpp)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
|
|
|
case 32:
|
2003-10-11 21:12:10 +02:00
|
|
|
translate24to32(data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
translate24to24(data, out, end);
|
|
|
|
break;
|
|
|
|
case 16:
|
2003-10-11 21:12:10 +02:00
|
|
|
translate24to16(data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
break;
|
|
|
|
case 16:
|
2003-08-28 00:51:33 +02:00
|
|
|
switch (g_bpp)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
|
|
|
case 32:
|
2003-10-11 21:12:10 +02:00
|
|
|
translate16to32((uint16 *) data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
translate16to24((uint16 *) data, out, end);
|
|
|
|
break;
|
|
|
|
case 16:
|
2003-10-29 09:37:20 +01:00
|
|
|
translate16to16((uint16 *) data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
break;
|
2003-02-09 18:17:37 +01:00
|
|
|
case 15:
|
2003-08-28 00:51:33 +02:00
|
|
|
switch (g_bpp)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
|
|
|
case 32:
|
2003-10-11 21:12:10 +02:00
|
|
|
translate15to32((uint16 *) data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
translate15to24((uint16 *) data, out, end);
|
|
|
|
break;
|
|
|
|
case 16:
|
2003-10-11 21:12:10 +02:00
|
|
|
translate15to16((uint16 *) data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
break;
|
2003-02-09 18:17:37 +01:00
|
|
|
case 8:
|
2003-08-28 00:51:33 +02:00
|
|
|
switch (g_bpp)
|
2003-02-09 18:17:37 +01:00
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
translate8to8(data, out, end);
|
|
|
|
break;
|
|
|
|
case 16:
|
2003-10-28 10:02:46 +01:00
|
|
|
translate8to16(data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
translate8to24(data, out, end);
|
|
|
|
break;
|
|
|
|
case 32:
|
2003-10-28 10:02:46 +01:00
|
|
|
translate8to32(data, out, end);
|
2003-02-09 18:17:37 +01:00
|
|
|
break;
|
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return out;
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
2000-08-15 12:23:24 +02:00
|
|
|
|
2002-09-11 13:45:20 +02:00
|
|
|
BOOL
|
2002-10-02 15:51:16 +02:00
|
|
|
get_key_state(unsigned int state, uint32 keysym)
|
2002-08-26 19:14:04 +02:00
|
|
|
{
|
2002-09-26 16:04:30 +02:00
|
|
|
int modifierpos, key, keysymMask = 0;
|
2002-08-26 19:14:04 +02:00
|
|
|
int offset;
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
KeyCode keycode = XKeysymToKeycode(g_display, keysym);
|
2002-08-26 19:14:04 +02:00
|
|
|
|
|
|
|
if (keycode == NoSymbol)
|
|
|
|
return False;
|
|
|
|
|
|
|
|
for (modifierpos = 0; modifierpos < 8; modifierpos++)
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
offset = g_mod_map->max_keypermod * modifierpos;
|
2002-08-26 19:14:04 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
for (key = 0; key < g_mod_map->max_keypermod; key++)
|
2002-08-26 19:14:04 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_mod_map->modifiermap[offset + key] == keycode)
|
2002-09-26 16:04:30 +02:00
|
|
|
keysymMask |= 1 << modifierpos;
|
2002-08-26 19:14:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-26 16:04:30 +02:00
|
|
|
return (state & keysymMask) ? True : False;
|
2002-08-26 19:14:04 +02:00
|
|
|
}
|
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
static void
|
|
|
|
calculate_shifts(uint32 mask, int *shift_r, int *shift_l)
|
|
|
|
{
|
|
|
|
*shift_l = ffs(mask) - 1;
|
|
|
|
mask >>= *shift_l;
|
|
|
|
*shift_r = 8 - ffs(mask & ~(mask >> 1));
|
|
|
|
}
|
|
|
|
|
2002-07-30 03:57:39 +02:00
|
|
|
BOOL
|
2002-09-24 09:59:14 +02:00
|
|
|
ui_init(void)
|
2002-07-30 03:57:39 +02:00
|
|
|
{
|
2003-10-29 09:15:02 +01:00
|
|
|
XVisualInfo vi;
|
2002-09-14 13:48:44 +02:00
|
|
|
XPixmapFormatValues *pfm;
|
|
|
|
uint16 test;
|
2004-01-19 22:58:58 +01:00
|
|
|
int i, screen_num, nvisuals;
|
|
|
|
XVisualInfo *vmatches = NULL;
|
|
|
|
XVisualInfo template;
|
|
|
|
Bool TrueColorVisual = False;
|
2002-09-14 13:48:44 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
g_display = XOpenDisplay(NULL);
|
|
|
|
if (g_display == NULL)
|
2002-07-30 03:57:39 +02:00
|
|
|
{
|
2002-10-04 16:25:37 +02:00
|
|
|
error("Failed to open display: %s\n", XDisplayName(NULL));
|
2002-07-30 03:57:39 +02:00
|
|
|
return False;
|
|
|
|
}
|
2002-09-14 13:48:44 +02:00
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
screen_num = DefaultScreen(g_display);
|
2003-08-28 00:51:33 +02:00
|
|
|
g_x_socket = ConnectionNumber(g_display);
|
2003-10-29 09:15:02 +01:00
|
|
|
g_screen = ScreenOfDisplay(g_display, screen_num);
|
2003-08-28 00:51:33 +02:00
|
|
|
g_depth = DefaultDepthOfScreen(g_screen);
|
2002-09-14 13:48:44 +02:00
|
|
|
|
2004-01-19 22:58:58 +01:00
|
|
|
/* Search for best TrueColor depth */
|
|
|
|
template.class = TrueColor;
|
|
|
|
vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &nvisuals);
|
|
|
|
|
|
|
|
nvisuals--;
|
|
|
|
while (nvisuals >= 0)
|
|
|
|
{
|
|
|
|
if ((vmatches + nvisuals)->depth > g_depth)
|
|
|
|
{
|
|
|
|
g_depth = (vmatches + nvisuals)->depth;
|
|
|
|
}
|
|
|
|
nvisuals--;
|
|
|
|
TrueColorVisual = True;
|
|
|
|
}
|
|
|
|
|
2004-03-25 23:58:45 +01:00
|
|
|
test = 1;
|
|
|
|
g_host_be = !(BOOL) (*(uint8 *) (&test));
|
|
|
|
g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
|
|
|
|
|
2004-01-23 09:35:52 +01:00
|
|
|
if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))
|
2003-10-29 09:15:02 +01:00
|
|
|
{
|
2004-01-19 22:58:58 +01:00
|
|
|
/* we use a colourmap, so the default visual should do */
|
2003-10-29 09:15:02 +01:00
|
|
|
g_visual = DefaultVisualOfScreen(g_screen);
|
2004-01-19 22:58:58 +01:00
|
|
|
g_depth = DefaultDepthOfScreen(g_screen);
|
|
|
|
|
|
|
|
/* Do not allocate colours on a TrueColor visual */
|
|
|
|
if (g_visual->class == TrueColor)
|
|
|
|
{
|
|
|
|
g_owncolmap = False;
|
|
|
|
}
|
2003-10-29 09:15:02 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* need a truecolour visual */
|
|
|
|
if (!XMatchVisualInfo(g_display, screen_num, g_depth, TrueColor, &vi))
|
|
|
|
{
|
|
|
|
error("The display does not support true colour - high colour support unavailable.\n");
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_visual = vi.visual;
|
|
|
|
g_owncolmap = False;
|
2003-10-29 15:14:46 +01:00
|
|
|
calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l);
|
|
|
|
calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l);
|
2003-10-29 09:15:02 +01:00
|
|
|
calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l);
|
2004-03-25 23:58:45 +01:00
|
|
|
|
|
|
|
/* if RGB video and averything is little endian */
|
|
|
|
if (vi.red_mask > vi.green_mask && vi.green_mask > vi.blue_mask)
|
|
|
|
if (!g_xserver_be && !g_host_be)
|
|
|
|
g_arch_match = True;
|
2003-10-29 09:15:02 +01:00
|
|
|
}
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
pfm = XListPixmapFormats(g_display, &i);
|
2002-09-14 13:48:44 +02:00
|
|
|
if (pfm != NULL)
|
|
|
|
{
|
|
|
|
/* Use maximum bpp for this depth - this is generally
|
|
|
|
desirable, e.g. 24 bits->32 bits. */
|
|
|
|
while (i--)
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if ((pfm[i].depth == g_depth) && (pfm[i].bits_per_pixel > g_bpp))
|
2002-09-14 13:48:44 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
g_bpp = pfm[i].bits_per_pixel;
|
2002-09-14 13:48:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
XFree(pfm);
|
|
|
|
}
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_bpp < 8)
|
2002-09-14 13:48:44 +02:00
|
|
|
{
|
|
|
|
error("Less than 8 bpp not currently supported.\n");
|
2003-08-28 00:51:33 +02:00
|
|
|
XCloseDisplay(g_display);
|
2002-09-14 13:48:44 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2003-10-28 04:30:51 +01:00
|
|
|
if (!g_owncolmap)
|
2002-11-26 11:09:14 +01:00
|
|
|
{
|
2004-01-23 09:35:52 +01:00
|
|
|
g_xcolmap =
|
|
|
|
XCreateColormap(g_display, RootWindowOfScreen(g_screen), g_visual,
|
|
|
|
AllocNone);
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_depth <= 8)
|
2003-01-28 13:27:28 +01:00
|
|
|
warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n");
|
2002-11-26 11:09:14 +01:00
|
|
|
}
|
|
|
|
|
2004-02-16 21:28:09 +01:00
|
|
|
if ((!g_ownbackstore) && (DoesBackingStore(g_screen) != Always))
|
|
|
|
{
|
|
|
|
warning("External BackingStore not available, using internal\n");
|
2003-08-28 00:51:33 +02:00
|
|
|
g_ownbackstore = True;
|
2004-02-16 21:28:09 +01:00
|
|
|
}
|
2002-09-14 13:48:44 +02:00
|
|
|
|
2003-10-15 16:32:43 +02:00
|
|
|
/*
|
|
|
|
* Determine desktop size
|
|
|
|
*/
|
2003-11-10 16:09:49 +01:00
|
|
|
if (g_fullscreen)
|
|
|
|
{
|
|
|
|
g_width = WidthOfScreen(g_screen);
|
|
|
|
g_height = HeightOfScreen(g_screen);
|
|
|
|
}
|
|
|
|
else if (g_width < 0)
|
2003-10-15 16:32:43 +02:00
|
|
|
{
|
|
|
|
/* Percent of screen */
|
|
|
|
g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
|
|
|
|
g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
|
|
|
|
}
|
|
|
|
else if (g_width == 0)
|
2002-11-18 19:12:49 +01:00
|
|
|
{
|
|
|
|
/* Fetch geometry from _NET_WORKAREA */
|
2003-01-30 12:20:30 +01:00
|
|
|
uint32 x, y, cx, cy;
|
2002-11-18 19:12:49 +01:00
|
|
|
|
2003-01-30 12:20:30 +01:00
|
|
|
if (get_current_workarea(&x, &y, &cx, &cy) == 0)
|
|
|
|
{
|
2003-08-22 01:23:15 +02:00
|
|
|
g_width = cx;
|
|
|
|
g_height = cy;
|
2003-01-30 12:20:30 +01:00
|
|
|
}
|
|
|
|
else
|
2002-11-18 19:12:49 +01:00
|
|
|
{
|
2003-01-28 13:27:28 +01:00
|
|
|
warning("Failed to get workarea: probably your window manager does not support extended hints\n");
|
2003-08-22 01:23:15 +02:00
|
|
|
g_width = 800;
|
|
|
|
g_height = 600;
|
2002-11-18 19:12:49 +01:00
|
|
|
}
|
|
|
|
}
|
2002-09-14 13:48:44 +02:00
|
|
|
|
2002-09-15 14:42:26 +02:00
|
|
|
/* make sure width is a multiple of 4 */
|
2003-08-22 01:23:15 +02:00
|
|
|
g_width = (g_width + 3) & ~3;
|
2002-09-15 14:42:26 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
g_mod_map = XGetModifierMapping(g_display);
|
2002-09-26 16:04:30 +02:00
|
|
|
|
2003-10-14 14:05:27 +02:00
|
|
|
xkeymap_init();
|
|
|
|
|
2003-08-22 01:23:15 +02:00
|
|
|
if (g_enable_compose)
|
2003-08-28 00:51:33 +02:00
|
|
|
g_IM = XOpenIM(g_display, NULL, NULL, NULL);
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-07-01 11:31:25 +02:00
|
|
|
xclip_init();
|
2003-02-09 18:17:37 +01:00
|
|
|
|
2003-10-28 04:40:26 +01:00
|
|
|
DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth));
|
2003-02-09 18:17:37 +01:00
|
|
|
|
2002-07-30 03:57:39 +02:00
|
|
|
return True;
|
|
|
|
}
|
2002-07-18 20:28:12 +02:00
|
|
|
|
2002-09-24 08:09:09 +02:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
ui_deinit(void)
|
2002-09-24 08:09:09 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_IM != NULL)
|
|
|
|
XCloseIM(g_IM);
|
2004-01-23 09:35:52 +01:00
|
|
|
|
2004-01-22 21:31:59 +01:00
|
|
|
if (g_null_cursor != NULL)
|
|
|
|
ui_destroy_cursor(g_null_cursor);
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreeModifiermap(g_mod_map);
|
2002-09-26 16:04:30 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
|
|
|
XFreePixmap(g_display, g_backstore);
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreeGC(g_display, g_gc);
|
|
|
|
XCloseDisplay(g_display);
|
|
|
|
g_display = NULL;
|
2002-09-24 08:09:09 +02:00
|
|
|
}
|
|
|
|
|
2002-09-14 13:48:44 +02:00
|
|
|
BOOL
|
2002-09-24 09:59:14 +02:00
|
|
|
ui_create_window(void)
|
2000-07-05 09:44:21 +02:00
|
|
|
{
|
2003-10-31 05:29:57 +01:00
|
|
|
uint8 null_pointer_mask[1] = { 0x80 };
|
2004-10-21 10:43:22 +02:00
|
|
|
uint8 null_pointer_data[24] = { 0x00 };
|
|
|
|
|
2002-09-14 13:48:44 +02:00
|
|
|
XSetWindowAttributes attribs;
|
2001-06-20 15:54:48 +02:00
|
|
|
XClassHint *classhints;
|
|
|
|
XSizeHints *sizehints;
|
2002-09-24 08:09:09 +02:00
|
|
|
int wndwidth, wndheight;
|
2003-07-01 11:31:25 +02:00
|
|
|
long input_mask, ic_input_mask;
|
2002-08-24 22:04:56 +02:00
|
|
|
XEvent xevent;
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width;
|
|
|
|
wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
attribs.background_pixel = BlackPixelOfScreen(g_screen);
|
2004-01-19 22:58:58 +01:00
|
|
|
attribs.border_pixel = WhitePixelOfScreen(g_screen);
|
2003-08-28 00:51:33 +02:00
|
|
|
attribs.backing_store = g_ownbackstore ? NotUseful : Always;
|
2003-08-22 01:23:15 +02:00
|
|
|
attribs.override_redirect = g_fullscreen;
|
2004-01-19 22:58:58 +01:00
|
|
|
attribs.colormap = g_xcolmap;
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2004-11-23 14:29:12 +01:00
|
|
|
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), g_xpos, g_ypos, wndwidth,
|
|
|
|
wndheight, 0, g_depth, InputOutput, g_visual,
|
|
|
|
CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
|
|
|
|
CWBorderPixel, &attribs);
|
2004-01-19 22:58:58 +01:00
|
|
|
|
2004-01-22 21:31:59 +01:00
|
|
|
if (g_gc == NULL)
|
2004-01-20 00:45:26 +01:00
|
|
|
g_gc = XCreateGC(g_display, g_wnd, 0, NULL);
|
2004-01-19 22:58:58 +01:00
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
if (g_create_bitmap_gc == NULL)
|
|
|
|
g_create_bitmap_gc = XCreateGC(g_display, g_wnd, 0, NULL);
|
|
|
|
|
2004-02-07 19:47:06 +01:00
|
|
|
if ((g_ownbackstore) && (g_backstore == 0))
|
2004-01-19 22:58:58 +01:00
|
|
|
{
|
2004-01-23 09:35:52 +01:00
|
|
|
g_backstore = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
|
2004-01-19 22:58:58 +01:00
|
|
|
|
|
|
|
/* clear to prevent rubbish being exposed at startup */
|
|
|
|
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
|
|
|
|
XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height);
|
|
|
|
}
|
2002-08-24 22:04:56 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XStoreName(g_display, g_wnd, g_title);
|
2002-08-24 22:04:56 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_hide_decorations)
|
2002-11-18 16:37:20 +01:00
|
|
|
mwm_hide_decorations();
|
|
|
|
|
2002-08-24 22:04:56 +02:00
|
|
|
classhints = XAllocClassHint();
|
|
|
|
if (classhints != NULL)
|
|
|
|
{
|
|
|
|
classhints->res_name = classhints->res_class = "rdesktop";
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetClassHint(g_display, g_wnd, classhints);
|
2002-08-24 22:04:56 +02:00
|
|
|
XFree(classhints);
|
|
|
|
}
|
|
|
|
|
|
|
|
sizehints = XAllocSizeHints();
|
|
|
|
if (sizehints)
|
|
|
|
{
|
|
|
|
sizehints->flags = PMinSize | PMaxSize;
|
2003-08-22 01:23:15 +02:00
|
|
|
sizehints->min_width = sizehints->max_width = g_width;
|
|
|
|
sizehints->min_height = sizehints->max_height = g_height;
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetWMNormalHints(g_display, g_wnd, sizehints);
|
2002-08-24 22:04:56 +02:00
|
|
|
XFree(sizehints);
|
|
|
|
}
|
|
|
|
|
2004-04-15 22:12:42 +02:00
|
|
|
if (g_embed_wnd)
|
|
|
|
{
|
|
|
|
XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0);
|
|
|
|
}
|
2004-03-13 13:08:18 +01:00
|
|
|
|
2002-09-14 13:48:44 +02:00
|
|
|
input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
|
2002-11-12 00:15:27 +01:00
|
|
|
VisibilityChangeMask | FocusChangeMask;
|
2002-09-14 13:48:44 +02:00
|
|
|
|
2003-08-22 01:23:15 +02:00
|
|
|
if (g_sendmotion)
|
2002-09-14 13:48:44 +02:00
|
|
|
input_mask |= PointerMotionMask;
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
2002-09-14 13:48:44 +02:00
|
|
|
input_mask |= ExposureMask;
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_fullscreen || g_grab_keyboard)
|
2002-11-03 13:33:02 +01:00
|
|
|
input_mask |= EnterWindowMask;
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_grab_keyboard)
|
2002-11-12 00:15:27 +01:00
|
|
|
input_mask |= LeaveWindowMask;
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_IM != NULL)
|
2002-09-24 08:09:09 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
g_IC = XCreateIC(g_IM, XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
2003-08-31 22:01:12 +02:00
|
|
|
XNClientWindow, g_wnd, XNFocusWindow, g_wnd, NULL);
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if ((g_IC != NULL)
|
|
|
|
&& (XGetICValues(g_IC, XNFilterEvents, &ic_input_mask, NULL) == NULL))
|
2002-09-24 08:09:09 +02:00
|
|
|
input_mask |= ic_input_mask;
|
|
|
|
}
|
2002-08-24 22:04:56 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XSelectInput(g_display, g_wnd, input_mask);
|
|
|
|
XMapWindow(g_display, g_wnd);
|
2002-08-24 22:04:56 +02:00
|
|
|
|
2002-09-27 03:04:34 +02:00
|
|
|
/* wait for VisibilityNotify */
|
2002-09-25 13:07:12 +02:00
|
|
|
do
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XMaskEvent(g_display, VisibilityChangeMask, &xevent);
|
2002-09-25 13:07:12 +02:00
|
|
|
}
|
2002-09-27 03:04:34 +02:00
|
|
|
while (xevent.type != VisibilityNotify);
|
2004-04-30 21:14:15 +02:00
|
|
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured;
|
2002-08-24 22:04:56 +02:00
|
|
|
|
2003-08-22 01:23:15 +02:00
|
|
|
g_focused = False;
|
|
|
|
g_mouse_in_wnd = False;
|
2002-11-12 00:15:27 +01:00
|
|
|
|
2002-11-19 15:48:02 +01:00
|
|
|
/* handle the WM_DELETE_WINDOW protocol */
|
2003-08-28 00:51:33 +02:00
|
|
|
g_protocol_atom = XInternAtom(g_display, "WM_PROTOCOLS", True);
|
|
|
|
g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);
|
|
|
|
XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);
|
2002-11-19 15:48:02 +01:00
|
|
|
|
2003-10-22 12:55:11 +02:00
|
|
|
/* create invisible 1x1 cursor to be used as null cursor */
|
2004-01-22 21:31:59 +01:00
|
|
|
if (g_null_cursor == NULL)
|
|
|
|
g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);
|
2003-10-22 12:55:11 +02:00
|
|
|
|
2000-08-15 12:23:24 +02:00
|
|
|
return True;
|
2000-07-05 09:44:21 +02:00
|
|
|
}
|
|
|
|
|
2004-04-26 15:48:39 +02:00
|
|
|
void
|
|
|
|
ui_resize_window()
|
|
|
|
{
|
|
|
|
XSizeHints *sizehints;
|
2004-06-04 17:01:36 +02:00
|
|
|
Pixmap bs;
|
2004-04-26 15:48:39 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2004-06-04 17:01:36 +02:00
|
|
|
|
|
|
|
/* create new backstore pixmap */
|
|
|
|
if (g_backstore != 0)
|
|
|
|
{
|
|
|
|
bs = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
|
|
|
|
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen));
|
|
|
|
XFillRectangle(g_display, bs, g_gc, 0, 0, g_width, g_height);
|
|
|
|
XCopyArea(g_display, g_backstore, bs, g_gc, 0, 0, g_width, g_height, 0, 0);
|
|
|
|
XFreePixmap(g_display, g_backstore);
|
|
|
|
g_backstore = bs;
|
|
|
|
}
|
2004-04-26 15:48:39 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
ui_destroy_window(void)
|
2000-07-05 09:44:21 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_IC != NULL)
|
|
|
|
XDestroyIC(g_IC);
|
2002-07-18 20:28:12 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XDestroyWindow(g_display, g_wnd);
|
2000-07-05 09:44:21 +02:00
|
|
|
}
|
|
|
|
|
2002-08-24 22:04:56 +02:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
xwin_toggle_fullscreen(void)
|
2002-08-24 22:04:56 +02:00
|
|
|
{
|
2002-09-24 08:09:09 +02:00
|
|
|
Pixmap contents = 0;
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (!g_ownbackstore)
|
2002-09-24 08:09:09 +02:00
|
|
|
{
|
|
|
|
/* need to save contents of window */
|
2003-08-28 00:51:33 +02:00
|
|
|
contents = XCreatePixmap(g_display, g_wnd, g_width, g_height, g_depth);
|
|
|
|
XCopyArea(g_display, g_wnd, contents, g_gc, 0, 0, g_width, g_height, 0, 0);
|
2002-09-24 08:09:09 +02:00
|
|
|
}
|
2002-09-14 15:47:24 +02:00
|
|
|
|
2002-09-24 08:09:09 +02:00
|
|
|
ui_destroy_window();
|
2003-08-22 01:23:15 +02:00
|
|
|
g_fullscreen = !g_fullscreen;
|
2002-09-24 08:09:09 +02:00
|
|
|
ui_create_window();
|
2002-09-14 15:47:24 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XDefineCursor(g_display, g_wnd, g_current_cursor);
|
2002-09-24 08:09:09 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (!g_ownbackstore)
|
2002-09-24 08:09:09 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XCopyArea(g_display, contents, g_wnd, g_gc, 0, 0, g_width, g_height, 0, 0);
|
|
|
|
XFreePixmap(g_display, contents);
|
2002-09-24 08:09:09 +02:00
|
|
|
}
|
2002-08-24 22:04:56 +02:00
|
|
|
}
|
|
|
|
|
2003-08-22 01:23:15 +02:00
|
|
|
/* Process all events in Xlib queue
|
2002-11-19 15:48:02 +01:00
|
|
|
Returns 0 after user quit, 1 otherwise */
|
|
|
|
static int
|
2002-09-24 09:59:14 +02:00
|
|
|
xwin_process_events(void)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2002-06-07 09:49:59 +02:00
|
|
|
XEvent xevent;
|
2002-04-04 14:04:33 +02:00
|
|
|
KeySym keysym;
|
2002-04-20 11:41:03 +02:00
|
|
|
uint16 button, flags;
|
2000-08-15 12:23:24 +02:00
|
|
|
uint32 ev_time;
|
2002-07-18 20:28:12 +02:00
|
|
|
key_translation tr;
|
|
|
|
char str[256];
|
|
|
|
Status status;
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
while (XPending(g_display) > 0)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XNextEvent(g_display, &xevent);
|
2002-09-14 15:47:24 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if ((g_IC != NULL) && (XFilterEvent(&xevent, None) == True))
|
2002-07-18 20:28:12 +02:00
|
|
|
{
|
2002-07-30 09:30:12 +02:00
|
|
|
DEBUG_KBD(("Filtering event\n"));
|
2002-07-18 20:28:12 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-04-20 11:41:03 +02:00
|
|
|
flags = 0;
|
2000-08-15 12:23:24 +02:00
|
|
|
|
2002-06-07 09:49:59 +02:00
|
|
|
switch (xevent.type)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2004-04-30 21:14:15 +02:00
|
|
|
case VisibilityNotify:
|
|
|
|
g_Unobscured = xevent.xvisibility.state == VisibilityUnobscured;
|
|
|
|
break;
|
2002-11-19 15:48:02 +01:00
|
|
|
case ClientMessage:
|
|
|
|
/* the window manager told us to quit */
|
2003-08-28 00:51:33 +02:00
|
|
|
if ((xevent.xclient.message_type == g_protocol_atom)
|
|
|
|
&& ((Atom) xevent.xclient.data.l[0] == g_kill_atom))
|
2002-11-19 15:48:02 +01:00
|
|
|
/* Quit */
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
|
2002-04-20 11:41:03 +02:00
|
|
|
case KeyPress:
|
2003-08-28 00:51:33 +02:00
|
|
|
g_last_gesturetime = xevent.xkey.time;
|
|
|
|
if (g_IC != NULL)
|
2002-07-18 20:28:12 +02:00
|
|
|
/* Multi_key compatible version */
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XmbLookupString(g_IC,
|
2003-07-09 11:18:20 +02:00
|
|
|
&xevent.xkey, str, sizeof(str), &keysym,
|
|
|
|
&status);
|
2002-07-30 09:18:48 +02:00
|
|
|
if (!((status == XLookupKeySym) || (status == XLookupBoth)))
|
2002-07-18 20:28:12 +02:00
|
|
|
{
|
2002-07-30 09:18:48 +02:00
|
|
|
error("XmbLookupString failed with status 0x%x\n",
|
|
|
|
status);
|
2002-07-18 20:28:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Plain old XLookupString */
|
2002-09-17 18:55:43 +02:00
|
|
|
DEBUG_KBD(("\nNo input context, using XLookupString\n"));
|
2002-07-18 20:28:12 +02:00
|
|
|
XLookupString((XKeyEvent *) & xevent,
|
2002-07-30 09:18:48 +02:00
|
|
|
str, sizeof(str), &keysym, NULL);
|
2002-07-18 20:28:12 +02:00
|
|
|
}
|
|
|
|
|
2002-11-18 16:35:41 +01:00
|
|
|
DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym,
|
|
|
|
get_ksname(keysym)));
|
2002-07-18 20:28:12 +02:00
|
|
|
|
2002-09-26 16:04:30 +02:00
|
|
|
ev_time = time(NULL);
|
|
|
|
if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True))
|
2002-09-11 13:45:20 +02:00
|
|
|
break;
|
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
tr = xkeymap_translate_key(keysym,
|
2002-07-30 09:18:48 +02:00
|
|
|
xevent.xkey.keycode, xevent.xkey.state);
|
2002-07-28 00:35:38 +02:00
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
if (tr.scancode == 0)
|
2002-04-26 10:22:39 +02:00
|
|
|
break;
|
|
|
|
|
2003-09-15 10:03:30 +02:00
|
|
|
save_remote_modifiers(tr.scancode);
|
2002-09-11 11:52:30 +02:00
|
|
|
ensure_remote_modifiers(ev_time, tr);
|
2002-07-30 09:18:48 +02:00
|
|
|
rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
|
2003-09-15 10:03:30 +02:00
|
|
|
restore_remote_modifiers(ev_time, tr.scancode);
|
2003-08-27 11:42:55 +02:00
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
break;
|
2002-09-26 16:04:30 +02:00
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
case KeyRelease:
|
2003-08-28 00:51:33 +02:00
|
|
|
g_last_gesturetime = xevent.xkey.time;
|
2002-07-18 20:28:12 +02:00
|
|
|
XLookupString((XKeyEvent *) & xevent, str,
|
|
|
|
sizeof(str), &keysym, NULL);
|
|
|
|
|
2002-07-30 09:30:12 +02:00
|
|
|
DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym,
|
2002-09-26 16:04:30 +02:00
|
|
|
get_ksname(keysym)));
|
2002-07-18 20:28:12 +02:00
|
|
|
|
2002-09-26 16:04:30 +02:00
|
|
|
ev_time = time(NULL);
|
|
|
|
if (handle_special_keys(keysym, xevent.xkey.state, ev_time, False))
|
2002-09-11 13:45:20 +02:00
|
|
|
break;
|
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
tr = xkeymap_translate_key(keysym,
|
2002-07-30 09:18:48 +02:00
|
|
|
xevent.xkey.keycode, xevent.xkey.state);
|
2002-04-26 10:22:39 +02:00
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
if (tr.scancode == 0)
|
|
|
|
break;
|
2002-04-26 10:22:39 +02:00
|
|
|
|
2002-07-30 09:18:48 +02:00
|
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, tr.scancode);
|
2000-07-25 14:34:29 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ButtonPress:
|
2002-04-20 11:41:03 +02:00
|
|
|
flags = MOUSE_FLAG_DOWN;
|
|
|
|
/* fall through */
|
2000-07-25 14:34:29 +02:00
|
|
|
|
|
|
|
case ButtonRelease:
|
2003-08-28 00:51:33 +02:00
|
|
|
g_last_gesturetime = xevent.xbutton.time;
|
2002-07-30 09:18:48 +02:00
|
|
|
button = xkeymap_translate_button(xevent.xbutton.button);
|
2000-07-25 14:34:29 +02:00
|
|
|
if (button == 0)
|
|
|
|
break;
|
|
|
|
|
2003-02-18 14:03:51 +01:00
|
|
|
/* If win_button_size is nonzero, enable single app mode */
|
2003-08-28 00:51:33 +02:00
|
|
|
if (xevent.xbutton.y < g_win_button_size)
|
2003-02-18 14:03:51 +01:00
|
|
|
{
|
2003-03-14 13:00:17 +01:00
|
|
|
/* Stop moving window when button is released, regardless of cursor position */
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_moving_wnd && (xevent.type == ButtonRelease))
|
|
|
|
g_moving_wnd = False;
|
2003-03-14 13:00:17 +01:00
|
|
|
|
|
|
|
/* Check from right to left: */
|
2003-02-18 14:51:43 +01:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (xevent.xbutton.x >= g_width - g_win_button_size)
|
2003-02-18 14:44:27 +01:00
|
|
|
{
|
|
|
|
/* The close button, continue */
|
2003-02-18 14:03:51 +01:00
|
|
|
;
|
|
|
|
}
|
2003-08-31 22:01:12 +02:00
|
|
|
else if (xevent.xbutton.x >=
|
|
|
|
g_width - g_win_button_size * 2)
|
2003-02-18 14:03:51 +01:00
|
|
|
{
|
|
|
|
/* The maximize/restore button. Do not send to
|
|
|
|
server. It might be a good idea to change the
|
2003-08-22 01:23:15 +02:00
|
|
|
cursor or give some other visible indication
|
2003-02-18 14:03:51 +01:00
|
|
|
that rdesktop inhibited this click */
|
|
|
|
break;
|
|
|
|
}
|
2003-08-31 22:01:12 +02:00
|
|
|
else if (xevent.xbutton.x >=
|
|
|
|
g_width - g_win_button_size * 3)
|
2003-02-18 14:03:51 +01:00
|
|
|
{
|
|
|
|
/* The minimize button. Iconify window. */
|
2003-08-28 00:51:33 +02:00
|
|
|
XIconifyWindow(g_display, g_wnd,
|
|
|
|
DefaultScreen(g_display));
|
2003-02-18 14:03:51 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-08-28 00:51:33 +02:00
|
|
|
else if (xevent.xbutton.x <= g_win_button_size)
|
2003-03-14 13:00:17 +01:00
|
|
|
{
|
|
|
|
/* The system menu. Ignore. */
|
|
|
|
break;
|
|
|
|
}
|
2003-02-18 14:51:43 +01:00
|
|
|
else
|
|
|
|
{
|
2003-03-14 13:00:17 +01:00
|
|
|
/* The title bar. */
|
2003-08-22 01:23:15 +02:00
|
|
|
if ((xevent.type == ButtonPress) && !g_fullscreen
|
2003-08-28 00:51:33 +02:00
|
|
|
&& g_hide_decorations)
|
2003-03-14 13:00:17 +01:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
g_moving_wnd = True;
|
|
|
|
g_move_x_offset = xevent.xbutton.x;
|
|
|
|
g_move_y_offset = xevent.xbutton.y;
|
2003-03-14 13:00:17 +01:00
|
|
|
}
|
2003-02-18 14:51:43 +01:00
|
|
|
break;
|
2003-03-14 13:00:17 +01:00
|
|
|
|
2003-02-18 14:51:43 +01:00
|
|
|
}
|
2003-02-18 14:03:51 +01:00
|
|
|
}
|
|
|
|
|
2002-09-26 16:04:30 +02:00
|
|
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
|
2002-07-30 09:18:48 +02:00
|
|
|
flags | button, xevent.xbutton.x, xevent.xbutton.y);
|
2000-08-15 12:23:24 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MotionNotify:
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_moving_wnd)
|
2003-03-14 13:00:17 +01:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XMoveWindow(g_display, g_wnd,
|
|
|
|
xevent.xmotion.x_root - g_move_x_offset,
|
|
|
|
xevent.xmotion.y_root - g_move_y_offset);
|
2003-03-14 13:00:17 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-08-22 01:23:15 +02:00
|
|
|
if (g_fullscreen && !g_focused)
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetInputFocus(g_display, g_wnd, RevertToPointerRoot,
|
2003-01-05 21:06:32 +01:00
|
|
|
CurrentTime);
|
2002-09-26 16:04:30 +02:00
|
|
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE,
|
2002-07-30 09:18:48 +02:00
|
|
|
MOUSE_FLAG_MOVE, xevent.xmotion.x, xevent.xmotion.y);
|
2001-06-20 15:54:48 +02:00
|
|
|
break;
|
|
|
|
|
2002-09-24 14:25:21 +02:00
|
|
|
case FocusIn:
|
2002-11-12 00:15:27 +01:00
|
|
|
if (xevent.xfocus.mode == NotifyGrab)
|
|
|
|
break;
|
2003-08-22 01:23:15 +02:00
|
|
|
g_focused = True;
|
2003-11-03 14:33:35 +01:00
|
|
|
reset_modifier_keys();
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_grab_keyboard && g_mouse_in_wnd)
|
|
|
|
XGrabKeyboard(g_display, g_wnd, True,
|
2002-07-30 09:18:48 +02:00
|
|
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
2001-06-20 15:54:48 +02:00
|
|
|
break;
|
|
|
|
|
2002-09-24 14:25:21 +02:00
|
|
|
case FocusOut:
|
2002-11-12 00:15:27 +01:00
|
|
|
if (xevent.xfocus.mode == NotifyUngrab)
|
|
|
|
break;
|
2003-08-22 01:23:15 +02:00
|
|
|
g_focused = False;
|
2002-09-25 16:33:36 +02:00
|
|
|
if (xevent.xfocus.mode == NotifyWhileGrabbed)
|
2003-08-28 00:51:33 +02:00
|
|
|
XUngrabKeyboard(g_display, CurrentTime);
|
2001-06-20 15:54:48 +02:00
|
|
|
break;
|
2001-09-15 05:16:05 +02:00
|
|
|
|
2002-11-03 13:33:02 +01:00
|
|
|
case EnterNotify:
|
|
|
|
/* we only register for this event when in fullscreen mode */
|
2002-11-12 00:15:27 +01:00
|
|
|
/* or grab_keyboard */
|
2003-08-22 01:23:15 +02:00
|
|
|
g_mouse_in_wnd = True;
|
|
|
|
if (g_fullscreen)
|
2002-11-12 00:15:27 +01:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetInputFocus(g_display, g_wnd, RevertToPointerRoot,
|
2002-11-18 16:35:41 +01:00
|
|
|
CurrentTime);
|
2002-11-12 00:15:27 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-08-22 01:23:15 +02:00
|
|
|
if (g_focused)
|
2003-08-28 00:51:33 +02:00
|
|
|
XGrabKeyboard(g_display, g_wnd, True,
|
2002-11-12 00:15:27 +01:00
|
|
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
2002-11-03 13:33:02 +01:00
|
|
|
break;
|
|
|
|
|
2002-11-05 12:09:26 +01:00
|
|
|
case LeaveNotify:
|
2002-11-12 00:15:27 +01:00
|
|
|
/* we only register for this event when grab_keyboard */
|
2003-08-22 01:23:15 +02:00
|
|
|
g_mouse_in_wnd = False;
|
2003-08-28 00:51:33 +02:00
|
|
|
XUngrabKeyboard(g_display, CurrentTime);
|
2002-11-05 12:09:26 +01:00
|
|
|
break;
|
|
|
|
|
2001-09-15 05:16:05 +02:00
|
|
|
case Expose:
|
2003-08-28 00:51:33 +02:00
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc,
|
2002-06-07 09:49:59 +02:00
|
|
|
xevent.xexpose.x, xevent.xexpose.y,
|
2002-07-18 18:38:31 +02:00
|
|
|
xevent.xexpose.width,
|
|
|
|
xevent.xexpose.height,
|
2002-06-07 09:49:59 +02:00
|
|
|
xevent.xexpose.x, xevent.xexpose.y);
|
2001-09-15 05:16:05 +02:00
|
|
|
break;
|
2002-09-12 11:38:31 +02:00
|
|
|
|
|
|
|
case MappingNotify:
|
|
|
|
/* Refresh keyboard mapping if it has changed. This is important for
|
|
|
|
Xvnc, since it allocates keycodes dynamically */
|
|
|
|
if (xevent.xmapping.request == MappingKeyboard
|
|
|
|
|| xevent.xmapping.request == MappingModifier)
|
|
|
|
XRefreshKeyboardMapping(&xevent.xmapping);
|
2002-09-26 16:04:30 +02:00
|
|
|
|
|
|
|
if (xevent.xmapping.request == MappingModifier)
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreeModifiermap(g_mod_map);
|
|
|
|
g_mod_map = XGetModifierMapping(g_display);
|
2002-09-26 16:04:30 +02:00
|
|
|
}
|
2002-09-12 11:38:31 +02:00
|
|
|
break;
|
2003-07-01 11:31:25 +02:00
|
|
|
|
2003-07-09 11:18:20 +02:00
|
|
|
/* clipboard stuff */
|
2003-06-06 13:10:48 +02:00
|
|
|
case SelectionNotify:
|
2003-07-01 11:31:25 +02:00
|
|
|
xclip_handle_SelectionNotify(&xevent.xselection);
|
2003-06-06 13:10:48 +02:00
|
|
|
break;
|
|
|
|
case SelectionRequest:
|
2003-07-01 11:31:25 +02:00
|
|
|
xclip_handle_SelectionRequest(&xevent.xselectionrequest);
|
|
|
|
break;
|
|
|
|
case SelectionClear:
|
|
|
|
xclip_handle_SelectionClear();
|
2003-06-06 13:10:48 +02:00
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
2003-07-01 11:31:25 +02:00
|
|
|
xclip_handle_PropertyNotify(&xevent.xproperty);
|
2003-06-06 13:10:48 +02:00
|
|
|
break;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
}
|
2002-11-19 15:48:02 +01:00
|
|
|
/* Keep going */
|
|
|
|
return 1;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2002-11-19 15:48:02 +01:00
|
|
|
/* Returns 0 after user quit, 1 otherwise */
|
|
|
|
int
|
2001-09-15 14:34:34 +02:00
|
|
|
ui_select(int rdp_socket)
|
|
|
|
{
|
2004-02-15 00:20:24 +01:00
|
|
|
int n;
|
2003-09-30 11:11:08 +02:00
|
|
|
fd_set rfds, wfds;
|
2004-01-30 15:10:32 +01:00
|
|
|
struct timeval tv;
|
|
|
|
BOOL s_timeout = False;
|
2001-09-15 14:34:34 +02:00
|
|
|
|
|
|
|
while (True)
|
|
|
|
{
|
2004-02-15 00:20:24 +01:00
|
|
|
n = (rdp_socket > g_x_socket) ? rdp_socket : g_x_socket;
|
2002-09-14 13:48:44 +02:00
|
|
|
/* Process any events already waiting */
|
2002-11-19 15:48:02 +01:00
|
|
|
if (!xwin_process_events())
|
|
|
|
/* User quit */
|
|
|
|
return 0;
|
2002-09-12 11:38:31 +02:00
|
|
|
|
2001-09-15 14:34:34 +02:00
|
|
|
FD_ZERO(&rfds);
|
2003-09-30 11:11:08 +02:00
|
|
|
FD_ZERO(&wfds);
|
2001-09-15 14:34:34 +02:00
|
|
|
FD_SET(rdp_socket, &rfds);
|
2003-08-28 00:51:33 +02:00
|
|
|
FD_SET(g_x_socket, &rfds);
|
2001-09-15 14:34:34 +02:00
|
|
|
|
2003-09-30 11:11:08 +02:00
|
|
|
#ifdef WITH_RDPSND
|
|
|
|
/* FIXME: there should be an API for registering fds */
|
2003-10-19 13:59:41 +02:00
|
|
|
if (g_dsp_busy)
|
2003-09-30 11:11:08 +02:00
|
|
|
{
|
|
|
|
FD_SET(g_dsp_fd, &wfds);
|
2004-01-30 15:10:32 +01:00
|
|
|
n = (g_dsp_fd > n) ? g_dsp_fd : n;
|
2003-10-15 16:01:32 +02:00
|
|
|
}
|
2003-09-30 11:11:08 +02:00
|
|
|
#endif
|
2004-01-30 15:10:32 +01:00
|
|
|
/* default timeout */
|
|
|
|
tv.tv_sec = 60;
|
|
|
|
tv.tv_usec = 0;
|
2003-09-30 11:11:08 +02:00
|
|
|
|
2004-01-30 15:10:32 +01:00
|
|
|
/* add redirection handles */
|
|
|
|
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout);
|
|
|
|
|
|
|
|
n++;
|
|
|
|
|
|
|
|
switch (select(n, &rfds, &wfds, NULL, &tv))
|
2001-09-15 14:34:34 +02:00
|
|
|
{
|
|
|
|
case -1:
|
|
|
|
error("select: %s\n", strerror(errno));
|
|
|
|
|
|
|
|
case 0:
|
2004-11-03 14:56:52 +01:00
|
|
|
/* Abort serial read calls */
|
|
|
|
if (s_timeout)
|
|
|
|
rdpdr_check_fds(&rfds, &wfds, (BOOL) True);
|
2001-09-15 14:34:34 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-01-30 15:10:32 +01:00
|
|
|
rdpdr_check_fds(&rfds, &wfds, (BOOL) False);
|
|
|
|
|
2004-08-23 13:28:23 +02:00
|
|
|
if (FD_ISSET(rdp_socket, &rfds))
|
|
|
|
return 1;
|
|
|
|
|
2003-09-30 11:11:08 +02:00
|
|
|
#ifdef WITH_RDPSND
|
2003-10-19 13:59:41 +02:00
|
|
|
if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
|
2003-09-30 11:11:08 +02:00
|
|
|
wave_out_play();
|
|
|
|
#endif
|
2001-09-15 14:34:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_move_pointer(int x, int y)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XWarpPointer(g_display, g_wnd, g_wnd, 0, 0, 0, 0, x, y);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
HBITMAP
|
2002-07-18 18:38:31 +02:00
|
|
|
ui_create_bitmap(int width, int height, uint8 * data)
|
2000-07-05 09:44:21 +02:00
|
|
|
{
|
|
|
|
XImage *image;
|
2000-07-25 14:34:29 +02:00
|
|
|
Pixmap bitmap;
|
2001-06-20 15:54:48 +02:00
|
|
|
uint8 *tdata;
|
2003-10-28 10:02:46 +01:00
|
|
|
int bitmap_pad;
|
|
|
|
|
|
|
|
if (g_server_bpp == 8)
|
|
|
|
{
|
|
|
|
bitmap_pad = 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bitmap_pad = g_bpp;
|
|
|
|
|
|
|
|
if (g_bpp == 24)
|
|
|
|
bitmap_pad = 32;
|
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
tdata = (g_owncolmap ? data : translate_image(width, height, data));
|
|
|
|
bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);
|
|
|
|
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
|
2003-10-28 10:02:46 +01:00
|
|
|
(char *) tdata, width, height, bitmap_pad, 0);
|
2000-07-05 09:44:21 +02:00
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
XPutImage(g_display, bitmap, g_create_bitmap_gc, image, 0, 0, 0, 0, width, height);
|
2001-01-06 04:12:10 +01:00
|
|
|
|
2001-06-20 15:54:48 +02:00
|
|
|
XFree(image);
|
2004-03-25 23:58:45 +01:00
|
|
|
if (tdata != data)
|
2002-11-26 11:09:14 +01:00
|
|
|
xfree(tdata);
|
2001-01-06 04:12:10 +01:00
|
|
|
return (HBITMAP) bitmap;
|
2000-07-05 09:44:21 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data)
|
2000-07-05 09:44:21 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
XImage *image;
|
2001-09-14 05:38:39 +02:00
|
|
|
uint8 *tdata;
|
2003-10-28 10:02:46 +01:00
|
|
|
int bitmap_pad;
|
|
|
|
|
|
|
|
if (g_server_bpp == 8)
|
|
|
|
{
|
|
|
|
bitmap_pad = 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bitmap_pad = g_bpp;
|
|
|
|
|
|
|
|
if (g_bpp == 24)
|
|
|
|
bitmap_pad = 32;
|
|
|
|
}
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
tdata = (g_owncolmap ? data : translate_image(width, height, data));
|
|
|
|
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
|
2003-10-28 10:02:46 +01:00
|
|
|
(char *) tdata, width, height, bitmap_pad, 0);
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
2001-09-15 05:16:05 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XPutImage(g_display, g_backstore, g_gc, image, 0, 0, x, y, cx, cy);
|
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XPutImage(g_display, g_wnd, g_gc, image, 0, 0, x, y, cx, cy);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
XFree(image);
|
2004-03-25 23:58:45 +01:00
|
|
|
if (tdata != data)
|
2002-11-26 11:09:14 +01:00
|
|
|
xfree(tdata);
|
2000-08-15 12:23:24 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_destroy_bitmap(HBITMAP bmp)
|
2000-08-15 12:23:24 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreePixmap(g_display, (Pixmap) bmp);
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
HGLYPH
|
2002-07-18 18:38:31 +02:00
|
|
|
ui_create_glyph(int width, int height, uint8 * data)
|
2000-07-05 09:44:21 +02:00
|
|
|
{
|
2000-07-25 14:34:29 +02:00
|
|
|
XImage *image;
|
|
|
|
Pixmap bitmap;
|
|
|
|
int scanline;
|
|
|
|
|
|
|
|
scanline = (width + 7) / 8;
|
2000-07-05 09:44:21 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
bitmap = XCreatePixmap(g_display, g_wnd, width, height, 1);
|
2004-06-27 19:51:54 +02:00
|
|
|
if (g_create_glyph_gc == 0)
|
|
|
|
g_create_glyph_gc = XCreateGC(g_display, bitmap, 0, NULL);
|
2000-07-05 09:44:21 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
image = XCreateImage(g_display, g_visual, 1, ZPixmap, 0, (char *) data,
|
2002-07-29 21:21:51 +02:00
|
|
|
width, height, 8, scanline);
|
2000-10-17 10:24:09 +02:00
|
|
|
image->byte_order = MSBFirst;
|
|
|
|
image->bitmap_bit_order = MSBFirst;
|
|
|
|
XInitImage(image);
|
|
|
|
|
2004-06-27 19:51:54 +02:00
|
|
|
XPutImage(g_display, bitmap, g_create_glyph_gc, image, 0, 0, 0, 0, width, height);
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2000-07-25 14:34:29 +02:00
|
|
|
XFree(image);
|
2002-07-18 18:38:31 +02:00
|
|
|
return (HGLYPH) bitmap;
|
2000-07-05 09:44:21 +02:00
|
|
|
}
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_destroy_glyph(HGLYPH glyph)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreePixmap(g_display, (Pixmap) glyph);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
HCURSOR
|
2002-07-18 20:28:12 +02:00
|
|
|
ui_create_cursor(unsigned int x, unsigned int y, int width, int height,
|
|
|
|
uint8 * andmask, uint8 * xormask)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
HGLYPH maskglyph, cursorglyph;
|
|
|
|
XColor bg, fg;
|
|
|
|
Cursor xcursor;
|
|
|
|
uint8 *cursor, *pcursor;
|
|
|
|
uint8 *mask, *pmask;
|
|
|
|
uint8 nextbit;
|
|
|
|
int scanline, offset;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
scanline = (width + 7) / 8;
|
|
|
|
offset = scanline * height;
|
|
|
|
|
2003-06-06 13:10:48 +02:00
|
|
|
cursor = (uint8 *) xmalloc(offset);
|
2001-09-14 05:38:39 +02:00
|
|
|
memset(cursor, 0, offset);
|
|
|
|
|
2003-06-06 13:10:48 +02:00
|
|
|
mask = (uint8 *) xmalloc(offset);
|
2001-09-14 05:38:39 +02:00
|
|
|
memset(mask, 0, offset);
|
|
|
|
|
|
|
|
/* approximate AND and XOR masks with a monochrome X pointer */
|
|
|
|
for (i = 0; i < height; i++)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
offset -= scanline;
|
|
|
|
pcursor = &cursor[offset];
|
|
|
|
pmask = &mask[offset];
|
|
|
|
|
|
|
|
for (j = 0; j < scanline; j++)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
for (nextbit = 0x80; nextbit != 0; nextbit >>= 1)
|
|
|
|
{
|
|
|
|
if (xormask[0] || xormask[1] || xormask[2])
|
|
|
|
{
|
|
|
|
*pcursor |= (~(*andmask) & nextbit);
|
|
|
|
*pmask |= nextbit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*pcursor |= ((*andmask) & nextbit);
|
|
|
|
*pmask |= (~(*andmask) & nextbit);
|
|
|
|
}
|
|
|
|
|
|
|
|
xormask += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
andmask++;
|
|
|
|
pcursor++;
|
|
|
|
pmask++;
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
2000-07-07 11:40:03 +02:00
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
|
|
|
|
fg.red = fg.blue = fg.green = 0xffff;
|
|
|
|
bg.red = bg.blue = bg.green = 0x0000;
|
|
|
|
fg.flags = bg.flags = DoRed | DoBlue | DoGreen;
|
|
|
|
|
|
|
|
cursorglyph = ui_create_glyph(width, height, cursor);
|
|
|
|
maskglyph = ui_create_glyph(width, height, mask);
|
2002-07-18 18:38:31 +02:00
|
|
|
|
2002-07-18 20:28:12 +02:00
|
|
|
xcursor =
|
2003-08-28 00:51:33 +02:00
|
|
|
XCreatePixmapCursor(g_display, (Pixmap) cursorglyph,
|
2002-07-18 20:28:12 +02:00
|
|
|
(Pixmap) maskglyph, &fg, &bg, x, y);
|
2001-09-14 05:38:39 +02:00
|
|
|
|
|
|
|
ui_destroy_glyph(maskglyph);
|
|
|
|
ui_destroy_glyph(cursorglyph);
|
|
|
|
xfree(mask);
|
|
|
|
xfree(cursor);
|
2002-07-18 18:38:31 +02:00
|
|
|
return (HCURSOR) xcursor;
|
2001-09-14 05:38:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ui_set_cursor(HCURSOR cursor)
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
g_current_cursor = (Cursor) cursor;
|
|
|
|
XDefineCursor(g_display, g_wnd, g_current_cursor);
|
2001-09-14 05:38:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ui_destroy_cursor(HCURSOR cursor)
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreeCursor(g_display, (Cursor) cursor);
|
2001-09-14 05:38:39 +02:00
|
|
|
}
|
|
|
|
|
2003-10-22 12:55:11 +02:00
|
|
|
void
|
|
|
|
ui_set_null_cursor(void)
|
|
|
|
{
|
|
|
|
ui_set_cursor(g_null_cursor);
|
|
|
|
}
|
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
#define MAKE_XCOLOR(xc,c) \
|
|
|
|
(xc)->red = ((c)->red << 8) | (c)->red; \
|
|
|
|
(xc)->green = ((c)->green << 8) | (c)->green; \
|
|
|
|
(xc)->blue = ((c)->blue << 8) | (c)->blue; \
|
|
|
|
(xc)->flags = DoRed | DoGreen | DoBlue;
|
|
|
|
|
2002-11-26 11:09:14 +01:00
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
HCOLOURMAP
|
2002-07-18 18:38:31 +02:00
|
|
|
ui_create_colourmap(COLOURMAP * colours)
|
2001-09-14 05:38:39 +02:00
|
|
|
{
|
|
|
|
COLOURENTRY *entry;
|
|
|
|
int i, ncolours = colours->ncolours;
|
2003-08-28 00:51:33 +02:00
|
|
|
if (!g_owncolmap)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
uint32 *map = (uint32 *) xmalloc(sizeof(*g_colmap) * ncolours);
|
2002-11-26 11:09:14 +01:00
|
|
|
XColor xentry;
|
|
|
|
XColor xc_cache[256];
|
|
|
|
uint32 colour;
|
|
|
|
int colLookup = 256;
|
|
|
|
for (i = 0; i < ncolours; i++)
|
2001-06-20 15:54:48 +02:00
|
|
|
{
|
2002-11-26 11:09:14 +01:00
|
|
|
entry = &colours->colours[i];
|
|
|
|
MAKE_XCOLOR(&xentry, entry);
|
2002-09-18 14:13:08 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (XAllocColor(g_display, g_xcolmap, &xentry) == 0)
|
2002-09-25 13:07:12 +02:00
|
|
|
{
|
2002-11-26 11:09:14 +01:00
|
|
|
/* Allocation failed, find closest match. */
|
|
|
|
int j = 256;
|
|
|
|
int nMinDist = 3 * 256 * 256;
|
|
|
|
long nDist = nMinDist;
|
2002-09-18 14:13:08 +02:00
|
|
|
|
2002-11-26 11:09:14 +01:00
|
|
|
/* only get the colors once */
|
|
|
|
while (colLookup--)
|
2002-09-25 13:07:12 +02:00
|
|
|
{
|
2002-11-26 11:09:14 +01:00
|
|
|
xc_cache[colLookup].pixel = colLookup;
|
|
|
|
xc_cache[colLookup].red = xc_cache[colLookup].green =
|
|
|
|
xc_cache[colLookup].blue = 0;
|
|
|
|
xc_cache[colLookup].flags = 0;
|
2003-08-28 00:51:33 +02:00
|
|
|
XQueryColor(g_display,
|
|
|
|
DefaultColormap(g_display,
|
|
|
|
DefaultScreen(g_display)),
|
2002-11-26 11:09:14 +01:00
|
|
|
&xc_cache[colLookup]);
|
2002-09-18 14:13:08 +02:00
|
|
|
}
|
2002-11-26 11:09:14 +01:00
|
|
|
colLookup = 0;
|
|
|
|
|
|
|
|
/* approximate the pixel */
|
|
|
|
while (j--)
|
2002-09-25 13:07:12 +02:00
|
|
|
{
|
2002-11-26 11:09:14 +01:00
|
|
|
if (xc_cache[j].flags)
|
|
|
|
{
|
|
|
|
nDist = ((long) (xc_cache[j].red >> 8) -
|
|
|
|
(long) (xentry.red >> 8)) *
|
|
|
|
((long) (xc_cache[j].red >> 8) -
|
|
|
|
(long) (xentry.red >> 8)) +
|
|
|
|
((long) (xc_cache[j].green >> 8) -
|
|
|
|
(long) (xentry.green >> 8)) *
|
|
|
|
((long) (xc_cache[j].green >> 8) -
|
|
|
|
(long) (xentry.green >> 8)) +
|
|
|
|
((long) (xc_cache[j].blue >> 8) -
|
|
|
|
(long) (xentry.blue >> 8)) *
|
|
|
|
((long) (xc_cache[j].blue >> 8) -
|
|
|
|
(long) (xentry.blue >> 8));
|
|
|
|
}
|
|
|
|
if (nDist < nMinDist)
|
|
|
|
{
|
|
|
|
nMinDist = nDist;
|
|
|
|
xentry.pixel = j;
|
|
|
|
}
|
2002-09-18 14:13:08 +02:00
|
|
|
}
|
|
|
|
}
|
2002-11-26 11:09:14 +01:00
|
|
|
colour = xentry.pixel;
|
|
|
|
|
|
|
|
/* update our cache */
|
|
|
|
if (xentry.pixel < 256)
|
|
|
|
{
|
|
|
|
xc_cache[xentry.pixel].red = xentry.red;
|
|
|
|
xc_cache[xentry.pixel].green = xentry.green;
|
|
|
|
xc_cache[xentry.pixel].blue = xentry.blue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-10-29 09:15:02 +01:00
|
|
|
map[i] = colour;
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
2002-11-26 11:09:14 +01:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XColor *xcolours, *xentry;
|
|
|
|
Colormap map;
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2003-06-06 13:10:48 +02:00
|
|
|
xcolours = (XColor *) xmalloc(sizeof(XColor) * ncolours);
|
2002-11-26 11:09:14 +01:00
|
|
|
for (i = 0; i < ncolours; i++)
|
2002-09-25 13:07:12 +02:00
|
|
|
{
|
2002-11-26 11:09:14 +01:00
|
|
|
entry = &colours->colours[i];
|
|
|
|
xentry = &xcolours[i];
|
|
|
|
xentry->pixel = i;
|
|
|
|
MAKE_XCOLOR(xentry, entry);
|
2001-09-14 05:38:39 +02:00
|
|
|
}
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
map = XCreateColormap(g_display, g_wnd, g_visual, AllocAll);
|
|
|
|
XStoreColors(g_display, map, xcolours, ncolours);
|
2002-09-18 14:13:08 +02:00
|
|
|
|
2002-11-26 11:09:14 +01:00
|
|
|
xfree(xcolours);
|
|
|
|
return (HCOLOURMAP) map;
|
2001-06-20 15:54:48 +02:00
|
|
|
}
|
2000-07-07 11:40:03 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_destroy_colourmap(HCOLOURMAP map)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if (!g_owncolmap)
|
2002-11-26 11:09:14 +01:00
|
|
|
xfree(map);
|
|
|
|
else
|
2003-08-28 00:51:33 +02:00
|
|
|
XFreeColormap(g_display, (Colormap) map);
|
2000-07-07 11:40:03 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_set_colourmap(HCOLOURMAP map)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if (!g_owncolmap)
|
2003-08-27 10:21:53 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_colmap)
|
|
|
|
xfree(g_colmap);
|
2003-08-27 10:21:53 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
g_colmap = (uint32 *) map;
|
2003-08-27 10:21:53 +02:00
|
|
|
}
|
2002-11-26 11:09:14 +01:00
|
|
|
else
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetWindowColormap(g_display, g_wnd, (Colormap) map);
|
2000-07-07 11:40:03 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_set_clip(int x, int y, int cx, int cy)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
|
|
|
XRectangle rect;
|
|
|
|
|
|
|
|
rect.x = x;
|
|
|
|
rect.y = y;
|
|
|
|
rect.width = cx;
|
|
|
|
rect.height = cy;
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetClipRectangles(g_display, g_gc, 0, 0, &rect, 1, YXBanded);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
ui_reset_clip(void)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2000-07-25 14:34:29 +02:00
|
|
|
XRectangle rect;
|
|
|
|
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
2003-08-22 01:23:15 +02:00
|
|
|
rect.width = g_width;
|
|
|
|
rect.height = g_height;
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetClipRectangles(g_display, g_gc, 0, 0, &rect, 1, YXBanded);
|
2000-08-15 12:23:24 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
2002-09-24 09:59:14 +02:00
|
|
|
ui_bell(void)
|
2000-08-15 12:23:24 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XBell(g_display, 0);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
2000-07-07 11:40:03 +02:00
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_destblt(uint8 opcode,
|
|
|
|
/* dest */ int x, int y, int cx, int cy)
|
2000-07-07 11:40:03 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FUNCTION(opcode);
|
2001-09-15 05:16:05 +02:00
|
|
|
FILL_RECTANGLE(x, y, cx, cy);
|
2001-09-14 05:38:39 +02:00
|
|
|
RESET_FUNCTION(opcode);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2003-05-15 16:26:15 +02:00
|
|
|
static uint8 hatch_patterns[] = {
|
2003-06-06 13:10:48 +02:00
|
|
|
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0 - bsHorizontal */
|
|
|
|
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 1 - bsVertical */
|
|
|
|
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, /* 2 - bsFDiagonal */
|
|
|
|
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, /* 3 - bsBDiagonal */
|
|
|
|
0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08, /* 4 - bsCross */
|
|
|
|
0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 /* 5 - bsDiagCross */
|
2003-05-15 16:26:15 +02:00
|
|
|
};
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_patblt(uint8 opcode,
|
|
|
|
/* dest */ int x, int y, int cx, int cy,
|
2002-07-18 18:38:31 +02:00
|
|
|
/* brush */ BRUSH * brush, int bgcolour, int fgcolour)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
|
|
|
Pixmap fill;
|
2002-07-14 06:20:25 +02:00
|
|
|
uint8 i, ipattern[8];
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FUNCTION(opcode);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
|
|
|
switch (brush->style)
|
|
|
|
{
|
2001-01-06 04:12:10 +01:00
|
|
|
case 0: /* Solid */
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FOREGROUND(fgcolour);
|
2004-04-27 01:14:07 +02:00
|
|
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
|
2000-07-25 14:34:29 +02:00
|
|
|
break;
|
|
|
|
|
2003-05-15 16:26:15 +02:00
|
|
|
case 2: /* Hatch */
|
2003-06-06 13:10:48 +02:00
|
|
|
fill = (Pixmap) ui_create_glyph(8, 8,
|
|
|
|
hatch_patterns + brush->pattern[0] * 8);
|
2003-10-13 14:34:15 +02:00
|
|
|
SET_FOREGROUND(fgcolour);
|
|
|
|
SET_BACKGROUND(bgcolour);
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
|
|
|
|
XSetStipple(g_display, g_gc, fill);
|
|
|
|
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
|
2004-04-27 01:14:07 +02:00
|
|
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetFillStyle(g_display, g_gc, FillSolid);
|
|
|
|
XSetTSOrigin(g_display, g_gc, 0, 0);
|
2003-05-15 16:26:15 +02:00
|
|
|
ui_destroy_glyph((HGLYPH) fill);
|
|
|
|
break;
|
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
case 3: /* Pattern */
|
2002-07-14 06:20:25 +02:00
|
|
|
for (i = 0; i != 8; i++)
|
|
|
|
ipattern[7 - i] = brush->pattern[i];
|
|
|
|
fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FOREGROUND(bgcolour);
|
|
|
|
SET_BACKGROUND(fgcolour);
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
|
|
|
|
XSetStipple(g_display, g_gc, fill);
|
|
|
|
XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
|
2004-04-27 01:14:07 +02:00
|
|
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetFillStyle(g_display, g_gc, FillSolid);
|
|
|
|
XSetTSOrigin(g_display, g_gc, 0, 0);
|
2002-07-18 18:38:31 +02:00
|
|
|
ui_destroy_glyph((HGLYPH) fill);
|
2000-07-25 14:34:29 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-09-14 15:51:38 +02:00
|
|
|
unimpl("brush %d\n", brush->style);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
|
|
|
|
RESET_FUNCTION(opcode);
|
2004-04-27 01:14:07 +02:00
|
|
|
|
|
|
|
if (g_ownbackstore)
|
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_screenblt(uint8 opcode,
|
|
|
|
/* dest */ int x, int y, int cx, int cy,
|
|
|
|
/* src */ int srcx, int srcy)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FUNCTION(opcode);
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
2004-02-16 21:28:09 +01:00
|
|
|
{
|
2004-04-30 21:14:15 +02:00
|
|
|
if (g_Unobscured)
|
|
|
|
{
|
|
|
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
|
2004-05-06 10:17:47 +02:00
|
|
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x,
|
|
|
|
y);
|
2004-04-30 21:14:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
|
2004-05-06 10:17:47 +02:00
|
|
|
XCopyArea(g_display, g_backstore, g_backstore, g_gc, srcx, srcy, cx, cy, x,
|
|
|
|
y);
|
2004-04-30 21:14:15 +02:00
|
|
|
}
|
2004-02-16 21:28:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XCopyArea(g_display, g_wnd, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
|
|
|
|
}
|
2001-09-14 05:38:39 +02:00
|
|
|
RESET_FUNCTION(opcode);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_memblt(uint8 opcode,
|
|
|
|
/* dest */ int x, int y, int cx, int cy,
|
|
|
|
/* src */ HBITMAP src, int srcx, int srcy)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FUNCTION(opcode);
|
2003-08-28 00:51:33 +02:00
|
|
|
XCopyArea(g_display, (Pixmap) src, g_wnd, g_gc, srcx, srcy, cx, cy, x, y);
|
|
|
|
if (g_ownbackstore)
|
|
|
|
XCopyArea(g_display, (Pixmap) src, g_backstore, g_gc, srcx, srcy, cx, cy, x, y);
|
2001-09-14 05:38:39 +02:00
|
|
|
RESET_FUNCTION(opcode);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_triblt(uint8 opcode,
|
|
|
|
/* dest */ int x, int y, int cx, int cy,
|
|
|
|
/* src */ HBITMAP src, int srcx, int srcy,
|
2002-07-18 18:38:31 +02:00
|
|
|
/* brush */ BRUSH * brush, int bgcolour, int fgcolour)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
|
|
|
/* This is potentially difficult to do in general. Until someone
|
2000-08-15 12:23:24 +02:00
|
|
|
comes up with a more efficient way of doing it I am using cases. */
|
2000-07-25 14:34:29 +02:00
|
|
|
|
|
|
|
switch (opcode)
|
|
|
|
{
|
2001-01-06 04:12:10 +01:00
|
|
|
case 0x69: /* PDSxxn */
|
2000-09-28 09:04:14 +02:00
|
|
|
ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy);
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, fgcolour);
|
2000-09-28 09:04:14 +02:00
|
|
|
break;
|
|
|
|
|
2001-01-06 04:12:10 +01:00
|
|
|
case 0xb8: /* PSDPxax */
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
|
2000-09-28 09:04:14 +02:00
|
|
|
ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy);
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
|
2000-07-25 14:34:29 +02:00
|
|
|
break;
|
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
case 0xc0: /* PSa */
|
2001-06-20 15:54:48 +02:00
|
|
|
ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);
|
2002-07-30 09:18:48 +02:00
|
|
|
ui_patblt(ROP2_AND, x, y, cx, cy, brush, bgcolour, fgcolour);
|
2001-06-20 15:54:48 +02:00
|
|
|
break;
|
|
|
|
|
2000-07-25 14:34:29 +02:00
|
|
|
default:
|
2001-09-14 15:51:38 +02:00
|
|
|
unimpl("triblt 0x%x\n", opcode);
|
2000-09-28 09:04:14 +02:00
|
|
|
ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_line(uint8 opcode,
|
|
|
|
/* dest */ int startx, int starty, int endx, int endy,
|
2002-07-18 18:38:31 +02:00
|
|
|
/* pen */ PEN * pen)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FUNCTION(opcode);
|
|
|
|
SET_FOREGROUND(pen->colour);
|
2003-08-28 00:51:33 +02:00
|
|
|
XDrawLine(g_display, g_wnd, g_gc, startx, starty, endx, endy);
|
|
|
|
if (g_ownbackstore)
|
|
|
|
XDrawLine(g_display, g_backstore, g_gc, startx, starty, endx, endy);
|
2001-09-14 05:38:39 +02:00
|
|
|
RESET_FUNCTION(opcode);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_rect(
|
|
|
|
/* dest */ int x, int y, int cx, int cy,
|
|
|
|
/* brush */ int colour)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FOREGROUND(colour);
|
2001-09-15 05:16:05 +02:00
|
|
|
FILL_RECTANGLE(x, y, cx, cy);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:23:44 +01:00
|
|
|
/* warning, this function only draws on wnd or backstore, not both */
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_draw_glyph(int mixmode,
|
|
|
|
/* dest */ int x, int y, int cx, int cy,
|
2002-07-18 20:28:12 +02:00
|
|
|
/* src */ HGLYPH glyph, int srcx, int srcy,
|
|
|
|
int bgcolour, int fgcolour)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FOREGROUND(fgcolour);
|
|
|
|
SET_BACKGROUND(bgcolour);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetFillStyle(g_display, g_gc,
|
2002-07-30 09:18:48 +02:00
|
|
|
(mixmode == MIX_TRANSPARENT) ? FillStippled : FillOpaqueStippled);
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetStipple(g_display, g_gc, (Pixmap) glyph);
|
|
|
|
XSetTSOrigin(g_display, g_gc, x, y);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-01-28 13:07:55 +01:00
|
|
|
FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
XSetFillStyle(g_display, g_gc, FillSolid);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2002-04-19 14:06:08 +02:00
|
|
|
#define DO_GLYPH(ttext,idx) \
|
|
|
|
{\
|
|
|
|
glyph = cache_get_font (font, ttext[idx]);\
|
|
|
|
if (!(flags & TEXT2_IMPLICIT_X))\
|
2004-01-17 00:15:33 +01:00
|
|
|
{\
|
|
|
|
xyoffset = ttext[++idx];\
|
|
|
|
if ((xyoffset & 0x80))\
|
2002-04-19 14:06:08 +02:00
|
|
|
{\
|
2004-01-17 00:15:33 +01:00
|
|
|
if (flags & TEXT2_VERTICAL)\
|
|
|
|
y += ttext[idx+1] | (ttext[idx+2] << 8);\
|
2002-04-19 14:06:08 +02:00
|
|
|
else\
|
2004-01-17 00:15:33 +01:00
|
|
|
x += ttext[idx+1] | (ttext[idx+2] << 8);\
|
|
|
|
idx += 2;\
|
2002-04-19 14:06:08 +02:00
|
|
|
}\
|
2004-01-17 00:15:33 +01:00
|
|
|
else\
|
2002-04-19 14:06:08 +02:00
|
|
|
{\
|
2004-01-17 00:15:33 +01:00
|
|
|
if (flags & TEXT2_VERTICAL)\
|
|
|
|
y += xyoffset;\
|
|
|
|
else\
|
|
|
|
x += xyoffset;\
|
2002-04-19 14:06:08 +02:00
|
|
|
}\
|
2004-01-17 00:15:33 +01:00
|
|
|
}\
|
|
|
|
if (glyph != NULL)\
|
|
|
|
{\
|
|
|
|
x1 = x + glyph->offset;\
|
|
|
|
y1 = y + glyph->baseline;\
|
|
|
|
XSetStipple(g_display, g_gc, (Pixmap) glyph->pixmap);\
|
|
|
|
XSetTSOrigin(g_display, g_gc, x1, y1);\
|
|
|
|
FILL_RECTANGLE_BACKSTORE(x1, y1, glyph->width, glyph->height);\
|
|
|
|
if (flags & TEXT2_IMPLICIT_X)\
|
|
|
|
x += glyph->width;\
|
|
|
|
}\
|
2002-04-19 14:06:08 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
|
2002-07-18 20:28:12 +02:00
|
|
|
int clipx, int clipy, int clipcx, int clipcy,
|
|
|
|
int boxx, int boxy, int boxcx, int boxcy, int bgcolour,
|
2002-04-19 14:06:08 +02:00
|
|
|
int fgcolour, uint8 * text, uint8 length)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2000-08-15 12:23:24 +02:00
|
|
|
FONTGLYPH *glyph;
|
2004-01-17 00:15:33 +01:00
|
|
|
int i, j, xyoffset, x1, y1;
|
2002-04-19 14:06:08 +02:00
|
|
|
DATABLOB *entry;
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2001-09-14 05:38:39 +02:00
|
|
|
SET_FOREGROUND(bgcolour);
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2004-03-03 11:46:35 +01:00
|
|
|
/* Sometimes, the boxcx value is something really large, like
|
|
|
|
32691. This makes XCopyArea fail with Xvnc. The code below
|
|
|
|
is a quick fix. */
|
|
|
|
if (boxx + boxcx > g_width)
|
|
|
|
boxcx = g_width - boxx;
|
|
|
|
|
2000-07-25 14:34:29 +02:00
|
|
|
if (boxcx > 1)
|
2001-09-15 05:16:05 +02:00
|
|
|
{
|
2003-01-28 13:07:55 +01:00
|
|
|
FILL_RECTANGLE_BACKSTORE(boxx, boxy, boxcx, boxcy);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
2000-09-28 17:54:11 +02:00
|
|
|
else if (mixmode == MIX_OPAQUE)
|
2001-09-15 05:16:05 +02:00
|
|
|
{
|
2003-01-28 13:07:55 +01:00
|
|
|
FILL_RECTANGLE_BACKSTORE(clipx, clipy, clipcx, clipcy);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2004-01-17 00:15:33 +01:00
|
|
|
SET_FOREGROUND(fgcolour);
|
|
|
|
SET_BACKGROUND(bgcolour);
|
|
|
|
XSetFillStyle(g_display, g_gc, FillStippled);
|
|
|
|
|
2000-07-25 14:34:29 +02:00
|
|
|
/* Paint text, character by character */
|
2002-07-18 18:38:31 +02:00
|
|
|
for (i = 0; i < length;)
|
|
|
|
{
|
|
|
|
switch (text[i])
|
|
|
|
{
|
|
|
|
case 0xff:
|
|
|
|
if (i + 2 < length)
|
2002-07-30 09:18:48 +02:00
|
|
|
cache_put_text(text[i + 1], text, text[i + 2]);
|
2002-07-18 18:38:31 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
error("this shouldn't be happening\n");
|
2002-11-19 11:37:39 +01:00
|
|
|
exit(1);
|
2002-07-18 18:38:31 +02:00
|
|
|
}
|
|
|
|
/* this will move pointer from start to first character after FF command */
|
|
|
|
length -= i + 3;
|
|
|
|
text = &(text[i + 3]);
|
|
|
|
i = 0;
|
2002-04-19 14:06:08 +02:00
|
|
|
break;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2002-07-18 18:38:31 +02:00
|
|
|
case 0xfe:
|
|
|
|
entry = cache_get_text(text[i + 1]);
|
|
|
|
if (entry != NULL)
|
|
|
|
{
|
|
|
|
if ((((uint8 *) (entry->data))[1] ==
|
2002-07-30 09:18:48 +02:00
|
|
|
0) && (!(flags & TEXT2_IMPLICIT_X)))
|
2002-07-18 18:38:31 +02:00
|
|
|
{
|
|
|
|
if (flags & TEXT2_VERTICAL)
|
|
|
|
y += text[i + 2];
|
|
|
|
else
|
|
|
|
x += text[i + 2];
|
|
|
|
}
|
|
|
|
for (j = 0; j < entry->size; j++)
|
2002-07-30 09:18:48 +02:00
|
|
|
DO_GLYPH(((uint8 *) (entry->data)), j);
|
2002-04-10 16:07:56 +02:00
|
|
|
}
|
2002-12-23 19:40:03 +01:00
|
|
|
if (i + 2 < length)
|
|
|
|
i += 3;
|
|
|
|
else
|
|
|
|
i += 2;
|
|
|
|
length -= i;
|
|
|
|
/* this will move pointer from start to first character after FE command */
|
|
|
|
text = &(text[i]);
|
|
|
|
i = 0;
|
2002-07-18 18:38:31 +02:00
|
|
|
break;
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2002-07-18 18:38:31 +02:00
|
|
|
default:
|
|
|
|
DO_GLYPH(text, i);
|
|
|
|
i++;
|
|
|
|
break;
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
}
|
2004-01-17 00:15:33 +01:00
|
|
|
|
|
|
|
XSetFillStyle(g_display, g_gc, FillSolid);
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
2002-11-25 19:23:44 +01:00
|
|
|
{
|
|
|
|
if (boxcx > 1)
|
2003-08-28 00:51:33 +02:00
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, boxx,
|
2002-11-25 19:23:44 +01:00
|
|
|
boxy, boxcx, boxcy, boxx, boxy);
|
|
|
|
else
|
2003-08-28 00:51:33 +02:00
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, clipx,
|
2002-11-25 19:23:44 +01:00
|
|
|
clipy, clipcx, clipcy, clipx, clipy);
|
|
|
|
}
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
2001-06-20 15:54:48 +02:00
|
|
|
Pixmap pix;
|
2000-07-25 14:34:29 +02:00
|
|
|
XImage *image;
|
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
2001-09-15 05:16:05 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
image = XGetImage(g_display, g_backstore, x, y, cx, cy, AllPlanes, ZPixmap);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
pix = XCreatePixmap(g_display, g_wnd, cx, cy, g_depth);
|
|
|
|
XCopyArea(g_display, g_wnd, pix, g_gc, x, y, cx, cy, 0, 0);
|
|
|
|
image = XGetImage(g_display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap);
|
|
|
|
XFreePixmap(g_display, pix);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
2001-06-20 15:54:48 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
offset *= g_bpp / 8;
|
|
|
|
cache_put_desktop(offset, cx, cy, image->bytes_per_line, g_bpp / 8, (uint8 *) image->data);
|
2001-06-20 15:54:48 +02:00
|
|
|
|
|
|
|
XDestroyImage(image);
|
2000-07-25 14:34:29 +02:00
|
|
|
}
|
|
|
|
|
2001-01-06 04:47:04 +01:00
|
|
|
void
|
|
|
|
ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
|
2000-07-25 14:34:29 +02:00
|
|
|
{
|
|
|
|
XImage *image;
|
2000-08-15 12:23:24 +02:00
|
|
|
uint8 *data;
|
2000-07-25 14:34:29 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
offset *= g_bpp / 8;
|
|
|
|
data = cache_get_desktop(offset, cx, cy, g_bpp / 8);
|
2000-08-15 12:23:24 +02:00
|
|
|
if (data == NULL)
|
|
|
|
return;
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
|
|
|
|
(char *) data, cx, cy, BitmapPad(g_display), cx * g_bpp / 8);
|
2001-09-14 05:38:39 +02:00
|
|
|
|
2003-08-28 00:51:33 +02:00
|
|
|
if (g_ownbackstore)
|
2001-09-15 05:16:05 +02:00
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XPutImage(g_display, g_backstore, g_gc, image, 0, 0, x, y, cx, cy);
|
|
|
|
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-28 00:51:33 +02:00
|
|
|
XPutImage(g_display, g_wnd, g_gc, image, 0, 0, x, y, cx, cy);
|
2001-09-15 05:16:05 +02:00
|
|
|
}
|
|
|
|
|
2000-07-25 14:34:29 +02:00
|
|
|
XFree(image);
|
2000-07-07 11:40:03 +02:00
|
|
|
}
|
2004-06-16 05:08:55 +02:00
|
|
|
|
|
|
|
/* these do nothing here but are used in uiports */
|
|
|
|
void
|
|
|
|
ui_begin_update(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ui_end_update(void)
|
|
|
|
{
|
|
|
|
}
|