From f8e35ebbe71eed74ccf68af8ccda4182f1edc7f0 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 7 Aug 2012 07:51:02 +0200 Subject: mesa xserver xkeyboard-config git update 7 Aug 2012 --- xorg-server/hw/dmx/glxProxy/glxext.c | 1 + xorg-server/hw/kdrive/ephyr/ephyr.c | 80 ++++- xorg-server/hw/kdrive/ephyr/hostx.c | 36 +- xorg-server/hw/kdrive/ephyr/hostx.h | 10 +- xorg-server/hw/kdrive/src/kdrive.c | 20 +- xorg-server/hw/kdrive/src/kinput.c | 2 +- xorg-server/hw/xfree86/dixmods/glxmodule.c | 1 + xorg-server/hw/xfree86/dri2/dri2.c | 8 +- xorg-server/hw/xfree86/loader/loader.c | 13 +- xorg-server/hw/xfree86/modes/xf86Crtc.c | 11 +- xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c | 171 +++++---- xorg-server/hw/xfree86/modes/xf86EdidModes.c | 122 +++---- xorg-server/hw/xfree86/modes/xf86RandR12.c | 38 +- xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c | 26 +- .../hw/xfree86/os-support/bsd/bsd_kqueue_apm.c | 26 +- xorg-server/hw/xfree86/os-support/bus/Sbus.c | 20 +- xorg-server/hw/xfree86/os-support/linux/lnx_apm.c | 31 +- .../hw/xfree86/os-support/solaris/sun_apm.c | 26 +- xorg-server/hw/xquartz/pbproxy/x-selection.m | 2 +- xorg-server/hw/xquartz/pseudoramiX.c | 73 ++-- xorg-server/hw/xquartz/xpr/xprEvent.c | 34 +- xorg-server/hw/xwin/InitOutput.c | 1 + xorg-server/hw/xwin/glx/indirect.c | 70 ++-- xorg-server/hw/xwin/win.h | 9 - xorg-server/hw/xwin/winclipboardwndproc.c | 29 +- xorg-server/hw/xwin/winmultiwindowicons.c | 392 ++++++++++----------- xorg-server/hw/xwin/winmultiwindowicons.h | 42 +++ xorg-server/hw/xwin/winmultiwindowwindow.c | 18 +- xorg-server/hw/xwin/winmultiwindowwm.c | 202 +++++++---- xorg-server/hw/xwin/winprefs.c | 48 ++- xorg-server/hw/xwin/winprefs.h | 2 +- xorg-server/hw/xwin/winwin32rootless.c | 2 +- xorg-server/hw/xwin/winwin32rootlesswindow.c | 31 -- xorg-server/hw/xwin/winwindow.h | 15 +- xorg-server/hw/xwin/winwindowswm.c | 2 - 35 files changed, 891 insertions(+), 723 deletions(-) create mode 100644 xorg-server/hw/xwin/winmultiwindowicons.h (limited to 'xorg-server/hw') diff --git a/xorg-server/hw/dmx/glxProxy/glxext.c b/xorg-server/hw/dmx/glxProxy/glxext.c index 812222195..e72a040ed 100644 --- a/xorg-server/hw/dmx/glxProxy/glxext.c +++ b/xorg-server/hw/dmx/glxProxy/glxext.c @@ -45,6 +45,7 @@ #include "micmap.h" #include "glxswap.h" #include "extinit.h" +#include "glx_extinit.h" /* ** Forward declarations. diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c index a5225dc7d..e6520d035 100644 --- a/xorg-server/hw/kdrive/ephyr/ephyr.c +++ b/xorg-server/hw/kdrive/ephyr/ephyr.c @@ -415,23 +415,22 @@ ephyrRandRGetInfo(ScreenPtr pScreen, Rotation * rotations) struct { int width, height; } sizes[] = { - { - 1600, 1200}, { - 1400, 1050}, { - 1280, 960}, { - 1280, 1024}, { - 1152, 864}, { - 1024, 768}, { - 832, 624}, { - 800, 600}, { - 720, 400}, { - 480, 640}, { - 640, 480}, { - 640, 400}, { - 320, 240}, { - 240, 320}, { - 160, 160}, { - 0, 0} + {1600, 1200}, + {1400, 1050}, + {1280, 960}, + {1280, 1024}, + {1152, 864}, + {1024, 768}, + {832, 624}, + {800, 600}, + {720, 400}, + {480, 640}, + {640, 480}, + {640, 400}, + {320, 240}, + {240, 320}, + {160, 160}, + {0, 0} }; EPHYR_LOG("mark"); @@ -558,6 +557,8 @@ ephyrRandRSetConfig(ScreenPtr pScreen, if (wasEnabled) KdEnableScreen(pScreen); + RRScreenSizeNotify(pScreen); + return TRUE; bail4: @@ -590,6 +591,43 @@ ephyrRandRInit(ScreenPtr pScreen) pScrPriv->rrSetConfig = ephyrRandRSetConfig; return TRUE; } + +static Bool +ephyrResizeScreen (ScreenPtr pScreen, + int newwidth, + int newheight) +{ + KdScreenPriv(pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + RRScreenSize size = {0}; + Bool ret; + int t; + + if (screen->randr & (RR_Rotate_90|RR_Rotate_270)) { + t = newwidth; + newwidth = newheight; + newheight = t; + } + + if (newwidth == screen->width && newheight == screen->height) { + return FALSE; + } + + size.width = newwidth; + size.height = newheight; + + ret = ephyrRandRSetConfig (pScreen, screen->randr, 0, &size); + if (ret) { + RROutputPtr output; + + output = RRFirstOutput(pScreen); + if (!output) + return FALSE; + RROutputSetModes(output, NULL, 0, 0); + } + + return ret; +} #endif Bool @@ -930,6 +968,14 @@ ephyrPoll(void) break; #endif /* XF86DRI */ +#ifdef RANDR + case EPHYR_EV_CONFIGURE: + ephyrResizeScreen(screenInfo.screens[ev.data.configure.screen], + ev.data.configure.width, + ev.data.configure.height); + break; +#endif /* RANDR */ + default: break; } diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c index 6988f1625..02729d6f6 100644 --- a/xorg-server/hw/kdrive/ephyr/hostx.c +++ b/xorg-server/hw/kdrive/ephyr/hostx.c @@ -345,7 +345,11 @@ hostx_init(void) attr.event_mask = ButtonPressMask | ButtonReleaseMask - | PointerMotionMask | KeyPressMask | KeyReleaseMask | ExposureMask; + | PointerMotionMask + | KeyPressMask + | KeyReleaseMask + | ExposureMask + | StructureNotifyMask; EPHYR_DBG("mark"); @@ -693,12 +697,14 @@ hostx_screen_init(EphyrScreenInfo screen, XResizeWindow(HostX.dpy, host_screen->win, width, height); /* Ask the WM to keep our size static */ - size_hints = XAllocSizeHints(); - size_hints->max_width = size_hints->min_width = width; - size_hints->max_height = size_hints->min_height = height; - size_hints->flags = PMinSize | PMaxSize; - XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints); - XFree(size_hints); + if (host_screen->win_pre_existing == None) { + size_hints = XAllocSizeHints(); + size_hints->max_width = size_hints->min_width = width; + size_hints->max_height = size_hints->min_height = height; + size_hints->flags = PMinSize | PMaxSize; + XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints); + XFree(size_hints); + } XMapWindow(HostX.dpy, host_screen->win); @@ -1001,6 +1007,22 @@ hostx_get_event(EphyrHostXEvent * ev) ev->data.key_up.scancode = xev.xkey.keycode; return 1; + case ConfigureNotify: + { + struct EphyrHostScreen *host_screen = + host_screen_from_window(xev.xconfigure.window); + + if (host_screen && host_screen->win_pre_existing != None) { + ev->type = EPHYR_EV_CONFIGURE; + ev->data.configure.width = xev.xconfigure.width; + ev->data.configure.height = xev.xconfigure.height; + ev->data.configure.window = xev.xconfigure.window; + ev->data.configure.screen = host_screen->mynum; + return 1; + } + + return 0; + } default: break; diff --git a/xorg-server/hw/kdrive/ephyr/hostx.h b/xorg-server/hw/kdrive/ephyr/hostx.h index d6217119a..31c4053aa 100644 --- a/xorg-server/hw/kdrive/ephyr/hostx.h +++ b/xorg-server/hw/kdrive/ephyr/hostx.h @@ -47,7 +47,8 @@ typedef enum EphyrHostXEventType { EPHYR_EV_MOUSE_RELEASE, EPHYR_EV_KEY_PRESS, EPHYR_EV_KEY_RELEASE, - EPHYR_EV_EXPOSE + EPHYR_EV_EXPOSE, + EPHYR_EV_CONFIGURE, } EphyrHostXEventType; /* I can't believe it's not a KeySymsRec. */ @@ -89,6 +90,13 @@ struct EphyrHostXEvent { int window; } expose; + struct configure { + int width; + int height; + int screen; + int window; + } configure; + } data; int key_state; diff --git a/xorg-server/hw/kdrive/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c index a3b9434d1..7d9bf9ddd 100644 --- a/xorg-server/hw/kdrive/src/kdrive.c +++ b/xorg-server/hw/kdrive/src/kdrive.c @@ -730,22 +730,22 @@ KdSetSubpixelOrder(ScreenPtr pScreen, Rotation randr) int subpixel_order; Rotation direction; } orders[] = { - { - SubPixelHorizontalRGB, RR_Rotate_0}, { - SubPixelHorizontalBGR, RR_Rotate_180}, { - SubPixelVerticalRGB, RR_Rotate_270}, { - SubPixelVerticalBGR, RR_Rotate_90},}; + {SubPixelHorizontalRGB, RR_Rotate_0}, + {SubPixelHorizontalBGR, RR_Rotate_180}, + {SubPixelVerticalRGB, RR_Rotate_270}, + {SubPixelVerticalBGR, RR_Rotate_90}, + }; static struct { int bit; int normal; int reflect; } reflects[] = { - { - RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR}, { - RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB}, { - RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR}, { - RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB},}; + {RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR}, + {RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB}, + {RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR}, + {RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB}, + }; /* map subpixel to direction */ for (i = 0; i < 4; i++) diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c index b1068bbee..d35dcf848 100644 --- a/xorg-server/hw/kdrive/src/kinput.c +++ b/xorg-server/hw/kdrive/src/kinput.c @@ -1034,7 +1034,7 @@ KdGetOptions(InputOption **options, char *string) if (strchr(string, '=')) { tam_key = (strchr(string, '=') - string); - key = strndup(string, tam_key); + key = strndup(string, tam_key + 1); if (!key) goto out; diff --git a/xorg-server/hw/xfree86/dixmods/glxmodule.c b/xorg-server/hw/xfree86/dixmods/glxmodule.c index 5a9e84529..c0c611401 100644 --- a/xorg-server/hw/xfree86/dixmods/glxmodule.c +++ b/xorg-server/hw/xfree86/dixmods/glxmodule.c @@ -43,6 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "globals.h" #include "glxserver.h" #include "extinit.h" +#include "glx_extinit.h" static MODULESETUPPROTO(glxSetup); diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c index 63feed51a..23f589cdc 100644 --- a/xorg-server/hw/xfree86/dri2/dri2.c +++ b/xorg-server/hw/xfree86/dri2/dri2.c @@ -409,6 +409,11 @@ DRI2DrawableGone(pointer p, XID id) dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL); } + if (pPriv->prime_slave_pixmap) { + (*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap); + (*pPriv->prime_slave_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap); + } + if (pPriv->buffers != NULL) { for (i = 0; i < pPriv->bufferCount; i++) destroy_buffer(pDraw, pPriv->buffers[i], pPriv->prime_id); @@ -811,8 +816,9 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest) if (pPriv->prime_slave_pixmap->master_pixmap == mpix) return &pPriv->prime_slave_pixmap->drawable; else { - (*master->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap); + (*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap); (*slave->DestroyPixmap)(pPriv->prime_slave_pixmap); + pPriv->prime_slave_pixmap = NULL; } } diff --git a/xorg-server/hw/xfree86/loader/loader.c b/xorg-server/hw/xfree86/loader/loader.c index 5fbea38f8..64c69bb8a 100644 --- a/xorg-server/hw/xfree86/loader/loader.c +++ b/xorg-server/hw/xfree86/loader/loader.c @@ -195,13 +195,12 @@ LoaderGetABIVersion(const char *abiclass) const char *name; int version; } classes[] = { - { - ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion}, { - ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion}, { - ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion}, { - ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion}, { - ABI_CLASS_FONT, LoaderVersionInfo.fontVersion}, { - NULL, 0} + {ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion}, + {ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion}, + {ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion}, + {ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion}, + {ABI_CLASS_FONT, LoaderVersionInfo.fontVersion}, + {NULL, 0} }; int i; diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c index 2628409d2..154f684c4 100644 --- a/xorg-server/hw/xfree86/modes/xf86Crtc.c +++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c @@ -734,9 +734,6 @@ xf86CrtcCloseScreen(ScreenPtr screen) for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; - if (crtc->randr_crtc->scanout_pixmap) - RRCrtcDetachScanoutPixmap(crtc->randr_crtc); - crtc->randr_crtc = NULL; } /* detach any providers */ @@ -2073,12 +2070,13 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, /* * If there's no preferred mode, but only one monitor, pick the - * biggest mode for its aspect ratio, assuming one exists. + * biggest mode for its aspect ratio or 4:3, assuming one exists. */ if (!ret) do { int i = 0; float aspect = 0.0; + DisplayModePtr a = NULL, b = NULL; /* count the number of enabled outputs */ for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++); @@ -2092,8 +2090,11 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config, aspect = (float) config->output[p]->mm_width / (float) config->output[p]->mm_height; + a = bestModeForAspect(config, enabled, 4.0/3.0); if (aspect) - preferred_match[p] = bestModeForAspect(config, enabled, aspect); + b = bestModeForAspect(config, enabled, aspect); + + preferred_match[p] = biggestMode(a, b); if (preferred_match[p]) ret = TRUE; diff --git a/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c b/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c index 781c806bc..bead1265a 100644 --- a/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c +++ b/xorg-server/hw/xfree86/modes/xf86DisplayIDModes.c @@ -184,105 +184,96 @@ static const struct did_dmt { short w, h, r, f; } did_dmt[] = { /* byte 3 */ - { - 640, 350, 85, 0}, { - 640, 400, 85, 0}, { - 720, 400, 85, 0}, { - 640, 480, 60, 0}, { - 640, 480, 72, 0}, { - 640, 480, 75, 0}, { - 640, 480, 85, 0}, { - 800, 600, 56, 0}, + {640, 350, 85, 0}, + {640, 400, 85, 0}, + {720, 400, 85, 0}, + {640, 480, 60, 0}, + {640, 480, 72, 0}, + {640, 480, 75, 0}, + {640, 480, 85, 0}, + {800, 600, 56, 0}, /* byte 4 */ - { - 800, 600, 60, 0}, { - 800, 600, 72, 0}, { - 800, 600, 75, 0}, { - 800, 600, 85, 0}, { - 800, 600, 120, RB}, { - 848, 480, 60, 0}, { - 1024, 768, 43, INT}, { - 1024, 768, 60, 0}, + {800, 600, 60, 0}, + {800, 600, 72, 0}, + {800, 600, 75, 0}, + {800, 600, 85, 0}, + {800, 600, 120, RB}, + {848, 480, 60, 0}, + {1024, 768, 43, INT}, + {1024, 768, 60, 0}, /* byte 5 */ - { - 1024, 768, 70, 0}, { - 1024, 768, 75, 0}, { - 1024, 768, 85, 0}, { - 1024, 768, 120, RB}, { - 1152, 864, 75, 0}, { - 1280, 768, 60, RB}, { - 1280, 768, 60, 0}, { - 1280, 768, 75, 0}, + {1024, 768, 70, 0}, + {1024, 768, 75, 0}, + {1024, 768, 85, 0}, + {1024, 768, 120, RB}, + {1152, 864, 75, 0}, + {1280, 768, 60, RB}, + {1280, 768, 60, 0}, + {1280, 768, 75, 0}, /* byte 6 */ - { - 1280, 768, 85, 0}, { - 1280, 768, 120, RB}, { - 1280, 800, 60, RB}, { - 1280, 800, 60, 0}, { - 1280, 800, 75, 0}, { - 1280, 800, 85, 0}, { - 1280, 800, 120, RB}, { - 1280, 960, 60, 0}, + {1280, 768, 85, 0}, + {1280, 768, 120, RB}, + {1280, 800, 60, RB}, + {1280, 800, 60, 0}, + {1280, 800, 75, 0}, + {1280, 800, 85, 0}, + {1280, 800, 120, RB}, + {1280, 960, 60, 0}, /* byte 7 */ - { - 1280, 960, 85, 0}, { - 1280, 960, 120, RB}, { - 1280, 1024, 60, 0}, { - 1280, 1024, 75, 0}, { - 1280, 1024, 85, 0}, { - 1280, 1024, 120, RB}, { - 1360, 768, 60, 0}, { - 1360, 768, 120, RB}, + {1280, 960, 85, 0}, + {1280, 960, 120, RB}, + {1280, 1024, 60, 0}, + {1280, 1024, 75, 0}, + {1280, 1024, 85, 0}, + {1280, 1024, 120, RB}, + {1360, 768, 60, 0}, + {1360, 768, 120, RB}, /* byte 8 */ - { - 1400, 1050, 60, RB}, { - 1400, 1050, 60, 0}, { - 1400, 1050, 75, 0}, { - 1400, 1050, 85, 0}, { - 1400, 1050, 120, RB}, { - 1440, 900, 60, RB}, { - 1440, 900, 60, 0}, { - 1440, 900, 75, 0}, + {1400, 1050, 60, RB}, + {1400, 1050, 60, 0}, + {1400, 1050, 75, 0}, + {1400, 1050, 85, 0}, + {1400, 1050, 120, RB}, + {1440, 900, 60, RB}, + {1440, 900, 60, 0}, + {1440, 900, 75, 0}, /* byte 9 */ - { - 1440, 900, 85, 0}, { - 1440, 900, 120, RB}, { - 1600, 1200, 60, 0}, { - 1600, 1200, 65, 0}, { - 1600, 1200, 70, 0}, { - 1600, 1200, 75, 0}, { - 1600, 1200, 85, 0}, { - 1600, 1200, 120, RB}, + {1440, 900, 85, 0}, + {1440, 900, 120, RB}, + {1600, 1200, 60, 0}, + {1600, 1200, 65, 0}, + {1600, 1200, 70, 0}, + {1600, 1200, 75, 0}, + {1600, 1200, 85, 0}, + {1600, 1200, 120, RB}, /* byte a */ - { - 1680, 1050, 60, RB}, { - 1680, 1050, 60, 0}, { - 1680, 1050, 75, 0}, { - 1680, 1050, 85, 0}, { - 1680, 1050, 120, RB}, { - 1792, 1344, 60, 0}, { - 1792, 1344, 75, 0}, { - 1792, 1344, 120, RB}, + {1680, 1050, 60, RB}, + {1680, 1050, 60, 0}, + {1680, 1050, 75, 0}, + {1680, 1050, 85, 0}, + {1680, 1050, 120, RB}, + {1792, 1344, 60, 0}, + {1792, 1344, 75, 0}, + {1792, 1344, 120, RB}, /* byte b */ - { - 1856, 1392, 60, 0}, { - 1856, 1392, 75, 0}, { - 1856, 1392, 120, RB}, { - 1920, 1200, 60, RB}, { - 1920, 1200, 60, 0}, { - 1920, 1200, 75, 0}, { - 1920, 1200, 85, 0}, { - 1920, 1200, 120, RB}, + {1856, 1392, 60, 0}, + {1856, 1392, 75, 0}, + {1856, 1392, 120, RB}, + {1920, 1200, 60, RB}, + {1920, 1200, 60, 0}, + {1920, 1200, 75, 0}, + {1920, 1200, 85, 0}, + {1920, 1200, 120, RB}, /* byte c */ - { - 1920, 1440, 60, 0}, { - 1920, 1440, 75, 0}, { - 1920, 1440, 120, RB}, { - 2560, 1600, 60, RB}, { - 2560, 1600, 60, 0}, { - 2560, 1600, 75, 0}, { - 2560, 1600, 85, 0}, { -2560, 1600, 120, RB},}; + {1920, 1440, 60, 0}, + {1920, 1440, 75, 0}, + {1920, 1440, 120, RB}, + {2560, 1600, 60, RB}, + {2560, 1600, 60, 0}, + {2560, 1600, 75, 0}, + {2560, 1600, 85, 0}, + {2560, 1600, 120, RB}, +}; static void didVesaTiming(int scrn, unsigned char *x, MonPtr mon) diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c index 258ada5b4..4ee862da0 100644 --- a/xorg-server/hw/xfree86/modes/xf86EdidModes.c +++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c @@ -513,14 +513,14 @@ DDCModeDoInterlaceQuirks(DisplayModePtr mode) static const struct { int w, h; } cea_interlaced[] = { - { - 1920, 1080}, { - 720, 480}, { - 1440, 480}, { - 2880, 480}, { - 720, 576}, { - 1440, 576}, { - 2880, 576},}; + {1920, 1080}, + {720, 480}, + {1440, 480}, + {2880, 480}, + {720, 576}, + {1440, 576}, + {2880, 576}, + }; static const int n_modes = sizeof(cea_interlaced) / sizeof(cea_interlaced[0]); int i; @@ -668,68 +668,62 @@ static const struct { short r; short rb; } EstIIIModes[] = { - /* byte 6 */ - { - 640, 350, 85, 0}, { - 640, 400, 85, 0}, { - 720, 400, 85, 0}, { - 640, 480, 85, 0}, { - 848, 480, 60, 0}, { - 800, 600, 85, 0}, { - 1024, 768, 85, 0}, { - 1152, 864, 75, 0}, + /* byte 6 */ + {640, 350, 85, 0}, + {640, 400, 85, 0}, + {720, 400, 85, 0}, + {640, 480, 85, 0}, + {848, 480, 60, 0}, + {800, 600, 85, 0}, + {1024, 768, 85, 0}, + {1152, 864, 75, 0}, /* byte 7 */ - { - 1280, 768, 60, 1}, { - 1280, 768, 60, 0}, { - 1280, 768, 75, 0}, { - 1280, 768, 85, 0}, { - 1280, 960, 60, 0}, { - 1280, 960, 85, 0}, { - 1280, 1024, 60, 0}, { - 1280, 1024, 85, 0}, + {1280, 768, 60, 1}, + {1280, 768, 60, 0}, + {1280, 768, 75, 0}, + {1280, 768, 85, 0}, + {1280, 960, 60, 0}, + {1280, 960, 85, 0}, + {1280, 1024, 60, 0}, + {1280, 1024, 85, 0}, /* byte 8 */ - { - 1360, 768, 60, 0}, { - 1440, 900, 60, 1}, { - 1440, 900, 60, 0}, { - 1440, 900, 75, 0}, { - 1440, 900, 85, 0}, { - 1400, 1050, 60, 1}, { - 1400, 1050, 60, 0}, { - 1400, 1050, 75, 0}, + {1360, 768, 60, 0}, + {1440, 900, 60, 1}, + {1440, 900, 60, 0}, + {1440, 900, 75, 0}, + {1440, 900, 85, 0}, + {1400, 1050, 60, 1}, + {1400, 1050, 60, 0}, + {1400, 1050, 75, 0}, /* byte 9 */ - { - 1400, 1050, 85, 0}, { - 1680, 1050, 60, 1}, { - 1680, 1050, 60, 0}, { - 1680, 1050, 75, 0}, { - 1680, 1050, 85, 0}, { - 1600, 1200, 60, 0}, { - 1600, 1200, 65, 0}, { - 1600, 1200, 70, 0}, + {1400, 1050, 85, 0}, + {1680, 1050, 60, 1}, + {1680, 1050, 60, 0}, + {1680, 1050, 75, 0}, + {1680, 1050, 85, 0}, + {1600, 1200, 60, 0}, + {1600, 1200, 65, 0}, + {1600, 1200, 70, 0}, /* byte 10 */ - { - 1600, 1200, 75, 0}, { - 1600, 1200, 85, 0}, { - 1792, 1344, 60, 0}, { - 1792, 1344, 85, 0}, { - 1856, 1392, 60, 0}, { - 1856, 1392, 75, 0}, { - 1920, 1200, 60, 1}, { - 1920, 1200, 60, 0}, + {1600, 1200, 75, 0}, + {1600, 1200, 85, 0}, + {1792, 1344, 60, 0}, + {1792, 1344, 85, 0}, + {1856, 1392, 60, 0}, + {1856, 1392, 75, 0}, + {1920, 1200, 60, 1}, + {1920, 1200, 60, 0}, /* byte 11 */ - { - 1920, 1200, 75, 0}, { - 1920, 1200, 85, 0}, { - 1920, 1440, 60, 0}, { - 1920, 1440, 75, 0}, + {1920, 1200, 75, 0}, + {1920, 1200, 85, 0}, + {1920, 1440, 60, 0}, + {1920, 1440, 75, 0}, /* fill up last byte */ - { - 0,0,0,0}, { - 0,0,0,0}, { - 0,0,0,0}, { - 0,0,0,0}, }; + {0,0,0,0}, + {0,0,0,0}, + {0,0,0,0}, + {0,0,0,0}, +}; static DisplayModePtr DDCModesFromEstIII(unsigned char *est) diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c index 4be0ea32f..3530abf24 100644 --- a/xorg-server/hw/xfree86/modes/xf86RandR12.c +++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c @@ -60,6 +60,9 @@ typedef struct _xf86RandR12Info { * See https://bugs.freedesktop.org/show_bug.cgi?id=21554 */ xf86EnterVTProc *orig_EnterVT; + + Bool panning; + ConstrainCursorHarderProcPtr orig_ConstrainCursorHarder; } XF86RandRInfoRec, *XF86RandRInfoPtr; #ifdef RANDR_12_INTERFACE @@ -665,6 +668,10 @@ xf86RandR12SetConfig(ScreenPtr pScreen, return TRUE; } +#define PANNING_ENABLED(crtc) \ + ((crtc)->panningTotalArea.x2 > (crtc)->panningTotalArea.x1 || \ + (crtc)->panningTotalArea.y2 > (crtc)->panningTotalArea.y1) + static Bool xf86RandR12ScreenSetSize(ScreenPtr pScreen, CARD16 width, @@ -676,6 +683,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen, WindowPtr pRoot = pScreen->root; PixmapPtr pScrnPix; Bool ret = FALSE; + Bool panning = FALSE; int c; if (xf86RandR12Key) { @@ -696,8 +704,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen, for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; - if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 || - crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) { + if (PANNING_ENABLED (crtc)) { if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1) crtc->panningTotalArea.x2 += width - pScreen->width; if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1) @@ -708,6 +715,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen, crtc->panningTrackingArea.y2 += height - pScreen->height; xf86RandR13VerifyPanningArea(crtc, width, height); xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY); + panning = TRUE; } } @@ -903,6 +911,7 @@ xf86RandR12CloseScreen(ScreenPtr pScreen) randrp = XF86RANDRINFO(pScreen); #if RANDR_12_INTERFACE xf86ScreenToScrn(pScreen)->EnterVT = randrp->orig_EnterVT; + pScreen->ConstrainCursorHarder = randrp->orig_ConstrainCursorHarder; #endif free(randrp); @@ -1216,6 +1225,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen, } xf86RandR13VerifyPanningArea(crtc, pScreen->width, pScreen->height); xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY); + randrp->panning = PANNING_ENABLED (crtc); /* * Save the last successful setting for EnterVT */ @@ -1650,6 +1660,7 @@ xf86RandR13SetPanning(ScreenPtr pScreen, BoxRec oldTotalArea; BoxRec oldTrackingArea; INT16 oldBorder[4]; + Bool oldPanning = randrp->panning; if (crtc->version < 2) return FALSE; @@ -1667,6 +1678,7 @@ xf86RandR13SetPanning(ScreenPtr pScreen, if (xf86RandR13VerifyPanningArea(crtc, pScreen->width, pScreen->height)) { xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY); + randrp->panning = PANNING_ENABLED (crtc); return TRUE; } else { @@ -1674,6 +1686,7 @@ xf86RandR13SetPanning(ScreenPtr pScreen, memcpy(&crtc->panningTotalArea, &oldTotalArea, sizeof(BoxRec)); memcpy(&crtc->panningTrackingArea, &oldTrackingArea, sizeof(BoxRec)); memcpy(crtc->panningBorder, oldBorder, 4 * sizeof(INT16)); + randrp->panning = oldPanning; return FALSE; } } @@ -1762,8 +1775,6 @@ xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen, RRProviderPtr provider, RRProviderPtr source_provider) { - - if (!source_provider) { if (provider->output_source) { ScreenPtr cmScreen = pScreen->current_master; @@ -1859,6 +1870,21 @@ xf86CrtcSetScanoutPixmap(RRCrtcPtr randr_crtc, PixmapPtr pixmap) return crtc->funcs->set_scanout_pixmap(crtc, pixmap); } +static void +xf86RandR13ConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, int *x, int *y) +{ + XF86RandRInfoPtr randrp = XF86RANDRINFO(screen); + + if (randrp->panning) + return; + + if (randrp->orig_ConstrainCursorHarder) { + screen->ConstrainCursorHarder = randrp->orig_ConstrainCursorHarder; + screen->ConstrainCursorHarder(dev, screen, mode, x, y); + screen->ConstrainCursorHarder = xf86RandR13ConstrainCursorHarder; + } +} + static Bool xf86RandR12Init12(ScreenPtr pScreen) { @@ -1895,6 +1921,10 @@ xf86RandR12Init12(ScreenPtr pScreen) randrp->orig_EnterVT = pScrn->EnterVT; pScrn->EnterVT = xf86RandR12EnterVT; + randrp->panning = FALSE; + randrp->orig_ConstrainCursorHarder = pScreen->ConstrainCursorHarder; + pScreen->ConstrainCursorHarder = xf86RandR13ConstrainCursorHarder; + if (!xf86RandR12CreateObjects12(pScreen)) return FALSE; diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c index a8a4164e0..b1938cf0d 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c @@ -21,21 +21,19 @@ static struct { u_int apmBsd; pmEvent xf86; } bsdToXF86Array[] = { - { - APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, { - APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, { - APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, { - APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, { - APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, { - APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, { - APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, { - APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, { - APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, { - APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, { - APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, + {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, + {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, + {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, + {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, + {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, + {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, + {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, + {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, + {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, + {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, + {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, #ifdef APM_CAPABILITY_CHANGE - { - APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, + {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, #endif }; diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c index 10251f38e..22943855b 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c @@ -54,21 +54,19 @@ static struct { u_int apmBsd; pmEvent xf86; } bsdToXF86Array[] = { - { - APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, { - APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, { - APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, { - APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, { - APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, { - APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, { - APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, { - APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, { - APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, { - APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, { - APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, + {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, + {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, + {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, + {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, + {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, + {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, + {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, + {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, + {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, + {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, + {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, #ifdef APM_CAPABILITY_CHANGE - { - APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, + {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, #endif }; diff --git a/xorg-server/hw/xfree86/os-support/bus/Sbus.c b/xorg-server/hw/xfree86/os-support/bus/Sbus.c index b75308aa1..826000712 100644 --- a/xorg-server/hw/xfree86/os-support/bus/Sbus.c +++ b/xorg-server/hw/xfree86/os-support/bus/Sbus.c @@ -403,16 +403,16 @@ sparcPromAssignNodes(void) int devId; char *prefix; } procFbPrefixes[] = { - { - SBUS_DEVICE_BW2, "BWtwo"}, { - SBUS_DEVICE_CG14, "CGfourteen"}, { - SBUS_DEVICE_CG6, "CGsix"}, { - SBUS_DEVICE_CG3, "CGthree"}, { - SBUS_DEVICE_FFB, "Creator"}, { - SBUS_DEVICE_FFB, "Elite 3D"}, { - SBUS_DEVICE_LEO, "Leo"}, { - SBUS_DEVICE_TCX, "TCX"}, { - 0, NULL},}; + {SBUS_DEVICE_BW2, "BWtwo"}, + {SBUS_DEVICE_CG14, "CGfourteen"}, + {SBUS_DEVICE_CG6, "CGsix"}, + {SBUS_DEVICE_CG3, "CGthree"}, + {SBUS_DEVICE_FFB, "Creator"}, + {SBUS_DEVICE_FFB, "Elite 3D"}, + {SBUS_DEVICE_LEO, "Leo"}, + {SBUS_DEVICE_TCX, "TCX"}, + {0, NULL}, + }; while (fscanf(f, "%d %63s\n", &fbNum, buffer) == 2) { for (i = 0; procFbPrefixes[i].devId; i++) diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c b/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c index a37331e52..387934099 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_apm.c @@ -42,26 +42,23 @@ static struct { apm_event_t apmLinux; pmEvent xf86; } LinuxToXF86[] = { - { - APM_SYS_STANDBY, XF86_APM_SYS_STANDBY}, { - APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND}, { - APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, { - APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME}, { - APM_LOW_BATTERY, XF86_APM_LOW_BATTERY}, { - APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, { - APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, { - APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND}, { - APM_USER_STANDBY, XF86_APM_USER_STANDBY}, { - APM_USER_SUSPEND, XF86_APM_USER_SUSPEND}, { - APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, + {APM_SYS_STANDBY, XF86_APM_SYS_STANDBY}, + {APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND}, + {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, + {APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME}, + {APM_LOW_BATTERY, XF86_APM_LOW_BATTERY}, + {APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, + {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, + {APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND}, + {APM_USER_STANDBY, XF86_APM_USER_STANDBY}, + {APM_USER_SUSPEND, XF86_APM_USER_SUSPEND}, + {APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, #if defined(APM_CAPABILITY_CHANGED) - { - APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED}, + {APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED}, #endif #if 0 - { - APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED}, { - APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED} + {APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED}, + {APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED} #endif }; diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c index 4ff64649a..b6a1432f6 100644 --- a/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_apm.c @@ -97,21 +97,19 @@ static struct { u_int apmBsd; pmEvent xf86; } sunToXF86Array[] = { - { - APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, { - APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, { - APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, { - APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, { - APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, { - APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, { - APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, { - APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, { - APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, { - APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, { - APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, + {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, + {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, + {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, + {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, + {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, + {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, + {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, + {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, + {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, + {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, + {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, #ifdef APM_CAPABILITY_CHANGE - { - APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, + {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, #endif }; diff --git a/xorg-server/hw/xquartz/pbproxy/x-selection.m b/xorg-server/hw/xquartz/pbproxy/x-selection.m index 13d5e13ad..57ddb743a 100644 --- a/xorg-server/hw/xquartz/pbproxy/x-selection.m +++ b/xorg-server/hw/xquartz/pbproxy/x-selection.m @@ -1499,7 +1499,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, /* Allocation */ -- init +- (id) init { unsigned long pixel; diff --git a/xorg-server/hw/xquartz/pseudoramiX.c b/xorg-server/hw/xquartz/pseudoramiX.c index c650dd723..23dbc7328 100644 --- a/xorg-server/hw/xquartz/pseudoramiX.c +++ b/xorg-server/hw/xquartz/pseudoramiX.c @@ -37,7 +37,6 @@ #include #endif -#include "darwin.h" #include "pseudoramiX.h" #include "extnsionst.h" #include "extinit.h" @@ -46,6 +45,9 @@ #include #include "globals.h" +#define TRACE PseudoramiXTrace("TRACE " __FILE__ ":%s",__FUNCTION__) +#define DEBUG_LOG PseudoramiXDebug + Bool noPseudoramiXExtension = FALSE; extern int @@ -96,6 +98,26 @@ static int pseudoramiXScreensAllocated = 0; static int pseudoramiXNumScreens = 0; static unsigned long pseudoramiXGeneration = 0; +static void +PseudoramiXTrace(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVMessageVerb(X_NONE, 10, format, ap); + va_end(ap); +} + +static void +PseudoramiXDebug(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + LogVMessageVerb(X_NONE, 3, format, ap); + va_end(ap); +} + // Add a PseudoramiX screen. // The rest of the X server will know nothing about this screen. // Can be called before or after extension init. @@ -133,7 +155,7 @@ PseudoramiXExtensionInit(void) if (noPseudoramiXExtension) return; - TRACE(); + TRACE; /* Even with only one screen we need to enable PseudoramiX to allow dynamic screen configuration changes. */ @@ -170,7 +192,7 @@ PseudoramiXExtensionInit(void) void PseudoramiXResetScreens(void) { - TRACE(); + TRACE; pseudoramiXNumScreens = 0; } @@ -178,7 +200,7 @@ PseudoramiXResetScreens(void) static void PseudoramiXResetProc(ExtensionEntry *extEntry) { - TRACE(); + TRACE; PseudoramiXResetScreens(); } @@ -187,7 +209,7 @@ PseudoramiXResetProc(ExtensionEntry *extEntry) static int ProcPseudoramiXQueryVersion(ClientPtr client) { - TRACE(); + TRACE; return ProcPanoramiXQueryVersion(client); } @@ -201,7 +223,7 @@ ProcPseudoramiXGetState(ClientPtr client) xPanoramiXGetStateReply rep; register int rc; - TRACE(); + TRACE; REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -212,10 +234,11 @@ ProcPseudoramiXGetState(ClientPtr client) rep.length = 0; rep.sequenceNumber = client->sequence; rep.state = !noPseudoramiXExtension; + rep.window = stuff->window; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); - swaps(&rep.state); + swapl(&rep.window); } WriteToClient(client, sizeof(xPanoramiXGetStateReply),&rep); return Success; @@ -230,7 +253,7 @@ ProcPseudoramiXGetScreenCount(ClientPtr client) xPanoramiXGetScreenCountReply rep; register int rc; - TRACE(); + TRACE; REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -241,10 +264,11 @@ ProcPseudoramiXGetScreenCount(ClientPtr client) rep.length = 0; rep.sequenceNumber = client->sequence; rep.ScreenCount = pseudoramiXNumScreens; + rep.window = stuff->window; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); - swaps(&rep.ScreenCount); + swapl(&rep.window); } WriteToClient(client, sizeof(xPanoramiXGetScreenCountReply),&rep); return Success; @@ -259,7 +283,10 @@ ProcPseudoramiXGetScreenSize(ClientPtr client) xPanoramiXGetScreenSizeReply rep; register int rc; - TRACE(); + TRACE; + + if (stuff->screen >= pseudoramiXNumScreens) + return BadMatch; REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); @@ -274,11 +301,15 @@ ProcPseudoramiXGetScreenSize(ClientPtr client) // was screenInfo.screens[stuff->screen]->width; rep.height = pseudoramiXScreens[stuff->screen].h; // was screenInfo.screens[stuff->screen]->height; + rep.window = stuff->window; + rep.screen = stuff->screen; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); - swaps(&rep.width); - swaps(&rep.height); + swapl(&rep.width); + swapl(&rep.height); + swapl(&rep.window); + swapl(&rep.screen); } WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply),&rep); return Success; @@ -291,7 +322,7 @@ ProcPseudoramiXIsActive(ClientPtr client) /* REQUEST(xXineramaIsActiveReq); */ xXineramaIsActiveReply rep; - TRACE(); + TRACE; REQUEST_SIZE_MATCH(xXineramaIsActiveReq); @@ -360,7 +391,7 @@ static int ProcPseudoramiXDispatch(ClientPtr client) { REQUEST(xReq); - TRACE(); + TRACE; switch (stuff->data) { case X_PanoramiXQueryVersion: return ProcPseudoramiXQueryVersion(client); @@ -388,7 +419,7 @@ SProcPseudoramiXQueryVersion(ClientPtr client) { REQUEST(xPanoramiXQueryVersionReq); - TRACE(); + TRACE; swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); @@ -400,7 +431,7 @@ SProcPseudoramiXGetState(ClientPtr client) { REQUEST(xPanoramiXGetStateReq); - TRACE(); + TRACE; swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetStateReq); @@ -412,7 +443,7 @@ SProcPseudoramiXGetScreenCount(ClientPtr client) { REQUEST(xPanoramiXGetScreenCountReq); - TRACE(); + TRACE; swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); @@ -424,7 +455,7 @@ SProcPseudoramiXGetScreenSize(ClientPtr client) { REQUEST(xPanoramiXGetScreenSizeReq); - TRACE(); + TRACE; swaps(&stuff->length); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); @@ -436,7 +467,7 @@ SProcPseudoramiXIsActive(ClientPtr client) { REQUEST(xXineramaIsActiveReq); - TRACE(); + TRACE; swaps(&stuff->length); REQUEST_SIZE_MATCH(xXineramaIsActiveReq); @@ -448,7 +479,7 @@ SProcPseudoramiXQueryScreens(ClientPtr client) { REQUEST(xXineramaQueryScreensReq); - TRACE(); + TRACE; swaps(&stuff->length); REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); @@ -460,7 +491,7 @@ SProcPseudoramiXDispatch(ClientPtr client) { REQUEST(xReq); - TRACE(); + TRACE; switch (stuff->data) { case X_PanoramiXQueryVersion: diff --git a/xorg-server/hw/xquartz/xpr/xprEvent.c b/xorg-server/hw/xquartz/xpr/xprEvent.c index 73bcc930d..398177ca8 100644 --- a/xorg-server/hw/xquartz/xpr/xprEvent.c +++ b/xorg-server/hw/xquartz/xpr/xprEvent.c @@ -59,13 +59,6 @@ #include "rootlessWindow.h" #include "xprEvent.h" -/* This is important enough to declare here if building against an old - * libXplugin, so we pick it up whenever libXplugin starts to support it. - */ -#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION < 6 -extern xp_error xp_window_bring_all_to_front(void) __attribute__((weak_import)); -#endif - Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) { @@ -86,21 +79,18 @@ QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) /* There's no need to do xp_window_bring_all_to_front on Leopard, * and we don't care about the result, so just do it async. */ -#if defined(HAVE_LIBDISPATCH) -#if (defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED >= 6) || \ - (!defined(XPLUGIN_VERSION_MIN_REQUIRED) && defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6) - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - xp_window_bring_all_to_front(); - }); -#else - if (&xp_window_bring_all_to_front) { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - xp_window_bring_all_to_front(); - }); - } else { - RootlessOrderAllWindows(e->data[0]); - } -#endif +#if defined(HAVE_LIBDISPATCH) && defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 6 +# if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6 + if (&xp_window_bring_all_to_front) { +# endif + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + xp_window_bring_all_to_front(); + }); +# if defined(XPLUGIN_VERSION_MIN_REQUIRED) && XPLUGIN_VERSION_MIN_REQUIRED < 6 + } else { + RootlessOrderAllWindows(e->data[0]); + } +# endif #else RootlessOrderAllWindows(e->data[0]); #endif diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c index 538b2e101..37cd8b357 100644 --- a/xorg-server/hw/xwin/InitOutput.c +++ b/xorg-server/hw/xwin/InitOutput.c @@ -55,6 +55,7 @@ typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner, DWORD dwFlags, LPTSTR pszPath); #endif +#include "glx_extinit.h" /* * References to external symbols */ diff --git a/xorg-server/hw/xwin/glx/indirect.c b/xorg-server/hw/xwin/glx/indirect.c index 3f34146e5..97b6045b7 100644 --- a/xorg-server/hw/xwin/glx/indirect.c +++ b/xorg-server/hw/xwin/glx/indirect.c @@ -1625,6 +1625,18 @@ glxWinCreateContext(__GLXscreen * screen, * Utility functions */ +static int +GetShift(int Mask) +{ + int Shift = 0; + + while ((Mask &1) == 0) { + Shift++; + Mask >>=1; + } + return Shift; +} + static int fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret, int drawableTypeOverride) @@ -1661,16 +1673,26 @@ fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret, pfd.dwFlags |= PFD_DOUBLEBUFFER; } - pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = mode->redBits + mode->greenBits + mode->blueBits; pfd.cRedBits = mode->redBits; - pfd.cRedShift = 0; /* FIXME */ + pfd.cRedShift = GetShift(mode->redMask); pfd.cGreenBits = mode->greenBits; - pfd.cGreenShift = 0; /* FIXME */ + pfd.cGreenShift = GetShift(mode->greenMask); pfd.cBlueBits = mode->blueBits; - pfd.cBlueShift = 0; /* FIXME */ + pfd.cBlueShift = GetShift(mode->blueMask); pfd.cAlphaBits = mode->alphaBits; - pfd.cAlphaShift = 0; /* FIXME */ + pfd.cAlphaShift = GetShift(mode->alphaMask); + + if (mode->visualType == GLX_TRUE_COLOR) { + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.dwVisibleMask = + (pfd.cRedBits << pfd.cRedShift) | (pfd.cGreenBits << pfd.cGreenShift) | + (pfd.cBlueBits << pfd.cBlueShift) | (pfd.cAlphaBits << pfd.cAlphaShift); + } + else { + pfd.iPixelType = PFD_TYPE_COLORINDEX; + pfd.dwVisibleMask = mode->transparentIndex; + } pfd.cAccumBits = mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits + @@ -1910,25 +1932,27 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen) /* EXT_visual_info / GLX 1.2 */ if (pfd.iPixelType == PFD_TYPE_COLORINDEX) { c->base.visualType = GLX_STATIC_COLOR; - - if (!getenv("GLWIN_ENABLE_COLORINDEX_FBCONFIGS")) { - GLWIN_DEBUG_MSG - ("pixelFormat %d is PFD_TYPE_COLORINDEX, skipping", i + 1); - continue; - } + c->base.transparentRed = GLX_NONE; + c->base.transparentGreen = GLX_NONE; + c->base.transparentBlue = GLX_NONE; + c->base.transparentAlpha = GLX_NONE; + c->base.transparentIndex = pfd.dwVisibleMask; + c->base.transparentPixel = GLX_TRANSPARENT_INDEX; } else { c->base.visualType = GLX_TRUE_COLOR; + c->base.transparentRed = + (pfd.dwVisibleMask & c->base.redMask) >> pfd.cRedShift; + c->base.transparentGreen = + (pfd.dwVisibleMask & c->base.greenMask) >> pfd.cGreenShift; + c->base.transparentBlue = + (pfd.dwVisibleMask & c->base.blueMask) >> pfd.cBlueShift; + c->base.transparentAlpha = + (pfd.dwVisibleMask & c->base.alphaMask) >> pfd.cAlphaShift; + c->base.transparentIndex = GLX_NONE; + c->base.transparentPixel = GLX_TRANSPARENT_RGB; } - // pfd.dwVisibleMask; ??? - c->base.transparentPixel = GLX_NONE; - c->base.transparentRed = GLX_NONE; - c->base.transparentGreen = GLX_NONE; - c->base.transparentBlue = GLX_NONE; - c->base.transparentAlpha = GLX_NONE; - c->base.transparentIndex = GLX_NONE; - /* ARB_multisample / SGIS_multisample */ c->base.sampleBuffers = 0; c->base.samples = 0; @@ -2180,14 +2204,6 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen) c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); c->base.rgbBits = 0; c->base.visualType = GLX_STATIC_COLOR; - - if (!getenv("GLWIN_ENABLE_COLORINDEX_FBCONFIGS")) { - GLWIN_DEBUG_MSG - ("pixelFormat %d is WGL_TYPE_COLORINDEX_ARB, skipping", - i + 1); - continue; - } - break; case WGL_TYPE_RGBA_FLOAT_ARB: diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h index 38d6bde18..89e2a38c9 100644 --- a/xorg-server/hw/xwin/win.h +++ b/xorg-server/hw/xwin/win.h @@ -1174,15 +1174,6 @@ Bool void winSetShapeRootless(WindowPtr pWindow, int kind); -/* - * winmultiwindowicons.c - Used by both multi-window and Win32Rootless - */ - -HICON winXIconToHICON(WindowPtr pWin, int iconSize); - -void - winSelectIcons(WindowPtr pWin, HICON * pIcon, HICON * pSmallIcon); - #ifdef XWIN_MULTIWINDOW /* * winmultiwindowshape.c diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c index cbe6599f4..e19f678a7 100644 --- a/xorg-server/hw/xwin/winclipboardwndproc.c +++ b/xorg-server/hw/xwin/winclipboardwndproc.c @@ -74,10 +74,10 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay, int iConnNumber; struct timeval tv; int iReturn; - DWORD dwStopTime = (GetTickCount() / 1000) + iTimeoutSec; + DWORD dwStopTime = GetTickCount() + iTimeoutSec * 1000; - /* We need to ensure that all pending events are processed */ - XSync(pDisplay, FALSE); + winDebug("winProcessXEventsTimeout () - pumping X events for %d seconds\n", + iTimeoutSec); /* Get our connection number */ iConnNumber = ConnectionNumber(pDisplay); @@ -85,17 +85,24 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay, /* Loop for X events */ while (1) { fd_set fdsRead; + long remainingTime; + + /* We need to ensure that all pending events are processed */ + XSync(pDisplay, FALSE); /* Setup the file descriptor set */ FD_ZERO(&fdsRead); FD_SET(iConnNumber, &fdsRead); /* Adjust timeout */ - tv.tv_sec = dwStopTime - (GetTickCount() / 1000); - tv.tv_usec = 0; + remainingTime = dwStopTime - GetTickCount(); + tv.tv_sec = remainingTime / 1000; + tv.tv_usec = (remainingTime % 1000) * 1000; + winDebug("winProcessXEventsTimeout () - %d milliseconds left\n", + remainingTime); /* Break out if no time left */ - if (tv.tv_sec < 0) + if (remainingTime <= 0) return WIN_XEVENTS_SUCCESS; /* Wait for an X event */ @@ -103,7 +110,7 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay, &fdsRead, /* Read mask */ NULL, /* No write mask */ NULL, /* No exception mask */ - &tv); /* No timeout */ + &tv); /* Timeout */ if (iReturn < 0) { ErrorF("winProcessXEventsTimeout - Call to select () failed: %d. " "Bailing.\n", iReturn); @@ -116,11 +123,19 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay, /* Exit when we see that server is shutting down */ iReturn = winClipboardFlushXEvents(hwnd, iWindow, pDisplay, fUseUnicode); + + winDebug + ("winProcessXEventsTimeout () - winClipboardFlushXEvents returned %d\n", + iReturn); + if (WIN_XEVENTS_NOTIFY == iReturn) { /* Bail out if notify processed */ return iReturn; } } + else { + winDebug("winProcessXEventsTimeout - Spurious wake\n"); + } } return WIN_XEVENTS_SUCCESS; diff --git a/xorg-server/hw/xwin/winmultiwindowicons.c b/xorg-server/hw/xwin/winmultiwindowicons.c index df59f6066..b8357e72d 100644 --- a/xorg-server/hw/xwin/winmultiwindowicons.c +++ b/xorg-server/hw/xwin/winmultiwindowicons.c @@ -31,75 +31,65 @@ #ifdef HAVE_XWIN_CONFIG_H #include #endif -#include "win.h" -#include "dixevents.h" -#include "winmultiwindowclass.h" -#include "winprefs.h" -#include "propertyst.h" -#include "windowstr.h" +#ifndef WINVER +#define WINVER 0x0500 +#endif + +#include +#include +#include +#include "winresource.h" +#include "winprefs.h" +#include "winmsg.h" +#include "winmultiwindowicons.h" +#include "winglobals.h" /* - * Prototypes for local functions + * global variables */ - -static void - -winScaleXBitmapToWindows(int iconSize, int effBPP, - PixmapPtr pixmap, unsigned char *image); +extern HINSTANCE g_hInstance; /* - * Scale an X icon bitmap into a Windoze icon bitmap + * Scale an X icon ZPixmap into a Windoze icon bitmap */ static void -winScaleXBitmapToWindows(int iconSize, - int effBPP, PixmapPtr pixmap, unsigned char *image) +winScaleXImageToWindowsIcon(int iconSize, + int effBPP, + int stride, XImage * pixmap, unsigned char *image) { int row, column, effXBPP, effXDepth; unsigned char *outPtr; - char *iconData = 0; - int stride, xStride; + unsigned char *iconData = 0; + int xStride; float factX, factY; int posX, posY; unsigned char *ptr; unsigned int zero; unsigned int color; - effXBPP = BitsPerPixel(pixmap->drawable.depth); - effXDepth = pixmap->drawable.depth; - - if (pixmap->drawable.bitsPerPixel == 15) + effXBPP = pixmap->bits_per_pixel; + if (pixmap->bits_per_pixel == 15) effXBPP = 16; - if (pixmap->drawable.depth == 15) + effXDepth = pixmap->depth; + if (pixmap->depth == 15) effXDepth = 16; - /* Need 16-bit aligned rows for DDBitmaps */ - stride = ((iconSize * effBPP + 15) & (~15)) / 8; - xStride = PixmapBytePad(pixmap->drawable.width, pixmap->drawable.depth); + xStride = pixmap->bytes_per_line; if (stride == 0 || xStride == 0) { ErrorF("winScaleXBitmapToWindows - stride or xStride is zero. " "Bailing.\n"); return; } - /* Allocate memory for icon data */ - iconData = malloc(xStride * pixmap->drawable.height); - if (!iconData) { - ErrorF("winScaleXBitmapToWindows - malloc failed for iconData. " - "Bailing.\n"); - return; - } - /* Get icon data */ - miGetImage((DrawablePtr) &(pixmap->drawable), 0, 0, - pixmap->drawable.width, pixmap->drawable.height, - ZPixmap, 0xffffffff, iconData); + iconData = (unsigned char *) pixmap->data; /* Keep aspect ratio */ - factX = ((float) pixmap->drawable.width) / ((float) iconSize); - factY = ((float) pixmap->drawable.height) / ((float) iconSize); + factX = ((float) pixmap->width) / ((float) iconSize); + factY = ((float) pixmap->height) / ((float) iconSize); if (factX > factY) factY = factX; else @@ -119,8 +109,7 @@ winScaleXBitmapToWindows(int iconSize, ptr += posX / 8; /* Out of X icon bounds, leave space blank */ - if (posX >= pixmap->drawable.width - || posY >= pixmap->drawable.height) + if (posX >= pixmap->width || posY >= pixmap->height) ptr = (unsigned char *) &zero; if ((*ptr) & (1 << (posX & 7))) @@ -162,8 +151,7 @@ winScaleXBitmapToWindows(int iconSize, ptr += posX * (effXBPP / 8); /* Out of X icon bounds, leave space blank */ - if (posX >= pixmap->drawable.width - || posY >= pixmap->drawable.height) + if (posX >= pixmap->width || posY >= pixmap->height) ptr = (unsigned char *) &zero; color = (((*ptr) << 16) + ((*(ptr + 1)) << 8) @@ -203,8 +191,7 @@ winScaleXBitmapToWindows(int iconSize, ptr += posX * (effXBPP / 8); /* Out of X icon bounds, leave space blank */ - if (posX >= pixmap->drawable.width - || posY >= pixmap->drawable.height) + if (posX >= pixmap->width || posY >= pixmap->height) ptr = (unsigned char *) &zero; color = ((*ptr) << 8) + (*(ptr + 1)); switch (effBPP) { @@ -238,7 +225,6 @@ winScaleXBitmapToWindows(int iconSize, } /* end if effxbpp==16) */ } /* end for column */ } /* end for row */ - free(iconData); } static HICON @@ -250,7 +236,7 @@ NetWMToWinIconAlpha(uint32_t * icon) HICON result; HDC hdc = GetDC(NULL); uint32_t *DIB_pixels; - ICONINFO ii = { TRUE }; + ICONINFO ii; BITMAPV4HEADER bmh = { sizeof(bmh) }; /* Define an ARGB pixel format used for Color+Alpha icons */ @@ -264,6 +250,9 @@ NetWMToWinIconAlpha(uint32_t * icon) bmh.bV4GreenMask = 0x0000FF00; bmh.bV4BlueMask = 0x000000FF; + ii.fIcon = TRUE; + ii.xHotspot = 0; /* ignored */ + ii.yHotspot = 0; /* ignored */ ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO *) & bmh, DIB_RGB_COLORS, (void **) &DIB_pixels, NULL, 0); @@ -291,12 +280,15 @@ NetWMToWinIconThreshold(uint32_t * icon) uint32_t *pixels = &icon[2]; int row, col; HICON result; - ICONINFO ii = { TRUE }; + ICONINFO ii; HDC hdc = GetDC(NULL); HDC xorDC = CreateCompatibleDC(hdc); HDC andDC = CreateCompatibleDC(hdc); + ii.fIcon = TRUE; + ii.xHotspot = 0; /* ignored */ + ii.yHotspot = 0; /* ignored */ ii.hbmColor = CreateCompatibleBitmap(hdc, width, height); ii.hbmMask = CreateCompatibleBitmap(hdc, width, height); ReleaseDC(NULL, hdc); @@ -365,202 +357,220 @@ NetWMToWinIcon(int bpp, uint32_t * icon) return NetWMToWinIconThreshold(icon); } -static pointer -GetWindowProp(WindowPtr pWin, Atom name, long int *size_return) -{ - struct _Window *pwin; - struct _Property *prop; - - if (!pWin || !name) { - ErrorF("GetWindowProp - pWin or name was NULL\n"); - return 0; - } - pwin = (struct _Window *) pWin; - if (!pwin->optional) - return NULL; - for (prop = (struct _Property *) pwin->optional->userProps; - prop; prop = prop->next) { - if (prop->propertyName == name) { - *size_return = prop->size; - return prop->data; - } - } - return NULL; -} - /* * Attempt to create a custom icon from the WM_HINTS bitmaps */ -HICON -winXIconToHICON(WindowPtr pWin, int iconSize) +static + HICON +winXIconToHICON(Display * pDisplay, Window id, int iconSize) { - unsigned char *mask, *image, *imageMask; + unsigned char *mask, *image = NULL, *imageMask; unsigned char *dst, *src; - PixmapPtr iconPtr; - PixmapPtr maskPtr; - int planes, bpp, effBPP, stride, maskStride, i; + int planes, bpp, i; int biggest_size = 0; HDC hDC; ICONINFO ii; - WinXWMHints hints; + XWMHints *hints; HICON hIcon = NULL; uint32_t *biggest_icon = NULL; - /* Try to get _NET_WM_ICON icons first */ static Atom _XA_NET_WM_ICON; static int generation; uint32_t *icon, *icon_data = NULL; - long int size = 0; + unsigned long int size; + unsigned long int type; + int format; + unsigned long int left; hDC = GetDC(GetDesktopWindow()); planes = GetDeviceCaps(hDC, PLANES); bpp = GetDeviceCaps(hDC, BITSPIXEL); ReleaseDC(GetDesktopWindow(), hDC); + /* Always prefer _NET_WM_ICON icons */ if (generation != serverGeneration) { generation = serverGeneration; - _XA_NET_WM_ICON = MakeAtom("_NET_WM_ICON", 12, TRUE); + _XA_NET_WM_ICON = XInternAtom(pDisplay, "_NET_WM_ICON", FALSE); } - if (_XA_NET_WM_ICON) - icon_data = GetWindowProp(pWin, _XA_NET_WM_ICON, &size); - if (icon_data) { - for (icon = icon_data; - icon < &icon_data[size] && *icon; + if ((XGetWindowProperty(pDisplay, id, _XA_NET_WM_ICON, + 0, MAXINT, FALSE, + AnyPropertyType, &type, &format, &size, &left, + (unsigned char **) &icon_data) == Success) && + (icon_data != NULL)) { + for (icon = icon_data; icon < &icon_data[size] && *icon; icon = &icon[icon[0] * icon[1] + 2]) { - if (icon[0] == iconSize && icon[1] == iconSize) - return NetWMToWinIcon(bpp, icon); - /* Find the biggest icon and let Windows scale the size */ + /* Find an exact match to the size we require... */ + if (icon[0] == iconSize && icon[1] == iconSize) { + winDebug("winXIconToHICON: found %lu x %lu NetIcon\n", icon[0], + icon[1]); + hIcon = NetWMToWinIcon(bpp, icon); + break; + } + /* Otherwise, find the biggest icon and let Windows scale the size */ else if (biggest_size < icon[0]) { biggest_icon = icon; biggest_size = icon[0]; } } - if (biggest_icon) - return NetWMToWinIcon(bpp, biggest_icon); - } - winDebug("winXIconToHICON - pWin %x: no suitable NetIcon\n", (int) pWin, - iconSize); - winMultiWindowGetWMHints(pWin, &hints); - if (!hints.icon_pixmap) - return NULL; + if (!hIcon && biggest_icon) { + winDebug + ("winXIconToHICON: selected %lu x %lu NetIcon for scaling to %u x %u\n", + biggest_icon[0], biggest_icon[1], iconSize, iconSize); + + hIcon = NetWMToWinIcon(bpp, biggest_icon); + } - dixLookupResourceByType((pointer) &iconPtr, hints.icon_pixmap, RT_PIXMAP, - NullClient, DixUnknownAccess); + XFree(icon_data); + } - if (!iconPtr) - return NULL; + if (!hIcon) { + winDebug("winXIconToHICON: no suitable NetIcon\n"); + + hints = XGetWMHints(pDisplay, id); + if (hints) { + winDebug("winXIconToHICON: id 0x%x icon_pixmap hint %x\n", id, + hints->icon_pixmap); + + if (hints->icon_pixmap) { + Window root; + int x, y; + unsigned int width, height, border_width, depth; + XImage *xImageIcon; + XImage *xImageMask = NULL; + + XGetGeometry(pDisplay, hints->icon_pixmap, &root, &x, &y, + &width, &height, &border_width, &depth); + + xImageIcon = + XGetImage(pDisplay, hints->icon_pixmap, 0, 0, width, height, + 0xFFFFFFFF, ZPixmap); + winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%x\n", id, + xImageIcon); + + if (hints->icon_mask) + xImageMask = + XGetImage(pDisplay, hints->icon_mask, 0, 0, width, + height, 0xFFFFFFFF, ZPixmap); + + if (xImageIcon) { + int effBPP, stride, maskStride; + + /* 15 BPP is really 16BPP as far as we care */ + if (bpp == 15) + effBPP = 16; + else + effBPP = bpp; - /* 15 BPP is really 16BPP as far as we care */ - if (bpp == 15) - effBPP = 16; - else - effBPP = bpp; + /* Need 16-bit aligned rows for DDBitmaps */ + stride = ((iconSize * effBPP + 15) & (~15)) / 8; - /* Need 16-bit aligned rows for DDBitmaps */ - stride = ((iconSize * effBPP + 15) & (~15)) / 8; + /* Mask is 1-bit deep */ + maskStride = ((iconSize * 1 + 15) & (~15)) / 8; - /* Mask is 1-bit deep */ - maskStride = ((iconSize * 1 + 15) & (~15)) / 8; + image = malloc(stride * iconSize); + imageMask = malloc(stride * iconSize); + mask = malloc(maskStride * iconSize); - image = malloc(stride * iconSize); - imageMask = malloc(stride * iconSize); - /* Default to a completely black mask */ - mask = calloc(maskStride, iconSize); + /* Default to a completely black mask */ + memset(imageMask, 0, stride * iconSize); + memset(mask, 0, maskStride * iconSize); - winScaleXBitmapToWindows(iconSize, effBPP, iconPtr, image); - dixLookupResourceByType((pointer) &maskPtr, hints.icon_mask, RT_PIXMAP, - NullClient, DixUnknownAccess); + winScaleXImageToWindowsIcon(iconSize, effBPP, stride, + xImageIcon, image); - if (maskPtr) { - winScaleXBitmapToWindows(iconSize, 1, maskPtr, mask); + if (xImageMask) { + winScaleXImageToWindowsIcon(iconSize, 1, maskStride, + xImageMask, mask); + winScaleXImageToWindowsIcon(iconSize, effBPP, stride, + xImageMask, imageMask); + } - winScaleXBitmapToWindows(iconSize, effBPP, maskPtr, imageMask); + /* Now we need to set all bits of the icon which are not masked */ + /* on to 0 because Color is really an XOR, not an OR function */ + dst = image; + src = imageMask; - /* Now we need to set all bits of the icon which are not masked */ - /* on to 0 because Color is really an XOR, not an OR function */ - dst = image; - src = imageMask; + for (i = 0; i < (stride * iconSize); i++) + if ((*(src++))) + *(dst++) = 0; + else + dst++; - for (i = 0; i < (stride * iconSize); i++) - if ((*(src++))) - *(dst++) = 0; - else - dst++; - } + ii.fIcon = TRUE; + ii.xHotspot = 0; /* ignored */ + ii.yHotspot = 0; /* ignored */ - ii.fIcon = TRUE; - ii.xHotspot = 0; /* ignored */ - ii.yHotspot = 0; /* ignored */ + /* Create Win32 mask from pixmap shape */ + ii.hbmMask = + CreateBitmap(iconSize, iconSize, planes, 1, mask); - /* Create Win32 mask from pixmap shape */ - ii.hbmMask = CreateBitmap(iconSize, iconSize, planes, 1, mask); + /* Create Win32 bitmap from pixmap */ + ii.hbmColor = + CreateBitmap(iconSize, iconSize, planes, bpp, image); - /* Create Win32 bitmap from pixmap */ - ii.hbmColor = CreateBitmap(iconSize, iconSize, planes, bpp, image); + /* Merge Win32 mask and bitmap into icon */ + hIcon = CreateIconIndirect(&ii); - /* Merge Win32 mask and bitmap into icon */ - hIcon = CreateIconIndirect(&ii); + /* Release Win32 mask and bitmap */ + DeleteObject(ii.hbmMask); + DeleteObject(ii.hbmColor); - /* Release Win32 mask and bitmap */ - DeleteObject(ii.hbmMask); - DeleteObject(ii.hbmColor); + /* Free X mask and bitmap */ + free(mask); + free(image); + free(imageMask); - /* Free X mask and bitmap */ - free(mask); - free(image); - free(imageMask); + if (xImageMask) + XDestroyImage(xImageMask); + XDestroyImage(xImageIcon); + } + } + XFree(hints); + } + } return hIcon; } /* - * Change the Windows window icon + * Change the Windows window icon */ #ifdef XWIN_MULTIWINDOW void -winUpdateIcon(Window id) +winUpdateIcon(HWND hWnd, Display * pDisplay, Window id, HICON hIconNew) { - WindowPtr pWin; HICON hIcon, hIconSmall = NULL, hIconOld; - dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, - DixUnknownAccess); - if (pWin) { - winWindowPriv(pWin); - if (pWinPriv->hWnd) { - hIcon = winOverrideIcon((unsigned long) pWin); - if (!hIcon) { - hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON)); - if (!hIcon) { - hIcon = g_hIconX; - hIconSmall = g_hSmallIconX; - } - else { - /* Leave undefined if not found */ - hIconSmall = - winXIconToHICON(pWin, GetSystemMetrics(SM_CXSMICON)); - } - } + /* Start with the icon from preferences, if any */ + hIcon = hIconNew; + hIconSmall = hIconNew; - /* Set the large icon */ - hIconOld = (HICON) SendMessage(pWinPriv->hWnd, - WM_SETICON, ICON_BIG, - (LPARAM) hIcon); + /* If we still need an icon, try and get the icon from WM_HINTS */ + if (!hIcon) + hIcon = winXIconToHICON(pDisplay, id, GetSystemMetrics(SM_CXICON)); + if (!hIconSmall) + hIconSmall = + winXIconToHICON(pDisplay, id, GetSystemMetrics(SM_CXSMICON)); - /* Delete the icon if its not the default */ - winDestroyIcon(hIconOld); - - /* Same for the small icon */ - hIconOld = (HICON) SendMessage(pWinPriv->hWnd, - WM_SETICON, ICON_SMALL, - (LPARAM) hIconSmall); - winDestroyIcon(hIconOld); - } + /* If we got the small, but not the large one swap them */ + if (!hIcon && hIconSmall) { + hIcon = hIconSmall; + hIconSmall = NULL; } + + /* Set the large icon */ + hIconOld = (HICON) SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon); + /* Delete the old icon if its not the default */ + winDestroyIcon(hIconOld); + + /* Same for the small icon */ + hIconOld = + (HICON) SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall); + winDestroyIcon(hIconOld); } void @@ -591,37 +601,21 @@ winInitGlobalIcons(void) } void -winSelectIcons(WindowPtr pWin, HICON * pIcon, HICON * pSmallIcon) +winSelectIcons(HICON * pIcon, HICON * pSmallIcon) { HICON hIcon, hSmallIcon; winInitGlobalIcons(); - /* Try and get the icon from WM_HINTS */ - hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON)); - hSmallIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXSMICON)); - - /* If we got the small, but not the large one swap them */ - if (!hIcon && hSmallIcon) { - hIcon = hSmallIcon; - hSmallIcon = NULL; - } - - /* Use default X icon if no icon loaded from WM_HINTS */ - if (!hIcon) { - hIcon = g_hIconX; - hSmallIcon = g_hSmallIconX; - } + /* Use default X icon */ + hIcon = g_hIconX; + hSmallIcon = g_hSmallIconX; if (pIcon) *pIcon = hIcon; - else - winDestroyIcon(hIcon); if (pSmallIcon) *pSmallIcon = hSmallIcon; - else - winDestroyIcon(hSmallIcon); } void diff --git a/xorg-server/hw/xwin/winmultiwindowicons.h b/xorg-server/hw/xwin/winmultiwindowicons.h new file mode 100644 index 000000000..bf7f6eda7 --- /dev/null +++ b/xorg-server/hw/xwin/winmultiwindowicons.h @@ -0,0 +1,42 @@ +/* + * File: winmultiwindowicons.h + * Purpose: interface for multiwindow mode icon functions + * + * Copyright (c) Jon TURNEY 2012 + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef WINMULTIWINDOWICONS_H +#define WINMULTIWINDOWICONS_H + +void + winUpdateIcon(HWND hWnd, Display * pDisplay, Window id, HICON hIconNew); + +void + winInitGlobalIcons(void); + +void + winDestroyIcon(HICON hIcon); + +void + winSelectIcons(HICON * pIcon, HICON * pSmallIcon); + +#endif /* WINMULTIWINDOWICONS_H */ diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c index 0093fcbb1..c0c7db2b7 100644 --- a/xorg-server/hw/xwin/winmultiwindowwindow.c +++ b/xorg-server/hw/xwin/winmultiwindowwindow.c @@ -63,6 +63,11 @@ winInitMultiWindowClass(void) WNDCLASSEX wcx; if (atomXWinClass == 0) { + HICON hIcon, hIconSmall; + + /* Load the default icons */ + winSelectIcons(&hIcon, &hIconSmall); + /* Setup our window class */ wcx.cbSize = sizeof(WNDCLASSEX); wcx.style = CS_HREDRAW | CS_VREDRAW | (g_fNativeGl ? CS_OWNDC : 0); @@ -70,12 +75,12 @@ winInitMultiWindowClass(void) wcx.cbClsExtra = 0; wcx.cbWndExtra = 0; wcx.hInstance = g_hInstance; - wcx.hIcon = g_hIconX; + wcx.hIcon = hIcon; wcx.hCursor = 0; wcx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wcx.lpszMenuName = NULL; wcx.lpszClassName = WINDOW_CLASS_X; - wcx.hIconSm = g_hSmallIconX; + wcx.hIconSm = hIconSmall; #if CYGMULTIWINDOW_DEBUG ErrorF("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X); @@ -479,8 +484,6 @@ winCreateWindowsWindow(WindowPtr pWin) HWND hFore = NULL; winWindowPriv(pWin); - HICON hIcon; - HICON hIconSmall; winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv; WinXSizeHints hints; WindowPtr pDaddy; @@ -574,13 +577,6 @@ winCreateWindowsWindow(WindowPtr pWin) } pWinPriv->hWnd = hWnd; - /* Set application or .XWinrc defined Icons */ - winSelectIcons(pWin, &hIcon, &hIconSmall); - if (hIcon) - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon); - if (hIconSmall) - SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall); - /* Change style back to popup, already placed... */ SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c index 76b46837c..ffb7c2d0f 100644 --- a/xorg-server/hw/xwin/winmultiwindowwm.c +++ b/xorg-server/hw/xwin/winmultiwindowwm.c @@ -151,7 +151,7 @@ static Bool InitQueue(WMMsgQueuePtr pQueue); static void - GetWindowName(Display * pDpy, Window iWin, wchar_t ** ppName); + GetWindowName(Display * pDpy, Window iWin, char **ppWindowName); static int SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData); @@ -399,38 +399,19 @@ InitQueue(WMMsgQueuePtr pQueue) return TRUE; } -/* - * GetWindowName - Retrieve the title of an X Window - */ - -static void -GetWindowName(Display * pDisplay, Window iWin, wchar_t ** ppName) +static +char * +Xutf8TextPropertyToString(Display * pDisplay, XTextProperty * xtp) { - int nResult, nNum; + int nNum; char **ppList; char *pszReturnData; - int iLen, i; - XTextProperty xtpName; - -#if CYGMULTIWINDOW_DEBUG - ErrorF("GetWindowName\n"); -#endif - /* Intialize ppName to NULL */ - *ppName = NULL; + if (Xutf8TextPropertyToTextList(pDisplay, xtp, &ppList, &nNum) >= Success && + nNum > 0 && *ppList) { + int i; + int iLen = 0; - /* Try to get --- */ - nResult = XGetWMName(pDisplay, iWin, &xtpName); - if (!nResult || !xtpName.value || !xtpName.nitems) { -#if CYGMULTIWINDOW_DEBUG - ErrorF("GetWindowName - XGetWMName failed. No name.\n"); -#endif - return; - } - - if (Xutf8TextPropertyToTextList(pDisplay, &xtpName, &ppList, &nNum) >= - Success && nNum > 0 && *ppList) { - iLen = 0; for (i = 0; i < nNum; i++) iLen += strlen(ppList[i]); pszReturnData = (char *) malloc(iLen + 1); @@ -444,15 +425,40 @@ GetWindowName(Display * pDisplay, Window iWin, wchar_t ** ppName) pszReturnData = (char *) malloc(1); pszReturnData[0] = '\0'; } - iLen = MultiByteToWideChar(CP_UTF8, 0, pszReturnData, -1, NULL, 0); - *ppName = (wchar_t *) malloc(sizeof(wchar_t) * (iLen + 1)); - MultiByteToWideChar(CP_UTF8, 0, pszReturnData, -1, *ppName, iLen); - XFree(xtpName.value); - free(pszReturnData); + + return pszReturnData; +} + +/* + * GetWindowName - Retrieve the title of an X Window + */ + +static void +GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName) +{ + int nResult; + XTextProperty xtpWindowName; + char *pszWindowName; #if CYGMULTIWINDOW_DEBUG - ErrorF("GetWindowName - Returning\n"); + ErrorF("GetWindowName\n"); #endif + + /* Intialize ppWindowName to NULL */ + *ppWindowName = NULL; + + /* Try to get window name */ + nResult = XGetWMName(pDisplay, iWin, &xtpWindowName); + if (!nResult || !xtpWindowName.value || !xtpWindowName.nitems) { +#if CYGMULTIWINDOW_DEBUG + ErrorF("GetWindowName - XGetWMName failed. No name.\n"); +#endif + return; + } + + pszWindowName = Xutf8TextPropertyToString(pDisplay, &xtpWindowName); + XFree(xtpWindowName.value); + *ppWindowName = pszWindowName; } /* @@ -528,18 +534,70 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow) if (!hWnd) return; - /* Set the Windows window name */ - GetWindowName(pWMInfo->pDisplay, iWindow, &pszName); - if (pszName) { - /* Get the window attributes */ - XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr); - if (!attr.override_redirect) { - SetWindowTextW(hWnd, pszName); - winUpdateIcon(iWindow); + /* If window isn't override-redirect */ + XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr); + if (!attr.override_redirect) { + char *pszWindowName; + + /* Get the X windows window name */ + GetWindowName(pWMInfo->pDisplay, iWindow, &pszWindowName); + + if (pszWindowName) { + /* Convert from UTF-8 to wide char */ + int iLen = + MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0); + wchar_t *pwszWideWindowName = + (wchar_t *) malloc(sizeof(wchar_t) * (iLen + 1)); + MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, + pwszWideWindowName, iLen); + + /* Set the Windows window name */ + SetWindowTextW(hWnd, pwszWideWindowName); + + free(pwszWideWindowName); + free(pszWindowName); } + } +} + +/* + * Updates the icon of a HWND according to its X icon properties + */ + +static void +UpdateIcon(WMInfoPtr pWMInfo, Window iWindow) +{ + HWND hWnd; + HICON hIconNew = NULL; + XWindowAttributes attr; + + hWnd = getHwnd(pWMInfo, iWindow); + if (!hWnd) + return; + + /* If window isn't override-redirect */ + XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr); + if (!attr.override_redirect) { + XClassHint class_hint = { 0, 0 }; + char *window_name = 0; + + if (XGetClassHint(pWMInfo->pDisplay, iWindow, &class_hint)) { + XFetchName(pWMInfo->pDisplay, iWindow, &window_name); + + hIconNew = + (HICON) winOverrideIcon(class_hint.res_name, + class_hint.res_class, window_name); - free(pszName); + if (class_hint.res_name) + XFree(class_hint.res_name); + if (class_hint.res_class) + XFree(class_hint.res_class); + if (window_name) + XFree(window_name); + } } + + winUpdateIcon(hWnd, pWMInfo->pDisplay, iWindow, hIconNew); } #if 0 @@ -665,7 +723,7 @@ winMultiWindowWMProc(void *pArg) PropModeReplace, (unsigned char *) &(pNode->msg.hwndWindow), 1); UpdateName(pWMInfo, pNode->msg.iWindow); - winUpdateIcon(pNode->msg.iWindow); + UpdateIcon(pWMInfo, pNode->msg.iWindow); break; case WM_WM_MAP2: @@ -688,7 +746,7 @@ winMultiWindowWMProc(void *pArg) PropModeReplace, (unsigned char *) &(pNode->msg.hwndWindow), 1); UpdateName(pWMInfo, pNode->msg.iWindow); - winUpdateIcon(pNode->msg.iWindow); + UpdateIcon(pWMInfo, pNode->msg.iWindow); { HWND zstyle = HWND_NOTOPMOST; @@ -750,8 +808,8 @@ winMultiWindowWMProc(void *pArg) UpdateName(pWMInfo, pNode->msg.iWindow); break; - case WM_WM_HINTS_EVENT: - winUpdateIcon(pNode->msg.iWindow); + case WM_WM_ICON_EVENT: + UpdateIcon(pWMInfo, pNode->msg.iWindow); break; case WM_WM_CHANGE_STATE: @@ -802,6 +860,7 @@ winMultiWindowXMsgProc(void *pArg) Atom atmWmName; Atom atmWmHints; Atom atmWmChange; + Atom atmNetWmIcon; int iReturn; XIconSize *xis; @@ -927,6 +986,7 @@ winMultiWindowXMsgProc(void *pArg) atmWmName = XInternAtom(pProcArg->pDisplay, "WM_NAME", False); atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False); atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False); + atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False); /* iiimxcf had a bug until 2009-04-27, assuming that the @@ -1054,25 +1114,25 @@ winMultiWindowXMsgProc(void *pArg) True, StructureNotifyMask, &event_send); } } - else if (event.type == PropertyNotify - && event.xproperty.atom == atmWmName) { - memset(&msg, 0, sizeof(msg)); + else if (event.type == PropertyNotify) { + if (event.xproperty.atom == atmWmName) { + memset(&msg, 0, sizeof(msg)); - msg.msg = WM_WM_NAME_EVENT; - msg.iWindow = event.xproperty.window; + msg.msg = WM_WM_NAME_EVENT; + msg.iWindow = event.xproperty.window; - /* Other fields ignored */ - winSendMessageToWM(pProcArg->pWMInfo, &msg); - } - else if (event.type == PropertyNotify - && event.xproperty.atom == atmWmHints) { - memset(&msg, 0, sizeof(msg)); - - msg.msg = WM_WM_HINTS_EVENT; - msg.iWindow = event.xproperty.window; - - /* Other fields ignored */ - winSendMessageToWM(pProcArg->pWMInfo, &msg); + /* Other fields ignored */ + winSendMessageToWM(pProcArg->pWMInfo, &msg); + } + else if ((event.xproperty.atom == atmWmHints) || + (event.xproperty.atom == atmNetWmIcon)) { + memset(&msg, 0, sizeof(msg)); + msg.msg = WM_WM_ICON_EVENT; + msg.iWindow = event.xproperty.window; + + /* Other fields ignored */ + winSendMessageToWM(pProcArg->pWMInfo, &msg); + } } else if (event.type == ClientMessage && event.xclient.message_type == atmWmChange @@ -1683,13 +1743,11 @@ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle) /* Setup a rectangle with the X window position and size */ SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight); -#if 0 - ErrorF("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); -#endif + winDebug("winUpdateWindowPosition - drawable extent (%d, %d)-(%d, %d)\n", + rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, - WS_EX_APPWINDOW); + GetWindowLongPtr(hWnd, GWL_EXSTYLE)); /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */ if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) { @@ -1704,10 +1762,8 @@ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle) rcNew.bottom += iDy; } -#if 0 - ErrorF("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); -#endif + winDebug("winUpdateWindowPosition - Window extent (%d, %d)-(%d, %d)\n", + rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); /* Position the Windows window */ SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c index 86a788287..faa97c351 100644 --- a/xorg-server/hw/xwin/winprefs.c +++ b/xorg-server/hw/xwin/winprefs.c @@ -148,7 +148,6 @@ static wBOOL CALLBACK ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam) { HICON hicon; - Window wid; if (!hwnd) { ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n"); @@ -173,10 +172,23 @@ ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam) /* This window is now clean of our taint (but with undefined icons) */ } else { - /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */ - wid = (Window) GetProp(hwnd, WIN_WID_PROP); - if (wid) - winUpdateIcon(wid); + /* Send a message to WM thread telling it re-evaluate the icon for this window */ + { + winWMMessageRec wmMsg; + + WindowPtr pWin = GetProp(hwnd, WIN_WINDOW_PROP); + + if (pWin) { + winPrivWinPtr pWinPriv = winGetWindowPriv(pWin); + winPrivScreenPtr s_pScreenPriv = pWinPriv->pScreenPriv; + + wmMsg.msg = WM_WM_ICON_EVENT; + wmMsg.hwndWindow = hwnd; + wmMsg.iWindow = (Window) GetProp(hwnd, WIN_WID_PROP); + + winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); + } + } /* Update the system menu for this window */ SetupSysMenu((unsigned long) hwnd); @@ -577,31 +589,15 @@ LoadImageComma(char *fname, int sx, int sy, int flags) * ICONS{} section in the prefs file, and load the icon from a file */ HICON -winOverrideIcon(unsigned long longWin) +winOverrideIcon(char *res_name, char *res_class, char *wmName) { - WindowPtr pWin = (WindowPtr) longWin; - char *res_name, *res_class; int i; HICON hicon; - char *wmName; - - if (pWin == NULL) - return 0; - - /* If we can't find the class, we can't override from default! */ - if (!winMultiWindowGetClassHint(pWin, &res_name, &res_class)) - return 0; - - winMultiWindowGetWMName(pWin, &wmName); for (i = 0; i < pref.iconItems; i++) { - if (!strcmp(pref.icon[i].match, res_name) || - !strcmp(pref.icon[i].match, res_class) || + if ((res_name && !strcmp(pref.icon[i].match, res_name)) || + (res_class && !strcmp(pref.icon[i].match, res_class)) || (wmName && strstr(wmName, pref.icon[i].match))) { - free(res_name); - free(res_class); - free(wmName); - if (pref.icon[i].hicon) return pref.icon[i].hicon; @@ -616,10 +612,6 @@ winOverrideIcon(unsigned long longWin) } /* Didn't find the icon, fail gracefully */ - free(res_name); - free(res_class); - free(wmName); - return 0; } diff --git a/xorg-server/hw/xwin/winprefs.h b/xorg-server/hw/xwin/winprefs.h index fcce8d840..5de5719e1 100644 --- a/xorg-server/hw/xwin/winprefs.h +++ b/xorg-server/hw/xwin/winprefs.h @@ -164,7 +164,7 @@ Bool int winIconIsOverride(unsigned hiconIn); -HICON winOverrideIcon(unsigned long longpWin); +HICON winOverrideIcon(char *res_name, char *res_class, char *wmName); unsigned long winOverrideStyle(char *res_name, char *res_class, char *wmName); diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c index cef49b57c..5bf710209 100644 --- a/xorg-server/hw/xwin/winwin32rootless.c +++ b/xorg-server/hw/xwin/winwin32rootless.c @@ -231,7 +231,7 @@ winMWExtWMCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen, // Store the implementation private frame ID pFrame->wid = (RootlessFrameID) pRLWinPriv; - winSelectIcons(pFrame->win, &hIcon, &hIconSmall); + winSelectIcons(&hIcon, &hIconSmall); /* Set standard class name prefix so we can identify window easily */ strncpy(pszClass, WINDOW_CLASS_X, sizeof(pszClass)); diff --git a/xorg-server/hw/xwin/winwin32rootlesswindow.c b/xorg-server/hw/xwin/winwin32rootlesswindow.c index bfba1bfd0..f2d68cb46 100644 --- a/xorg-server/hw/xwin/winwin32rootlesswindow.c +++ b/xorg-server/hw/xwin/winwin32rootlesswindow.c @@ -147,39 +147,8 @@ winMWExtWMMoveResizeXWindow(WindowPtr pWin, int x, int y, int w, int h) } /* - * winMWExtWMUpdateIcon - * Change the Windows window icon - */ - -void -winMWExtWMUpdateIcon(Window id) -{ - WindowPtr pWin; - HICON hIcon, hiconOld; - - dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, - DixUnknownAccess); - hIcon = winOverrideIcon((unsigned long) pWin); - - if (!hIcon) - hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON)); - if (hIcon) { - win32RootlessWindowPtr pRLWinPriv - = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE); - if (pRLWinPriv->hWnd) { - - hiconOld = (HICON) SendMessage(pRLWinPriv->hWnd, - WM_SETICON, ICON_BIG, - (LPARAM) hIcon); - winDestroyIcon(hiconOld); - } - hIcon = NULL; - } -} - -/* * winMWExtWMDecorateWindow - Update window style. Called by EnumWindows. */ diff --git a/xorg-server/hw/xwin/winwindow.h b/xorg-server/hw/xwin/winwindow.h index c357f8d08..a5919ee4d 100644 --- a/xorg-server/hw/xwin/winwindow.h +++ b/xorg-server/hw/xwin/winwindow.h @@ -115,7 +115,7 @@ typedef struct _winWMMessageRec { #define WM_WM_KILL (WM_USER + 7) #define WM_WM_ACTIVATE (WM_USER + 8) #define WM_WM_NAME_EVENT (WM_USER + 9) -#define WM_WM_HINTS_EVENT (WM_USER + 10) +#define WM_WM_ICON_EVENT (WM_USER + 10) #define WM_WM_CHANGE_STATE (WM_USER + 11) #define WM_WM_MAP2 (WM_USER + 12) #define WM_WM_MAP3 (WM_USER + 13) @@ -157,18 +157,5 @@ void void winMinimizeWindow(Window id); -/* - * winmultiwindowicons.c - */ - -void - winUpdateIcon(Window id); - -void - winInitGlobalIcons(void); - -void - winDestroyIcon(HICON hIcon); - #endif /* XWIN_MULTIWINDOW */ #endif diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c index 77c997ae2..5d513a893 100644 --- a/xorg-server/hw/xwin/winwindowswm.c +++ b/xorg-server/hw/xwin/winwindowswm.c @@ -439,8 +439,6 @@ ProcWindowsWMFrameDraw(ClientPtr client) ShowWindow(pRLWinPriv->hWnd, nCmdShow); - winMWExtWMUpdateIcon(pWin->drawable.id); - if (wBoundingShape(pWin) != NULL) { /* wBoundingShape is relative to *inner* origin of window. Translate by borderWidth to get the outside-relative position. */ -- cgit v1.2.3