Rewrite of toggle_fullscreen so it modifies the attributes of the existing
window instead of creating a new one. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@122 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
b8aa6678ed
commit
4eb19aceb1
3
proto.h
3
proto.h
@ -83,8 +83,7 @@ BOOL ui_init(void);
|
|||||||
void ui_create_window_obj(int xpos, int ypos, int width, int height, int valuemask);
|
void ui_create_window_obj(int xpos, int ypos, int width, int height, int valuemask);
|
||||||
BOOL ui_create_window(void);
|
BOOL ui_create_window(void);
|
||||||
void ui_destroy_window(void);
|
void ui_destroy_window(void);
|
||||||
void reset_keys(void);
|
void xwin_toggle_fullscreen(void);
|
||||||
void toggle_fullscreen(void);
|
|
||||||
void ui_select(int rdp_socket);
|
void ui_select(int rdp_socket);
|
||||||
void ui_move_pointer(int x, int y);
|
void ui_move_pointer(int x, int y);
|
||||||
HBITMAP ui_create_bitmap(int width, int height, uint8 * data);
|
HBITMAP ui_create_bitmap(int width, int height, uint8 * data);
|
||||||
|
@ -223,7 +223,7 @@ handle_special_keys(KeySym keysym, uint32 ev_time, BOOL pressed)
|
|||||||
case XK_Break: /* toggle full screen */
|
case XK_Break: /* toggle full screen */
|
||||||
if (pressed && (get_key_state(XK_Alt_L) || get_key_state(XK_Alt_R)))
|
if (pressed && (get_key_state(XK_Alt_L) || get_key_state(XK_Alt_R)))
|
||||||
{
|
{
|
||||||
toggle_fullscreen();
|
xwin_toggle_fullscreen();
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
88
xwin.c
88
xwin.c
@ -42,8 +42,6 @@ static GC gc;
|
|||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
static int depth;
|
static int depth;
|
||||||
static int bpp;
|
static int bpp;
|
||||||
static int dpy_width;
|
|
||||||
static int dpy_height;
|
|
||||||
|
|
||||||
/* endianness */
|
/* endianness */
|
||||||
static BOOL host_be;
|
static BOOL host_be;
|
||||||
@ -280,6 +278,19 @@ get_key_state(int keysym)
|
|||||||
return (current_state & keysymMask) ? True : False;
|
return (current_state & keysymMask) ? True : False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xwin_map_window()
|
||||||
|
{
|
||||||
|
XEvent xevent;
|
||||||
|
|
||||||
|
XMapWindow(display, wnd);
|
||||||
|
|
||||||
|
/* wait for VisibilityChange */
|
||||||
|
XMaskEvent(display, VisibilityChangeMask, &xevent);
|
||||||
|
|
||||||
|
if (fullscreen)
|
||||||
|
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
ui_init()
|
ui_init()
|
||||||
@ -359,6 +370,9 @@ ui_create_window()
|
|||||||
0, CopyFromParent, InputOutput, CopyFromParent,
|
0, CopyFromParent, InputOutput, CopyFromParent,
|
||||||
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs);
|
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs);
|
||||||
|
|
||||||
|
if (ownbackstore)
|
||||||
|
backstore = XCreatePixmap(display, wnd, width, height, depth);
|
||||||
|
|
||||||
XStoreName(display, wnd, title);
|
XStoreName(display, wnd, title);
|
||||||
|
|
||||||
classhints = XAllocClassHint();
|
classhints = XAllocClassHint();
|
||||||
@ -393,27 +407,12 @@ ui_create_window()
|
|||||||
|
|
||||||
XSelectInput(display, wnd, input_mask);
|
XSelectInput(display, wnd, input_mask);
|
||||||
|
|
||||||
|
xwin_map_window();
|
||||||
|
|
||||||
|
/* clear the window so that cached data is not seen */
|
||||||
gc = XCreateGC(display, wnd, 0, NULL);
|
gc = XCreateGC(display, wnd, 0, NULL);
|
||||||
|
|
||||||
XMapWindow(display, wnd);
|
|
||||||
|
|
||||||
/* Wait for VisibilityNotify Event */
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
XNextEvent(display, &xevent);
|
|
||||||
if (xevent.type == VisibilityNotify)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ownbackstore)
|
|
||||||
backstore = XCreatePixmap(display, wnd, width, height, depth);
|
|
||||||
|
|
||||||
/* clear the window so that cached data is not viewed upon start... */
|
|
||||||
XSetBackground(display, gc, 0);
|
|
||||||
XSetForeground(display, gc, 0);
|
XSetForeground(display, gc, 0);
|
||||||
FILL_RECTANGLE(0, 0, width, height);
|
FILL_RECTANGLE(0, 0, width, height);
|
||||||
/* make sure the window is focused */
|
|
||||||
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);
|
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
@ -433,8 +432,8 @@ ui_destroy_window()
|
|||||||
display = NULL;
|
display = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
reset_keys()
|
xwin_reset_keys()
|
||||||
{
|
{
|
||||||
/* reset keys */
|
/* reset keys */
|
||||||
uint32 ev_time;
|
uint32 ev_time;
|
||||||
@ -448,30 +447,21 @@ reset_keys()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggle_fullscreen()
|
xwin_toggle_fullscreen()
|
||||||
{
|
{
|
||||||
/* save window contents */
|
XEvent xevent;
|
||||||
Pixmap pixmap;
|
XSetWindowAttributes attribs;
|
||||||
pixmap = XCreatePixmap(display, wnd, width, height, depth);
|
int newwidth, newheight;
|
||||||
if (ownbackstore)
|
|
||||||
XCopyArea(display, backstore, pixmap, gc, 0, 0, width, height, 0, 0);
|
fullscreen = !fullscreen;
|
||||||
else
|
newwidth = fullscreen ? WidthOfScreen(screen) : width;
|
||||||
XCopyArea(display, wnd, pixmap, gc, 0, 0, width, height, 0, 0);
|
newheight = fullscreen ? HeightOfScreen(screen) : height;
|
||||||
fullscreen = fullscreen ? False : True;
|
|
||||||
close_inputmethod();
|
XUnmapWindow(display, wnd);
|
||||||
if (ownbackstore)
|
attribs.override_redirect = fullscreen;
|
||||||
XFreePixmap(display, backstore);
|
XChangeWindowAttributes(display, wnd, CWOverrideRedirect, &attribs);
|
||||||
XFreeGC(display, gc);
|
XResizeWindow(display, wnd, newwidth, newheight);
|
||||||
XDestroyWindow(display, wnd);
|
xwin_map_window();
|
||||||
ui_create_window();
|
|
||||||
ui_set_cursor(cache_get_cursor(0));
|
|
||||||
ui_move_pointer(width / 2, height / 2);
|
|
||||||
reset_keys();
|
|
||||||
/* restore window contents */
|
|
||||||
if (ownbackstore)
|
|
||||||
XCopyArea(display, pixmap, backstore, gc, 0, 0, width, height, 0, 0);
|
|
||||||
XCopyArea(display, pixmap, wnd, gc, 0, 0, width, height, 0, 0);
|
|
||||||
XFreePixmap(display, pixmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process all events in Xlib queue */
|
/* Process all events in Xlib queue */
|
||||||
@ -479,7 +469,6 @@ static void
|
|||||||
xwin_process_events()
|
xwin_process_events()
|
||||||
{
|
{
|
||||||
XEvent xevent;
|
XEvent xevent;
|
||||||
|
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
uint16 button, flags;
|
uint16 button, flags;
|
||||||
uint32 ev_time;
|
uint32 ev_time;
|
||||||
@ -488,8 +477,10 @@ xwin_process_events()
|
|||||||
char str[256];
|
char str[256];
|
||||||
Status status;
|
Status status;
|
||||||
|
|
||||||
while (XCheckMaskEvent(display, ~0, &xevent))
|
while (XPending(display) > 0)
|
||||||
{
|
{
|
||||||
|
XNextEvent(display, &xevent);
|
||||||
|
|
||||||
if (enable_compose && (XFilterEvent(&xevent, None) == True))
|
if (enable_compose && (XFilterEvent(&xevent, None) == True))
|
||||||
{
|
{
|
||||||
DEBUG_KBD(("Filtering event\n"));
|
DEBUG_KBD(("Filtering event\n"));
|
||||||
@ -586,7 +577,7 @@ xwin_process_events()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
reset_keys();
|
xwin_reset_keys();
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case LeaveNotify:
|
case LeaveNotify:
|
||||||
if (grab_keyboard)
|
if (grab_keyboard)
|
||||||
@ -624,7 +615,6 @@ ui_select(int rdp_socket)
|
|||||||
while (True)
|
while (True)
|
||||||
{
|
{
|
||||||
/* Process any events already waiting */
|
/* Process any events already waiting */
|
||||||
XFlush(display);
|
|
||||||
xwin_process_events();
|
xwin_process_events();
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
|
Loading…
Reference in New Issue
Block a user