/[rdesktop]/sourceforge.net/trunk/rdesktop/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 /sourceforge.net/trunk/rdesktop/xwin.c

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

revision 257 by jsorg71, Mon Nov 11 23:15:27 2002 UTC revision 275 by astrand, Tue Nov 19 14:48:02 2002 UTC
# Line 29  extern int height; Line 29  extern int height;
29  extern BOOL sendmotion;  extern BOOL sendmotion;
30  extern BOOL fullscreen;  extern BOOL fullscreen;
31  extern BOOL grab_keyboard;  extern BOOL grab_keyboard;
32    extern BOOL hide_decorations;
33  extern char title[];  extern char title[];
34  BOOL enable_compose = False;  BOOL enable_compose = False;
35  BOOL focused;  BOOL focused;
# Line 46  static XIM IM; Line 47  static XIM IM;
47  static XIC IC;  static XIC IC;
48  static XModifierKeymap *mod_map;  static XModifierKeymap *mod_map;
49  static Cursor current_cursor;  static Cursor current_cursor;
50    static Atom protocol_atom, kill_atom;
51    
52  /* endianness */  /* endianness */
53  static BOOL host_be;  static BOOL host_be;
# Line 55  static BOOL xserver_be; Line 57  static BOOL xserver_be;
57  static BOOL ownbackstore;  static BOOL ownbackstore;
58  static Pixmap backstore;  static Pixmap backstore;
59    
60    /* MWM decorations */
61    #define MWM_HINTS_DECORATIONS   (1L << 1)
62    #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
63    typedef struct
64    {
65            unsigned long flags;
66            unsigned long functions;
67            unsigned long decorations;
68            long inputMode;
69            unsigned long status;
70    }
71    PropMotifWmHints;
72    
73    
74  #define FILL_RECTANGLE(x,y,cx,cy)\  #define FILL_RECTANGLE(x,y,cx,cy)\
75  { \  { \
76          XFillRectangle(display, wnd, gc, x, y, cx, cy); \          XFillRectangle(display, wnd, gc, x, y, cx, cy); \
# Line 91  static int rop2_map[] = { Line 107  static int rop2_map[] = {
107  #define SET_FUNCTION(rop2)      { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); }  #define SET_FUNCTION(rop2)      { if (rop2 != ROP2_COPY) XSetFunction(display, gc, rop2_map[rop2]); }
108  #define RESET_FUNCTION(rop2)    { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); }  #define RESET_FUNCTION(rop2)    { if (rop2 != ROP2_COPY) XSetFunction(display, gc, GXcopy); }
109    
110    void
111    mwm_hide_decorations(void)
112    {
113            PropMotifWmHints motif_hints;
114            Atom hintsatom;
115    
116            /* setup the property */
117            motif_hints.flags = MWM_HINTS_DECORATIONS;
118            motif_hints.decorations = 0;
119    
120            /* get the atom for the property */
121            hintsatom = XInternAtom(display, "_MOTIF_WM_HINTS", False);
122            if (!hintsatom)
123            {
124                    error("Failed to get atom _MOTIF_WM_HINTS\n");
125                    return;
126            }
127    
128            XChangeProperty(display, wnd, hintsatom, hintsatom, 32, PropModeReplace,
129                            (unsigned char *) &motif_hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
130    }
131    
132  static void  static void
133  translate8(uint8 * data, uint8 * out, uint8 * end)  translate8(uint8 * data, uint8 * out, uint8 * end)
134  {  {
# Line 261  ui_init(void) Line 299  ui_init(void)
299          host_be = !(BOOL) (*(uint8 *) (&test));          host_be = !(BOOL) (*(uint8 *) (&test));
300          xserver_be = (ImageByteOrder(display) == MSBFirst);          xserver_be = (ImageByteOrder(display) == MSBFirst);
301    
302            if ((width == 0) || (height == 0))
303            {
304                    /* Fetch geometry from _NET_WORKAREA */
305                    uint32 xpos, ypos;
306    
307                    if (get_current_workarea(&xpos, &ypos, &width, &height) < 0)
308                    {
309                            error("Failed to get workarea.\n");
310                            error("Perhaps your window manager does not support EWMH?\n");
311                            error("Defaulting to geometry 800x600\n");
312                            width = 800;
313                            height = 600;
314                    }
315            }
316    
317          if (fullscreen)          if (fullscreen)
318          {          {
319                  width = WidthOfScreen(screen);                  width = WidthOfScreen(screen);
# Line 328  ui_create_window(void) Line 381  ui_create_window(void)
381    
382          XStoreName(display, wnd, title);          XStoreName(display, wnd, title);
383    
384            if (hide_decorations)
385                    mwm_hide_decorations();
386    
387          classhints = XAllocClassHint();          classhints = XAllocClassHint();
388          if (classhints != NULL)          if (classhints != NULL)
389          {          {
# Line 381  ui_create_window(void) Line 437  ui_create_window(void)
437          focused = False;          focused = False;
438          mouse_in_wnd = False;          mouse_in_wnd = False;
439    
440            /* handle the WM_DELETE_WINDOW protocol */
441            protocol_atom = XInternAtom(display, "WM_PROTOCOLS", True);
442            kill_atom = XInternAtom(display, "WM_DELETE_WINDOW", True);
443            XSetWMProtocols(display, wnd, &kill_atom, 1);
444    
445          return True;          return True;
446  }  }
447    
# Line 418  xwin_toggle_fullscreen(void) Line 479  xwin_toggle_fullscreen(void)
479          }          }
480  }  }
481    
482  /* Process all events in Xlib queue */  /* Process all events in Xlib queue
483  static void     Returns 0 after user quit, 1 otherwise */
484    static int
485  xwin_process_events(void)  xwin_process_events(void)
486  {  {
487          XEvent xevent;          XEvent xevent;
# Line 447  xwin_process_events(void) Line 509  xwin_process_events(void)
509    
510                  switch (xevent.type)                  switch (xevent.type)
511                  {                  {
512                            case ClientMessage:
513                                    /* the window manager told us to quit */
514                                    if ((xevent.xclient.message_type == protocol_atom)
515                                        && (xevent.xclient.data.l[0] == kill_atom))
516                                            /* Quit */
517                                            return 0;
518                                    break;
519    
520                          case KeyPress:                          case KeyPress:
521                                  if (IC != NULL)                                  if (IC != NULL)
522                                          /* Multi_key compatible version */                                          /* Multi_key compatible version */
# Line 469  xwin_process_events(void) Line 539  xwin_process_events(void)
539                                                        str, sizeof(str), &keysym, NULL);                                                        str, sizeof(str), &keysym, NULL);
540                                  }                                  }
541    
542                                  DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym)));                                  DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym,
543                                               get_ksname(keysym)));
544    
545                                  ev_time = time(NULL);                                  ev_time = time(NULL);
546                                  if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True))                                  if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True))
# Line 528  xwin_process_events(void) Line 599  xwin_process_events(void)
599                                  if (xevent.xfocus.mode == NotifyGrab)                                  if (xevent.xfocus.mode == NotifyGrab)
600                                          break;                                          break;
601                                  focused = True;                                  focused = True;
602                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy,
603                                                  &dummy, &dummy, &state);
604                                  reset_modifier_keys(state);                                  reset_modifier_keys(state);
605                                  if (grab_keyboard && mouse_in_wnd)                                  if (grab_keyboard && mouse_in_wnd)
606                                          XGrabKeyboard(display, wnd, True,                                          XGrabKeyboard(display, wnd, True,
# Line 549  xwin_process_events(void) Line 621  xwin_process_events(void)
621                                  mouse_in_wnd = True;                                  mouse_in_wnd = True;
622                                  if (fullscreen)                                  if (fullscreen)
623                                  {                                  {
624                                          XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);                                          XSetInputFocus(display, wnd, RevertToPointerRoot,
625                                                           CurrentTime);
626                                          break;                                          break;
627                                  }                                  }
628                                  if (focused)                                  if (focused)
# Line 587  xwin_process_events(void) Line 660  xwin_process_events(void)
660    
661                  }                  }
662          }          }
663            /* Keep going */
664            return 1;
665  }  }
666    
667  void  /* Returns 0 after user quit, 1 otherwise */
668    int
669  ui_select(int rdp_socket)  ui_select(int rdp_socket)
670  {  {
671          int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1;          int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1;
# Line 600  ui_select(int rdp_socket) Line 676  ui_select(int rdp_socket)
676          while (True)          while (True)
677          {          {
678                  /* Process any events already waiting */                  /* Process any events already waiting */
679                  xwin_process_events();                  if (!xwin_process_events())
680                            /* User quit */
681                            return 0;
682    
683                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
684                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
# Line 616  ui_select(int rdp_socket) Line 694  ui_select(int rdp_socket)
694                  }                  }
695    
696                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
697                          return;                          return 1;
698          }          }
699  }  }
700    
# Line 1132  ui_draw_text(uint8 font, uint8 flags, in Line 1210  ui_draw_text(uint8 font, uint8 flags, in
1210                                  else                                  else
1211                                  {                                  {
1212                                          error("this shouldn't be happening\n");                                          error("this shouldn't be happening\n");
1213                                          break;                                          exit(1);
1214                                  }                                  }
1215                                  /* this will move pointer from start to first character after FF command */                                  /* this will move pointer from start to first character after FF command */
1216                                  length -= i + 3;                                  length -= i + 3;

Legend:
Removed from v.257  
changed lines
  Added in v.275

  ViewVC Help
Powered by ViewVC 1.1.26