~ubuntu-branches/ubuntu/trusty/miwm/trusty

« back to all changes in this revision

Viewing changes to error.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jari Aalto
  • Date: 2010-01-04 15:25:34 UTC
  • Revision ID: james.westby@ubuntu.com-20100104152534-l3fdvt162le460cv
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-*- c++ -*-
 
2
// -------------------------------------------
 
3
// RCS data:
 
4
// $Date: 2003/06/23 14:47:22 $
 
5
// $Revision: 1.1.1.1 $
 
6
// $Source: /cvsroot/miwm/miwm/miwm/error.cc,v $
 
7
// $Id: error.cc,v 1.1.1.1 2003/06/23 14:47:22 bwise837 Exp $
 
8
// $RCSfile: error.cc,v $
 
9
// -------------------------------------------
 
10
// Copyright by Ben Paul Wise.
 
11
// -------------------------------------------
 
12
// This program is free software; you can redistribute it and/or modify
 
13
// it under the terms of the GNU General Public License as published by
 
14
// the Free Software Foundation; either version 2 of the License, or
 
15
// (at your option) any later version.
 
16
// 
 
17
// This program is distributed in the hope that it will be useful,
 
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
// GNU General Public License for more details.
 
21
// 
 
22
// You should have received a copy of the GNU General Public License
 
23
// along with this program; if not, write to the Free Software
 
24
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
25
// -------------------------------------------
 
26
 
 
27
#include        <stdio.h>
 
28
#include        <stdlib.h>
 
29
 
 
30
#include        <X11/X.h>
 
31
#include        <X11/Xlib.h>
 
32
#include        <X11/Xutil.h>
 
33
#include        <X11/Xproto.h>
 
34
 
 
35
#include        "miwm.h"
 
36
 
 
37
int ignore_badwindow;
 
38
 
 
39
void
 
40
miAbort(char *s)
 
41
{
 
42
  fprintf(stderr, "%s: %s\n", argv0, s);
 
43
  cout << endl;
 
44
  cout << "Terminating MIWM at ";
 
45
  cout << __TIME__<<", "<<__DATE__<<endl<<flush;
 
46
 
 
47
  StopMemoryLeakCheck();
 
48
 
 
49
  exit(EXIT_FAILURE);
 
50
}
 
51
 
 
52
int
 
53
ErrorHandler(Display *d, XErrorEvent *e)
 
54
{
 
55
  char  msg[80];
 
56
  char  req[80];
 
57
  char  number[80];
 
58
 
 
59
  if (theWM->mode == wmStartup &&
 
60
      e->request_code == X_ChangeWindowAttributes &&
 
61
      e->error_code == BadAccess)
 
62
    miAbort("another window manager is already running.");
 
63
 
 
64
  if (ignore_badwindow &&
 
65
      (e->error_code == BadWindow || e->error_code == BadColor))
 
66
    return 0;
 
67
 
 
68
  XGetErrorText(d, e->error_code, msg, sizeof(msg));
 
69
  sprintf(number, "%d", e->request_code);
 
70
  XGetErrorDatabaseText(d, "XRequest", number, number, req, sizeof(req));
 
71
 
 
72
  fprintf(stderr, "%s: protocol request %s on resource %#x failed: %s\n\n",
 
73
          argv0, req, (unsigned int) e->resourceid, msg);
 
74
 
 
75
  if (theWM->mode == wmStartup)
 
76
    miAbort("Failed during initialization.");
 
77
 
 
78
  return 0;
 
79
}
 
80
 
 
81
// -------------------------------------------
 
82
// end of error.cc
 
83
// -------------------------------------------