/[rdesktop]/jpeg/rdesktop/trunk/xwin.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /jpeg/rdesktop/trunk/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

sourceforge.net/trunk/rdesktop/xwin.c revision 1453 by astrand, Fri Mar 14 07:39:38 2008 UTC jpeg/rdesktop/trunk/xwin.c revision 1508 by dpavlin, Mon Jul 20 16:47:49 2009 UTC
# Line 1  Line 1 
1  /* -*- c-basic-offset: 8 -*-  /* -*- c-basic-offset: 8 -*-
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X Window System     User interface services - X Window System
4     Copyright (C) Matthew Chapman 1999-2007     Copyright (C) Matthew Chapman 1999-2008
5     Copyright 2007 Pierre Ossman <ossman@cendio.se> for Cendio AB     Copyright 2007-2008 Pierre Ossman <ossman@cendio.se> for Cendio AB
6    
7     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 30  Line 30 
30  #include "rdesktop.h"  #include "rdesktop.h"
31  #include "xproto.h"  #include "xproto.h"
32    
33    /* DJ globals begin */
34    extern uint8 * g_bitmap_data;
35    extern uint8 * g_bitmap_data_last_write;
36    extern uint32 g_pixels_changed;
37    extern unsigned long long g_time_last_change;
38    /* DJ globals end */
39    
40  extern int g_width;  extern int g_width;
41  extern int g_height;  extern int g_height;
42  extern int g_xpos;  extern int g_xpos;
# Line 86  static unsigned long g_seamless_focused Line 93  static unsigned long g_seamless_focused
93  static RD_BOOL g_seamless_started = False;      /* Server end is up and running */  static RD_BOOL g_seamless_started = False;      /* Server end is up and running */
94  static RD_BOOL g_seamless_active = False;       /* We are currently in seamless mode */  static RD_BOOL g_seamless_active = False;       /* We are currently in seamless mode */
95  static RD_BOOL g_seamless_hidden = False;       /* Desktop is hidden on server */  static RD_BOOL g_seamless_hidden = False;       /* Desktop is hidden on server */
96    static RD_BOOL g_seamless_broken_restack = False;       /* WM does not properly restack */
97  extern RD_BOOL g_seamless_rdp;  extern RD_BOOL g_seamless_rdp;
98    
99  extern uint32 g_embed_wnd;  extern uint32 g_embed_wnd;
# Line 109  static XIC g_IC; Line 117  static XIC g_IC;
117  static XModifierKeymap *g_mod_map;  static XModifierKeymap *g_mod_map;
118  /* Maps logical (xmodmap -pp) pointing device buttons (0-based) back  /* Maps logical (xmodmap -pp) pointing device buttons (0-based) back
119     to physical (1-based) indices. */     to physical (1-based) indices. */
120  static unsigned char g_pointer_log_to_phys_map[16];  static unsigned char g_pointer_log_to_phys_map[32];
121  static Cursor g_current_cursor;  static Cursor g_current_cursor;
122  static RD_HCURSOR g_null_cursor = NULL;  static RD_HCURSOR g_null_cursor = NULL;
123  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
# Line 529  mwm_hide_decorations(Window wnd) Line 537  mwm_hide_decorations(Window wnd)
537    
538  }  }
539    
540    typedef struct _sw_configurenotify_context
541    {
542            Window window;
543            unsigned long serial;
544    } sw_configurenotify_context;
545    
546    /* Predicate procedure for sw_wait_configurenotify */
547    static Bool
548    sw_configurenotify_p(Display * display, XEvent * xevent, XPointer arg)
549    {
550            sw_configurenotify_context *context = (sw_configurenotify_context *) arg;
551            if (xevent->xany.type == ConfigureNotify
552                && xevent->xconfigure.window == context->window
553                && xevent->xany.serial >= context->serial)
554                    return True;
555    
556            return False;
557    }
558    
559    /* Wait for a ConfigureNotify, with a equal or larger serial, on the
560       specified window. The event will be removed from the queue. We
561       could use XMaskEvent(StructureNotifyMask), but we would then risk
562       throwing away crucial events like DestroyNotify.
563    
564       After a ConfigureWindow, according to ICCCM section 4.1.5, we
565       should recieve a ConfigureNotify, either a real or synthetic
566       one. This indicates that the configure has been "completed".
567       However, some WMs such as several versions of Metacity fails to
568       send synthetic events. See bug
569       http://bugzilla.gnome.org/show_bug.cgi?id=322840. We need to use a
570       timeout to avoid a hang. Tk uses the same approach. */
571    static void
572    sw_wait_configurenotify(Window wnd, unsigned long serial)
573    {
574            XEvent xevent;
575            sw_configurenotify_context context;
576            struct timeval now;
577            struct timeval nextsecond;
578            RD_BOOL got = False;
579    
580            context.window = wnd;
581            context.serial = serial;
582    
583            gettimeofday(&nextsecond, NULL);
584            nextsecond.tv_sec += 1;
585    
586            do
587            {
588                    if (XCheckIfEvent(g_display, &xevent, sw_configurenotify_p, (XPointer) & context))
589                    {
590                            got = True;
591                            break;
592                    }
593                    usleep(100000);
594                    gettimeofday(&now, NULL);
595            }
596            while (timercmp(&now, &nextsecond, <));
597    
598            if (!got)
599            {
600                    warning("Broken Window Manager: Timeout while waiting for ConfigureNotify\n");
601            }
602    }
603    
604    /* Get the toplevel window, in case of reparenting */
605    static Window
606    sw_get_toplevel(Window wnd)
607    {
608            Window root, parent;
609            Window *child_list;
610            unsigned int num_children;
611    
612            while (1)
613            {
614                    XQueryTree(g_display, wnd, &root, &parent, &child_list, &num_children);
615                    if (root == parent)
616                    {
617                            break;
618                    }
619                    else if (!parent)
620                    {
621                            warning("Internal error: sw_get_toplevel called with root window\n");
622                    }
623    
624                    wnd = parent;
625            }
626    
627            return wnd;
628    }
629    
630    
631    /* Check if wnd is already behind a window wrt stacking order */
632    static RD_BOOL
633    sw_window_is_behind(Window wnd, Window behind)
634    {
635            Window dummy1, dummy2;
636            Window *child_list;
637            unsigned int num_children;
638            unsigned int i;
639            RD_BOOL found_behind = False;
640            RD_BOOL found_wnd = False;
641    
642            wnd = sw_get_toplevel(wnd);
643            behind = sw_get_toplevel(behind);
644    
645            XQueryTree(g_display, RootWindowOfScreen(g_screen), &dummy1, &dummy2, &child_list,
646                       &num_children);
647    
648            for (i = num_children - 1; i >= 0; i--)
649            {
650                    if (child_list[i] == behind)
651                    {
652                            found_behind = True;
653                    }
654                    else if (child_list[i] == wnd)
655                    {
656                            found_wnd = True;
657                            break;
658                    }
659            }
660    
661            if (child_list)
662                    XFree(child_list);
663    
664            if (!found_wnd)
665            {
666                    warning("sw_window_is_behind: Unable to find window 0x%lx\n", wnd);
667    
668                    if (!found_behind)
669                    {
670                            warning("sw_window_is_behind: Unable to find behind window 0x%lx\n",
671                                    behind);
672                    }
673            }
674    
675            return found_behind;
676    }
677    
678    
679    /* Test if the window manager correctly handles window restacking. In
680       particular, we are testing if it's possible to place a window
681       between two other windows. Many WMs such as Metacity can only stack
682       windows on the top or bottom. The window creation should mostly
683       match ui_seamless_create_window. */
684    static void
685    seamless_restack_test()
686    {
687            /* The goal is to have the middle window between top and
688               bottom.  The middle window is initially at the top,
689               though. */
690            Window wnds[3];         /* top, middle and bottom */
691            int i;
692            XEvent xevent;
693            XWindowChanges values;
694            unsigned long restack_serial;
695    
696            for (i = 0; i < 3; i++)
697            {
698                    char name[64];
699                    wnds[i] =
700                            XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, 20, 20,
701                                                0, 0, 0);
702                    snprintf(name, sizeof(name), "SeamlessRDP restack test - window %d", i);
703                    XStoreName(g_display, wnds[i], name);
704                    ewmh_set_wm_name(wnds[i], name);
705    
706                    /* Hide decorations. Often this means that no
707                       reparenting will be done, which makes the restack
708                       easier. Besides, we want to mimic our other
709                       seamless windows as much as possible. We must still
710                       handle the case with reparenting, though. */
711                    mwm_hide_decorations(wnds[i]);
712    
713                    /* Prevent windows from appearing in task bar */
714                    XSetTransientForHint(g_display, wnds[i], RootWindowOfScreen(g_screen));
715                    ewmh_set_window_popup(wnds[i]);
716    
717                    /* We need to catch MapNotify/ConfigureNotify */
718                    XSelectInput(g_display, wnds[i], StructureNotifyMask);
719            }
720    
721            /* Map Windows. Currently, we assume that XMapRaised places
722               the window on the top of the stack. Should be fairly safe;
723               the window is configured before it's mapped. */
724            XMapRaised(g_display, wnds[2]); /* bottom */
725            do
726            {
727                    XWindowEvent(g_display, wnds[2], StructureNotifyMask, &xevent);
728            }
729            while (xevent.type != MapNotify);
730            XMapRaised(g_display, wnds[0]); /* top */
731            do
732            {
733                    XWindowEvent(g_display, wnds[0], StructureNotifyMask, &xevent);
734            }
735            while (xevent.type != MapNotify);
736            XMapRaised(g_display, wnds[1]); /* middle */
737            do
738            {
739                    XWindowEvent(g_display, wnds[1], StructureNotifyMask, &xevent);
740            }
741            while (xevent.type != MapNotify);
742    
743            /* The stacking order should now be 1 - 0 - 2 */
744            if (!sw_window_is_behind(wnds[0], wnds[1]) || !sw_window_is_behind(wnds[2], wnds[1]))
745            {
746                    /* Ok, technically a WM is allowed to stack windows arbitrarily, but... */
747                    warning("Broken Window Manager: Unable to test window restacking\n");
748                    g_seamless_broken_restack = True;
749                    for (i = 0; i < 3; i++)
750                            XDestroyWindow(g_display, wnds[i]);
751                    return;
752            }
753    
754            /* Restack, using XReconfigureWMWindow, which should correctly
755               handle reparented windows as well as nonreparenting WMs. */
756            values.stack_mode = Below;
757            values.sibling = wnds[0];
758            restack_serial = XNextRequest(g_display);
759            XReconfigureWMWindow(g_display, wnds[1], DefaultScreen(g_display), CWStackMode | CWSibling,
760                                 &values);
761            sw_wait_configurenotify(wnds[1], restack_serial);
762    
763            /* Now verify that middle is behind top but not behind
764               bottom */
765            if (!sw_window_is_behind(wnds[1], wnds[0]))
766            {
767                    warning("Broken Window Manager: doesn't handle restack (restack request was ignored)\n");
768                    g_seamless_broken_restack = True;
769            }
770            else if (sw_window_is_behind(wnds[1], wnds[2]))
771            {
772                    warning("Broken Window Manager: doesn't handle restack (window was moved to bottom)\n");
773                    g_seamless_broken_restack = True;
774            }
775    
776            /* Destroy windows */
777            for (i = 0; i < 3; i++)
778                    XDestroyWindow(g_display, wnds[i]);
779    }
780    
781  #define SPLITCOLOUR15(colour, rv) \  #define SPLITCOLOUR15(colour, rv) \
782  { \  { \
783          rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); \          rv.red = ((colour >> 7) & 0xf8) | ((colour >> 12) & 0x7); \
# Line 1283  xwin_refresh_pointer_map(void) Line 1532  xwin_refresh_pointer_map(void)
1532          int i, pointer_buttons;          int i, pointer_buttons;
1533    
1534          pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map));          pointer_buttons = XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map));
1535          for (i = 0; i < pointer_buttons; ++i)          if (pointer_buttons > sizeof(phys_to_log_map))
1536          {                  pointer_buttons = sizeof(phys_to_log_map);
1537                  /* This might produce multiple logical buttons mapping  
1538                     to a single physical one, but hey, that's          /* if multiple physical buttons map to the same logical button, then
1539                     life... */           * use the lower numbered physical one */
1540            for (i = pointer_buttons - 1; i >= 0; i--)
1541            {
1542                    /* a user could specify arbitrary values for the logical button
1543                     * number, ignore any that are abnormally large */
1544                    if (phys_to_log_map[i] > sizeof(g_pointer_log_to_phys_map))
1545                            continue;
1546                  g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1;                  g_pointer_log_to_phys_map[phys_to_log_map[i] - 1] = i + 1;
1547          }          }
1548  }  }
# Line 1536  select_visual(int screen_num) Line 1791  select_visual(int screen_num)
1791  }  }
1792    
1793  static XErrorHandler g_old_error_handler;  static XErrorHandler g_old_error_handler;
1794    static RD_BOOL g_error_expected = False;
1795    
1796    /* Check if the X11 window corresponding to a seamless window with
1797       specified id exists. */
1798    RD_BOOL
1799    sw_window_exists(unsigned long id)
1800    {
1801            seamless_window *sw;
1802            char *name;
1803            Status sts = 0;
1804    
1805            sw = sw_get_window_by_id(id);
1806            if (!sw)
1807                    return False;
1808    
1809            g_error_expected = True;
1810            sts = XFetchName(g_display, sw->wnd, &name);
1811            g_error_expected = False;
1812            if (sts)
1813            {
1814                    XFree(name);
1815            }
1816    
1817            return sts;
1818    }
1819    
1820  static int  static int
1821  error_handler(Display * dpy, XErrorEvent * eev)  error_handler(Display * dpy, XErrorEvent * eev)
1822  {  {
1823          if ((eev->error_code == BadMatch) && (eev->request_code == X_ConfigureWindow))          if (g_error_expected)
         {  
                 fprintf(stderr, "Got \"BadMatch\" when trying to restack windows.\n");  
                 fprintf(stderr,  
                         "This is most likely caused by a broken window manager (commonly KWin).\n");  
1824                  return 0;                  return 0;
         }  
1825    
1826          return g_old_error_handler(dpy, eev);          return g_old_error_handler(dpy, eev);
1827  }  }
# Line 1656  ui_init(void) Line 1931  ui_init(void)
1931          xclip_init();          xclip_init();
1932          ewmh_init();          ewmh_init();
1933          if (g_seamless_rdp)          if (g_seamless_rdp)
1934            {
1935                  seamless_init();                  seamless_init();
1936            }
1937    
1938          DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_depth, g_bpp, g_depth));          DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_depth, g_bpp, g_depth));
1939    
# Line 1831  ui_create_window(void) Line 2108  ui_create_window(void)
2108          if (g_null_cursor == NULL)          if (g_null_cursor == NULL)
2109                  g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);                  g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);
2110    
2111            if (g_seamless_rdp)
2112            {
2113                    seamless_restack_test();
2114            }
2115    
2116          return True;          return True;
2117  }  }
2118    
# Line 2138  xwin_process_events(void) Line 2420  xwin_process_events(void)
2420                                  if (!sw)                                  if (!sw)
2421                                          break;                                          break;
2422    
2423                                    /* Menu windows are real X11 windows,
2424                                       with focus. When such a window is
2425                                       destroyed, focus is reverted to the
2426                                       main application window, which
2427                                       would cause us to send FOCUS. This
2428                                       breaks window switching in, say,
2429                                       Seamonkey. We shouldn't need to
2430                                       send FOCUS: Windows should also
2431                                       revert focus to some other window
2432                                       when the menu window is
2433                                       destroyed. So, we only send FOCUS
2434                                       if the previous focus window still
2435                                       exists. */
2436                                  if (sw->id != g_seamless_focused)                                  if (sw->id != g_seamless_focused)
2437                                  {                                  {
2438                                          seamless_send_focus(sw->id, 0);  
2439                                            if (sw_window_exists(g_seamless_focused))
2440                                                    seamless_send_focus(sw->id, 0);
2441                                          g_seamless_focused = sw->id;                                          g_seamless_focused = sw->id;
2442                                  }                                  }
2443                                  break;                                  break;
# Line 2400  ui_create_bitmap(int width, int height, Line 2697  ui_create_bitmap(int width, int height,
2697  }  }
2698    
2699  void  void
2700    update_bitmap(int x, int y, int width, int height, uint8 * data)
2701    {
2702            int size;
2703            uint8 *out;
2704            uint8 *end;
2705            uint8 *c_current;
2706            uint8 *c_update;
2707            uint8 *c_written;
2708            int col;
2709            int row;
2710            BOOL matches_written;
2711            BOOL matches_current;
2712    
2713            size = width * height * 3;   /* force 24-bit color for libjpeg: R G B */
2714            out = (uint8 *) xmalloc(size);
2715            end = out + size;
2716    
2717            switch (g_server_depth)
2718            {
2719                    case 24:
2720                            translate24to24(data, out, end);
2721                            break;
2722                    case 16:
2723                            translate16to24((uint16 *) data, out, end);
2724                            break;
2725                    case 15:
2726                            translate15to24((uint16 *) data, out, end);
2727                            break;
2728                    case 8:
2729                            translate8to24(data, out, end);
2730                            break;
2731            }
2732    
2733            for (row=0; row<height; row++)
2734            {
2735                    /* truncate if out of bounds */
2736                    if (g_height <= (y + row))
2737                            break;
2738    
2739                    c_update = out + row * width * 3;
2740                    c_current = g_bitmap_data + (row + y) * g_width * 3 + x * 3;
2741                    c_written = g_bitmap_data_last_write + (row + y) * g_width * 3 + x * 3;
2742    
2743                    for (col = 0; col < width; col++)
2744                    {
2745                            /* truncate if out of bounds */
2746                            if (g_width <= (x + col))
2747                                    break;
2748    
2749                            matches_written = True;
2750                            matches_current = True;
2751    
2752                            /* updates come in as BGR order... force RGB */
2753                            if (*c_current != *(c_update+2))
2754                            {
2755                                    if (*(c_update+2) != *c_written)
2756                                            matches_written = False;
2757                                    matches_current = False;
2758                                    *c_current = *(c_update+2);
2759                            }
2760    
2761                            c_written++;
2762    
2763                            if (*(++c_current) != *(++c_update))
2764                            {
2765                                    if (*c_update != *c_written)
2766                                            matches_written = False;
2767                                    matches_current = False;
2768                                    *c_current = *c_update;
2769                            }
2770    
2771                            c_written++;
2772    
2773                            if (*(++c_current) != *(++c_update-2))
2774                            {
2775                                    if (*(c_update-2) != *c_written)
2776                                            matches_written = False;
2777                                    matches_current = False;
2778                                    *c_current = *(c_update-2);
2779                            }
2780    
2781                            c_written++;
2782                            c_current++;
2783                            c_update++;
2784    
2785                            if (!matches_current)
2786                            {
2787                                    if (matches_written)
2788                                            g_pixels_changed--;
2789                                    else
2790                                            g_pixels_changed++;
2791                            }
2792                    }
2793            }
2794    
2795            //printf("g_pixels_changed=%d\n", g_pixels_changed);
2796    
2797            xfree(out);
2798            g_time_last_change = tod();
2799    }
2800    
2801    void
2802  ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data)  ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data)
2803  {  {
2804          XImage *image;          XImage *image;
2805          uint8 *tdata;          uint8 *tdata;
2806          int bitmap_pad;          int bitmap_pad;
2807    
2808            update_bitmap(x, y, width, height, data);
2809    
2810          if (g_server_depth == 8)          if (g_server_depth == 8)
2811          {          {
2812                  bitmap_pad = 8;                  bitmap_pad = 8;
# Line 2780  ui_patblt(uint8 opcode, Line 3181  ui_patblt(uint8 opcode,
3181                          break;                          break;
3182    
3183                  case 3: /* Pattern */                  case 3: /* Pattern */
3184                          for (i = 0; i != 8; i++)                          if (brush->bd == 0)     /* rdp4 brush */
3185                                  ipattern[7 - i] = brush->pattern[i];                          {
3186                          fill = (Pixmap) ui_create_glyph(8, 8, ipattern);                                  for (i = 0; i != 8; i++)
3187                          SET_FOREGROUND(bgcolour);                                          ipattern[7 - i] = brush->pattern[i];
3188                          SET_BACKGROUND(fgcolour);                                  fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
3189                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                                  SET_FOREGROUND(bgcolour);
3190                          XSetStipple(g_display, g_gc, fill);                                  SET_BACKGROUND(fgcolour);
3191                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                                  XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
3192                          FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);                                  XSetStipple(g_display, g_gc, fill);
3193                          XSetFillStyle(g_display, g_gc, FillSolid);                                  XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3194                          XSetTSOrigin(g_display, g_gc, 0, 0);                                  FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
3195                          ui_destroy_glyph((RD_HGLYPH) fill);                                  XSetFillStyle(g_display, g_gc, FillSolid);
3196                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3197                                    ui_destroy_glyph((RD_HGLYPH) fill);
3198                            }
3199                            else if (brush->bd->colour_code > 1)    /* > 1 bpp */
3200                            {
3201                                    fill = (Pixmap) ui_create_bitmap(8, 8, brush->bd->data);
3202                                    XSetFillStyle(g_display, g_gc, FillTiled);
3203                                    XSetTile(g_display, g_gc, fill);
3204                                    XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3205                                    FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
3206                                    XSetFillStyle(g_display, g_gc, FillSolid);
3207                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3208                                    ui_destroy_bitmap((RD_HBITMAP) fill);
3209                            }
3210                            else
3211                            {
3212                                    fill = (Pixmap) ui_create_glyph(8, 8, brush->bd->data);
3213                                    SET_FOREGROUND(bgcolour);
3214                                    SET_BACKGROUND(fgcolour);
3215                                    XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
3216                                    XSetStipple(g_display, g_gc, fill);
3217                                    XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3218                                    FILL_RECTANGLE_BACKSTORE(x, y, cx, cy);
3219                                    XSetFillStyle(g_display, g_gc, FillSolid);
3220                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3221                                    ui_destroy_glyph((RD_HGLYPH) fill);
3222                            }
3223                          break;                          break;
3224    
3225                  default:                  default:
# Line 2954  ui_polygon(uint8 opcode, Line 3382  ui_polygon(uint8 opcode,
3382                          break;                          break;
3383    
3384                  case 3: /* Pattern */                  case 3: /* Pattern */
3385                          for (i = 0; i != 8; i++)                          if (brush->bd == 0)     /* rdp4 brush */
3386                                  ipattern[7 - i] = brush->pattern[i];                          {
3387                          fill = (Pixmap) ui_create_glyph(8, 8, ipattern);                                  for (i = 0; i != 8; i++)
3388                          SET_FOREGROUND(bgcolour);                                          ipattern[7 - i] = brush->pattern[i];
3389                          SET_BACKGROUND(fgcolour);                                  fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
3390                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                                  SET_FOREGROUND(bgcolour);
3391                          XSetStipple(g_display, g_gc, fill);                                  SET_BACKGROUND(fgcolour);
3392                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                                  XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
3393                          FILL_POLYGON((XPoint *) point, npoints);                                  XSetStipple(g_display, g_gc, fill);
3394                          XSetFillStyle(g_display, g_gc, FillSolid);                                  XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3395                          XSetTSOrigin(g_display, g_gc, 0, 0);                                  FILL_POLYGON((XPoint *) point, npoints);
3396                          ui_destroy_glyph((RD_HGLYPH) fill);                                  XSetFillStyle(g_display, g_gc, FillSolid);
3397                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3398                                    ui_destroy_glyph((RD_HGLYPH) fill);
3399                            }
3400                            else if (brush->bd->colour_code > 1)    /* > 1 bpp */
3401                            {
3402                                    fill = (Pixmap) ui_create_bitmap(8, 8, brush->bd->data);
3403                                    XSetFillStyle(g_display, g_gc, FillTiled);
3404                                    XSetTile(g_display, g_gc, fill);
3405                                    XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3406                                    FILL_POLYGON((XPoint *) point, npoints);
3407                                    XSetFillStyle(g_display, g_gc, FillSolid);
3408                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3409                                    ui_destroy_bitmap((RD_HBITMAP) fill);
3410                            }
3411                            else
3412                            {
3413                                    fill = (Pixmap) ui_create_glyph(8, 8, brush->bd->data);
3414                                    SET_FOREGROUND(bgcolour);
3415                                    SET_BACKGROUND(fgcolour);
3416                                    XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
3417                                    XSetStipple(g_display, g_gc, fill);
3418                                    XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3419                                    FILL_POLYGON((XPoint *) point, npoints);
3420                                    XSetFillStyle(g_display, g_gc, FillSolid);
3421                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3422                                    ui_destroy_glyph((RD_HGLYPH) fill);
3423                            }
3424                          break;                          break;
3425    
3426                  default:                  default:
# Line 3032  ui_ellipse(uint8 opcode, Line 3487  ui_ellipse(uint8 opcode,
3487                          break;                          break;
3488    
3489                  case 3: /* Pattern */                  case 3: /* Pattern */
3490                          for (i = 0; i != 8; i++)                          if (brush->bd == 0)     /* rdp4 brush */
3491                                  ipattern[7 - i] = brush->pattern[i];                          {
3492                          fill = (Pixmap) ui_create_glyph(8, 8, ipattern);                                  for (i = 0; i != 8; i++)
3493                          SET_FOREGROUND(bgcolour);                                          ipattern[7 - i] = brush->pattern[i];
3494                          SET_BACKGROUND(fgcolour);                                  fill = (Pixmap) ui_create_glyph(8, 8, ipattern);
3495                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                                  SET_FOREGROUND(bgcolour);
3496                          XSetStipple(g_display, g_gc, fill);                                  SET_BACKGROUND(fgcolour);
3497                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                                  XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
3498                          DRAW_ELLIPSE(x, y, cx, cy, fillmode);                                  XSetStipple(g_display, g_gc, fill);
3499                          XSetFillStyle(g_display, g_gc, FillSolid);                                  XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3500                          XSetTSOrigin(g_display, g_gc, 0, 0);                                  DRAW_ELLIPSE(x, y, cx, cy, fillmode);
3501                          ui_destroy_glyph((RD_HGLYPH) fill);                                  XSetFillStyle(g_display, g_gc, FillSolid);
3502                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3503                                    ui_destroy_glyph((RD_HGLYPH) fill);
3504                            }
3505                            else if (brush->bd->colour_code > 1)    /* > 1 bpp */
3506                            {
3507                                    fill = (Pixmap) ui_create_bitmap(8, 8, brush->bd->data);
3508                                    XSetFillStyle(g_display, g_gc, FillTiled);
3509                                    XSetTile(g_display, g_gc, fill);
3510                                    XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3511                                    DRAW_ELLIPSE(x, y, cx, cy, fillmode);
3512                                    XSetFillStyle(g_display, g_gc, FillSolid);
3513                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3514                                    ui_destroy_bitmap((RD_HBITMAP) fill);
3515                            }
3516                            else
3517                            {
3518                                    fill = (Pixmap) ui_create_glyph(8, 8, brush->bd->data);
3519                                    SET_FOREGROUND(bgcolour);
3520                                    SET_BACKGROUND(fgcolour);
3521                                    XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
3522                                    XSetStipple(g_display, g_gc, fill);
3523                                    XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);
3524                                    DRAW_ELLIPSE(x, y, cx, cy, fillmode);
3525                                    XSetFillStyle(g_display, g_gc, FillSolid);
3526                                    XSetTSOrigin(g_display, g_gc, 0, 0);
3527                                    ui_destroy_glyph((RD_HGLYPH) fill);
3528                            }
3529                          break;                          break;
3530    
3531                  default:                  default:
# Line 3683  void Line 4165  void
4165  ui_seamless_restack_window(unsigned long id, unsigned long behind, unsigned long flags)  ui_seamless_restack_window(unsigned long id, unsigned long behind, unsigned long flags)
4166  {  {
4167          seamless_window *sw;          seamless_window *sw;
4168            XWindowChanges values;
4169            unsigned long restack_serial;
4170    
4171          if (!g_seamless_active)          if (!g_seamless_active)
4172                  return;                  return;
# Line 3697  ui_seamless_restack_window(unsigned long Line 4181  ui_seamless_restack_window(unsigned long
4181          if (behind)          if (behind)
4182          {          {
4183                  seamless_window *sw_behind;                  seamless_window *sw_behind;
                 Window wnds[2];  
4184    
4185                  sw_behind = sw_get_window_by_id(behind);                  sw_behind = sw_get_window_by_id(behind);
4186                  if (!sw_behind)                  if (!sw_behind)
# Line 3706  ui_seamless_restack_window(unsigned long Line 4189  ui_seamless_restack_window(unsigned long
4189                          return;                          return;
4190                  }                  }
4191    
4192                  wnds[1] = sw->wnd;                  if (!g_seamless_broken_restack)
4193                  wnds[0] = sw_behind->wnd;                  {
4194                            values.stack_mode = Below;
4195                  XRestackWindows(g_display, wnds, 2);                          values.sibling = sw_behind->wnd;
4196                            restack_serial = XNextRequest(g_display);
4197                            XReconfigureWMWindow(g_display, sw->wnd, DefaultScreen(g_display),
4198                                                 CWStackMode | CWSibling, &values);
4199                            sw_wait_configurenotify(sw->wnd, restack_serial);
4200                    }
4201          }          }
4202          else          else
4203          {          {
4204                  XRaiseWindow(g_display, sw->wnd);                  values.stack_mode = Above;
4205                    restack_serial = XNextRequest(g_display);
4206                    XReconfigureWMWindow(g_display, sw->wnd, DefaultScreen(g_display), CWStackMode,
4207                                         &values);
4208                    sw_wait_configurenotify(sw->wnd, restack_serial);
4209          }          }
4210    
4211          sw_restack_window(sw, behind);          sw_restack_window(sw, behind);

Legend:
Removed from v.1453  
changed lines
  Added in v.1508

  ViewVC Help
Powered by ViewVC 1.1.26