/* * X11DRV desktop window handling * * Copyright 2001 Alexandre Julliard * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include "config.h" #include #include #include "x11drv.h" /* avoid conflict with field names in included win32 headers */ #undef Status #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(x11drv); /* data for resolution changing */ static struct x11drv_mode_info *dd_modes; static unsigned int dd_mode_count; static unsigned int max_width; static unsigned int max_height; static struct screen_size { unsigned int width; unsigned int height; } screen_sizes[] = { /* 4:3 */ { 320, 240}, { 400, 300}, { 512, 384}, { 640, 480}, { 768, 576}, { 800, 600}, {1024, 768}, {1152, 864}, {1280, 960}, {1400, 1050}, {1600, 1200}, {2048, 1536}, /* 5:4 */ {1280, 1024}, {2560, 2048}, /* 16:9 */ {1280, 720}, {1366, 768}, {1600, 900}, {1920, 1080}, {2560, 1440}, {3840, 2160}, /* 16:10 */ { 320, 200}, { 640, 400}, {1280, 800}, {1440, 900}, {1680, 1050}, {1920, 1200}, {2560, 1600} }; #define _NET_WM_STATE_REMOVE 0 #define _NET_WM_STATE_ADD 1 /* create the mode structures */ static void make_modes(void) { RECT primary_rect = get_primary_monitor_rect(); unsigned int i; unsigned int screen_width = primary_rect.right - primary_rect.left; unsigned int screen_height = primary_rect.bottom - primary_rect.top; /* original specified desktop size */ X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 60); for (i=0; iold_virtual_rect.left != resize_data->new_virtual_rect.left) mask |= CWX; if (resize_data->old_virtual_rect.top != resize_data->new_virtual_rect.top) mask |= CWY; if (mask && data->whole_window) { POINT pos = virtual_screen_to_root( data->whole_rect.left, data->whole_rect.top ); XWindowChanges changes; changes.x = pos.x; changes.y = pos.y; XReconfigureWMWindow( data->display, data->whole_window, data->vis.screen, mask, &changes ); } release_win_data( data ); if (hwnd == GetForegroundWindow()) clip_fullscreen_window( hwnd, TRUE ); return TRUE; } BOOL is_desktop_fullscreen(void) { RECT primary_rect = get_primary_monitor_rect(); return (primary_rect.right - primary_rect.left == max_width && primary_rect.bottom - primary_rect.top == max_height); } static void update_desktop_fullscreen( unsigned int width, unsigned int height) { Display *display = thread_display(); XEvent xev; if (!display || root_window == DefaultRootWindow( display )) return; xev.xclient.type = ClientMessage; xev.xclient.window = root_window; xev.xclient.message_type = x11drv_atom(_NET_WM_STATE); xev.xclient.serial = 0; xev.xclient.display = display; xev.xclient.send_event = True; xev.xclient.format = 32; if (width == max_width && height == max_height) xev.xclient.data.l[0] = _NET_WM_STATE_ADD; else xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; xev.xclient.data.l[1] = x11drv_atom(_NET_WM_STATE_FULLSCREEN); xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 1; TRACE("action=%li\n", xev.xclient.data.l[0]); XSendEvent( display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev ); xev.xclient.data.l[1] = x11drv_atom(_NET_WM_STATE_MAXIMIZED_VERT); xev.xclient.data.l[2] = x11drv_atom(_NET_WM_STATE_MAXIMIZED_HORZ); XSendEvent( display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev ); } /*********************************************************************** * X11DRV_resize_desktop */ void X11DRV_resize_desktop( unsigned int width, unsigned int height ) { HWND hwnd = GetDesktopWindow(); struct desktop_resize_data resize_data; resize_data.old_virtual_rect = get_virtual_screen_rect(); xinerama_init( width, height ); X11DRV_DisplayDevices_Init( TRUE ); resize_data.new_virtual_rect = get_virtual_screen_rect(); if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId()) { SendMessageW( hwnd, WM_X11DRV_RESIZE_DESKTOP, 0, MAKELPARAM( width, height ) ); } else { TRACE( "desktop %p change to (%dx%d)\n", hwnd, width, height ); update_desktop_fullscreen( width, height ); SetWindowPos( hwnd, 0, resize_data.new_virtual_rect.left, resize_data.new_virtual_rect.top, resize_data.new_virtual_rect.right - resize_data.new_virtual_rect.left, resize_data.new_virtual_rect.bottom - resize_data.new_virtual_rect.top, SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE ); ungrab_clipping_window(); SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_bpp, MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL ); } EnumWindows( update_windows_on_desktop_resize, (LPARAM)&resize_data ); }