/[oroborus]/oroborus/src/oroborus.c
ViewVC logotype

Diff of /oroborus/src/oroborus.c

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

revision 1.11 by dreamind, Sun Jul 7 03:17:41 2002 UTC revision 1.12 by dreamind, Mon Jul 15 08:23:08 2002 UTC
# Line 35  Line 35 
35  int  int
36  handleXError (Display * dpy, XErrorEvent * err)  handleXError (Display * dpy, XErrorEvent * err)
37  {  {
38    switch (err->error_code)          switch (err->error_code)
39      {                  {
40      case BadAccess:                  case BadAccess:
41        if (err->resourceid == root)                          if (err->resourceid == root)
42          {                                  {
43            fprintf (stderr, "%s: Another window manager is running\n",                                          fprintf (stderr, "%s: Another window manager is running\n",
44                     progname);                                                                           progname);
45            exit (1);                                          exit (1);
46          }                                  }
47      }                  }
48    return 0;          return 0;
49  }  }
50    
51  void  void
52  cleanUp ()  cleanUp ()
53  {  {
54    int i;          int i;
55    
56  #ifdef DEBUG  #ifdef DEBUG
57    printf ("entering cleanUp\n");          printf ("entering cleanUp\n");
58  #endif  #endif
59    
60    clientUnframeAll ();          clientUnframeAll ();
61    unloadSettings ();          unloadSettings ();
62    XFreeCursor (dpy, root_cursor);          XFreeCursor (dpy, root_cursor);
63    XFreeCursor (dpy, move_cursor);          XFreeCursor (dpy, move_cursor);
64    for (i = 0; i < 4; i++)          for (i = 0; i < 4; i++)
65      XFreeCursor (dpy, resize_cursor[i]);                  XFreeCursor (dpy, resize_cursor[i]);
66    XSetInputFocus (dpy, root, RevertToPointerRoot, CurrentTime);          XSetInputFocus (dpy, root, RevertToPointerRoot, CurrentTime);
67    XCloseDisplay (dpy);          XCloseDisplay (dpy);
68  }  }
69    
70  void  void
71  handleSignal (int sig)  handleSignal (int sig)
72  {  {
73    int *status = NULL;          int *status = NULL;
74  #ifdef DEBUG  #ifdef DEBUG
75    printf ("entering handleSignal\n");          printf ("entering handleSignal\n");
76  #endif  #endif
77    
78    switch (sig)          switch (sig)
79      {                  {
80      case SIGINT:                  case SIGINT:
81      case SIGTERM:                  case SIGTERM:
82        quit = True;                          quit = True;
83        break;                          break;
84      case SIGSEGV:                  case SIGSEGV:
85        fprintf (stderr, "%s: Segmentation fault\n", progname);                          fprintf (stderr, "%s: Segmentation fault\n", progname);
86        cleanUp ();                          cleanUp ();
87        exit (1);                          exit (1);
88        break;                          break;
89      case SIGHUP:                  case SIGHUP:
90        reload = True;                          reload = True;
91        break;                          break;
92      case SIGCHLD:                  case SIGCHLD:
93        printf ("waiting for a child\n");                          printf ("waiting for a child\n");
94        waitpid (-1, status, WNOHANG);                          waitpid (-1, status, WNOHANG);
95        break;                          break;
96      }                  }
97  }  }
98    
99  void  void
100  usage (int status)  usage (int status)
101  {  {
102    printf (_("%s - \          printf (_("%s - \
103  lightweight themeable window manager for X.\n"), progname);  lightweight themeable window manager for X.\n"), progname);
104    printf (_("Usage: %s [OPTION]... \n"), progname);          printf (_("Usage: %s [OPTION]... \n"), progname);
105    printf (_("Options:\n"          printf (_("Options:\n"
106              "  -r, --file=FILE            use an alternative rcfile\n"                                                  "  -r, --file=FILE            use an alternative rcfile\n"
107              "                             instead of $HOME/.oroborusrc\n"                                                  "                             instead of $HOME/.oroborusrc\n"
108              "  -v, --verbose              print more information\n"                                                  "  -v, --verbose              print more information\n"
109              "  -h, --help                 display this help and exit\n"                                                  "  -h, --help                 display this help and exit\n"
110              "  -V, --version              output version information and exit\n"                                                  "  -V, --version              output version information and exit\n"
111              "  --display                  use an alternative display instead of,\n"                                                  "  --display                  use an alternative display instead of,\n"
112              "                             $DISPLAY\n"));                                                  "                             $DISPLAY\n"));
113    exit (status);          exit (status);
114  }  }
115    
116  int  int
117  decode_switches (int argc, char **argv)  decode_switches (int argc, char **argv)
118  {  {
119    int c;          int c;
120    
121    while ((c = getopt_long (argc, argv, "v"      /* verbose */          while ((c = getopt_long (argc, argv, "v"        /* verbose */
122                             "h"  /* help */                                                                                                           "h"    /* help */
123                             "V"  /* version */                                                                                                           "V"    /* version */
124                             "f:" /* file */                                                                                                           "f:"   /* file */
125                             "d:",        /* display */                                                                                                           "d:",  /* display */
126                             long_options, (int *) 0)) != EOF)                                                                                                           long_options, (int *) 0)) != EOF)
127      {                  {
128        switch (c)                          switch (c)
129          {                                  {
130          case 'd':               /* --quit-menu */                                  case 'd':                                                       /* --quit-menu */
131            display = optarg;                                          display = optarg;
132            break;                                          break;
133          case 'v':               /* --verbose */                                  case 'v':                                                       /* --verbose */
134            want_verbose = 1;                                          want_verbose = 1;
135            break;                                          break;
136          case 'f':               /* --file */                                  case 'f':                                                       /* --file */
137            rcfile = optarg;                                          rcfile = optarg;
138            break;                                          break;
139          case 'V':                                  case 'V':
140            printf ("%s %s\n", PACKAGE, VERSION);                                          printf ("%s %s\n", PACKAGE, VERSION);
141            exit (0);                                          exit (0);
142          case 'h':                                  case 'h':
143            usage (0);                                          usage (0);
144          default:                                  default:
145            usage (EXIT_FAILURE);                                          usage (EXIT_FAILURE);
146          }                                  }
147      }                  }
148    return optind;          return optind;
149  }  }
150    
151  void  void
152  initialize (int argc, char **argv)  initialize (int argc, char **argv)
153  {  {
154    struct sigaction act;          struct sigaction act;
155    char *locale = "";          char *locale = "";
156    int dummy;          int dummy;
157    
158  #ifdef DEBUG  #ifdef DEBUG
159    printf ("entering initialize\n");          printf ("entering initialize\n");
160  #endif  #endif
161    
162    progname = argv[0];          progname = argv[0];
163    
164    decode_switches (argc, argv);          decode_switches (argc, argv);
165    
166    printf          printf
167      ("\nOroborus\n(c) 2001 Ken Lynch\n(c) 2002 Stefan Pfetzing\nDistributed under the terms and conditions of the GPL\n\n");                  ("\nOroborus\n(c) 2001 Ken Lynch\n(c) 2002 Stefan Pfetzing\nDistributed under the terms and conditions of the GPL\n\n");
168    
169    locale = setlocale (LC_ALL, "");          locale = setlocale (LC_ALL, "");
170    
171    stat_argv = argv;          stat_argv = argv;
172    
173    if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX") ||          if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX") ||
174        !XSupportsLocale ())                          !XSupportsLocale ())
175      use_fontset = False;                  use_fontset = False;
176    else          else
177      use_fontset = True;                  use_fontset = True;
178    
179    dpy = XOpenDisplay (display);          dpy = XOpenDisplay (display);
180    if (!dpy)          if (!dpy)
181      {                  {
182        fprintf (stderr, "%s: failed to open display %s!\n", progname,                          fprintf (stderr, "%s: failed to open display %s!\n", progname,
183                 display ? display : getenv ("DISPLAY"));                                                           display ? display : getenv ("DISPLAY"));
184        exit (1);                          exit (1);
185      }                  }
186    
187    act.sa_handler = handleSignal;          act.sa_handler = handleSignal;
188    act.sa_flags = 0;          act.sa_flags = 0;
189    if (sigaction (SIGINT, &act, NULL))          if (sigaction (SIGINT, &act, NULL))
190      fprintf (stderr, "%s: Warning, could not install SIGINT Handler!\n",                  fprintf (stderr, "%s: Warning, could not install SIGINT Handler!\n",
191               progname);                                                   progname);
192    if (sigaction (SIGTERM, &act, NULL))          if (sigaction (SIGTERM, &act, NULL))
193      fprintf (stderr, "%s: Warning, could not install SIGTERM Handler!\n",                  fprintf (stderr, "%s: Warning, could not install SIGTERM Handler!\n",
194               progname);                                                   progname);
195    if (sigaction (SIGHUP, &act, NULL))          if (sigaction (SIGHUP, &act, NULL))
196      fprintf (stderr, "%s: Warning, could not install SIGHUP Handler!\n",                  fprintf (stderr, "%s: Warning, could not install SIGHUP Handler!\n",
197               progname);                                                   progname);
198    if (sigaction (SIGSEGV, &act, NULL))          if (sigaction (SIGSEGV, &act, NULL))
199      fprintf (stderr, "%s: Warning, could not install SIGSEGV Handler!\n",                  fprintf (stderr, "%s: Warning, could not install SIGSEGV Handler!\n",
200               progname);                                                   progname);
201    if (sigaction (SIGCHLD, &act, NULL))          if (sigaction (SIGCHLD, &act, NULL))
202      fprintf (stderr, "%s: Warning, could not install SIGCHLD Handler!\n",                  fprintf (stderr, "%s: Warning, could not install SIGCHLD Handler!\n",
203               progname);                                                   progname);
204    
205    root = XDefaultRootWindow (dpy);          root = XDefaultRootWindow (dpy);
206    screen = XDefaultScreen (dpy);          screen = XDefaultScreen (dpy);
207    depth = DefaultDepth (dpy, screen);          depth = DefaultDepth (dpy, screen);
208    cmap = DefaultColormap (dpy, screen);          cmap = DefaultColormap (dpy, screen);
209    
210    XSetErrorHandler (handleXError);          XSetErrorHandler (handleXError);
211    XSelectInput (dpy, root,          XSelectInput (dpy, root,
212                  SubstructureNotifyMask | SubstructureRedirectMask |                                                                  SubstructureNotifyMask | SubstructureRedirectMask |
213                  ButtonPressMask | ButtonReleaseMask | FocusChangeMask |                                                                  ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
214                  PropertyChangeMask);                                                                  PropertyChangeMask);
215    
216    shape = XShapeQueryExtension (dpy, &shape_event, &dummy);          shape = XShapeQueryExtension (dpy, &shape_event, &dummy);
217    
218    initHints (dpy);          initHints (dpy);
219    gnome_win = XCreateSimpleWindow (dpy, root, -1000, -1000, 5, 5, 0, 0, 0);          gnome_win = XCreateSimpleWindow (dpy, root, -1000, -1000, 5, 5, 0, 0, 0);
220    setGnomeHint (root, win_supporting_wm_check, gnome_win);          setGnomeHint (root, win_supporting_wm_check, gnome_win);
221    setGnomeHint (gnome_win, win_supporting_wm_check, gnome_win);          setGnomeHint (gnome_win, win_supporting_wm_check, gnome_win);
222    setSupportingWmCheck (root, gnome_win);          setSupportingWmCheck (root, gnome_win);
223    setSupportingWmCheck (gnome_win, gnome_win);          setSupportingWmCheck (gnome_win, gnome_win);
224    setGnomeHint (root, win_desktop_button_proxy, gnome_win);          setGnomeHint (root, win_desktop_button_proxy, gnome_win);
225    setGnomeHint (gnome_win, win_desktop_button_proxy, gnome_win);          setGnomeHint (gnome_win, win_desktop_button_proxy, gnome_win);
226    getGnomeHint (root, win_workspace, &workspace);          getGnomeHint (root, win_workspace, &workspace);
227    getGnomeDesktopMargins (margins);          getGnomeDesktopMargins (margins);
228    
229    root_cursor = XCreateFontCursor (dpy, XC_left_ptr);          root_cursor = XCreateFontCursor (dpy, XC_left_ptr);
230    move_cursor = XCreateFontCursor (dpy, XC_fleur);          move_cursor = XCreateFontCursor (dpy, XC_fleur);
231    resize_cursor[CORNER_TOP_LEFT] =          resize_cursor[CORNER_TOP_LEFT] =
232      XCreateFontCursor (dpy, XC_top_left_corner);                  XCreateFontCursor (dpy, XC_top_left_corner);
233    resize_cursor[CORNER_TOP_RIGHT] =          resize_cursor[CORNER_TOP_RIGHT] =
234      XCreateFontCursor (dpy, XC_top_right_corner);                  XCreateFontCursor (dpy, XC_top_right_corner);
235    resize_cursor[CORNER_BOTTOM_LEFT] =          resize_cursor[CORNER_BOTTOM_LEFT] =
236      XCreateFontCursor (dpy, XC_bottom_left_corner);                  XCreateFontCursor (dpy, XC_bottom_left_corner);
237    resize_cursor[CORNER_BOTTOM_RIGHT] =          resize_cursor[CORNER_BOTTOM_RIGHT] =
238      XCreateFontCursor (dpy, XC_bottom_right_corner);                  XCreateFontCursor (dpy, XC_bottom_right_corner);
239    XDefineCursor (dpy, root, root_cursor);          XDefineCursor (dpy, root, root_cursor);
240    
241    init_keyboard (dpy);          init_keyboard (dpy);
242    
243    loadSettings ();          loadSettings ();
244    
245    setNetWorkarea (margins, workspace_count);          setNetWorkarea (margins, workspace_count);
246    
247    clientFrameAll ();          clientFrameAll ();
248    
249    XMapWindow (dpy, gnome_win);          XMapWindow (dpy, gnome_win);
250    XSetInputFocus (dpy, gnome_win, RevertToNone, CurrentTime);          XSetInputFocus (dpy, gnome_win, RevertToNone, CurrentTime);
251  }  }
252    
253  int  int
254  main (int argc, char **argv)  main (int argc, char **argv)
255  {  {
256    initialize (argc, argv);          initialize (argc, argv);
257    eventLoop ();          eventLoop ();
258    cleanUp ();          cleanUp ();
259    return 0;          return 0;
260  }  }
261    
262  /* vim600:set foldmarker={{{,}}} foldmethod=marker: */  /* vim600:set foldmarker={{{,}}} foldmethod=marker: */
263    
264  /**This must remain at the end of the file.**********  /**This must remain at the end of the file.**********
265   * vim600:set sw=2 ts=8:                            *   * vim600:set sw=2 ts=2:                            *
266   * vim600:set cindent cinoptions={1s,>2s,^-1s,n-1s: *   * vim600:set cindent cinoptions={1s,>2s,^-1s,n-1s: *
267   * vim600:set foldmethod=marker:                    *   * vim600:set foldmethod=marker:                    *
268   ****************************************************/   ****************************************************/

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26