- changing MaxInstructions to 100 for cthulhain (crazy nut) =:)
[bbkeys.git] / src / Basewindow.cc
blobecb8f71c80e4e46162b3700e8e90488d6a069ec3
1 // Basewindow.cc for bbtools.
2 //
3 // Copyright (c) 1998-1999 by John Kennis, jkennis@chello.nl
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 // (See the included file COPYING / GPL-2.0)
21 // $Id$
23 #include "Basewindow.hh"
24 #include "resource.hh"
26 #ifdef HAVE_SIGNAL_H
27 # include <signal.h>
28 #endif // HAVE_SIGNAL_H
30 #ifdef HAVE_CONFIG_H
31 # include "../config.h"
32 #endif // HAVE_CONFIG_H
34 #ifdef HAVE_SYS_SIGNAL_H
35 # include <sys/signal.h>
36 #endif // HAVE_SYS_SIGNAL_H
38 #ifndef SA_NODEFER
39 # ifdef SA_INTERRUPT
40 # define SA_NODEFER SA_INTERRUPT
41 # else // !SA_INTERRUPT
42 # define SA_NODEFER (0)
43 # endif // SA_INTERRUPT
44 #endif // SA_NODEFER
47 static int handleXErrors(Display *, XErrorEvent *);
49 Basewindow::Basewindow(int argc,char **argv,struct CMDOPTIONS *options)
50 : BaseDisplay(argv[0], options->display_name) {
51 iargc=argc;
52 iargv=argv;
53 config_filename=NULL;
54 position=options->geometry;
55 withdrawn=options->withdrawn;
56 iconic=options->iconic;
57 noQt=options->noQt;
58 miniMe=options->miniMe;
59 tinyMe=options->tinyMe;
60 shape=options->shape;
61 decorated=options->decorated;
62 config_file=options->config_file;
63 nobb_config=options->nobb_config;
64 current_screen_info = getScreenInfo(DefaultScreen(getXDisplay()));
65 XSetErrorHandler((XErrorHandler) handleXErrors);
67 wm_delete_window = XInternAtom (getXDisplay(), "WM_DELETE_WINDOW",False);
70 Basewindow::~Basewindow() {}
72 void Basewindow::process_event(XEvent *event)
76 Bool Basewindow::handleSignal(int sig) {
77 switch (sig) {
78 case SIGHUP:
79 reconfigure();
80 break;
82 case SIGSEGV:
83 case SIGFPE:
84 case SIGINT:
85 case SIGTERM:
86 shutdown();
88 default:
89 return False;
92 return True;
95 void Basewindow::setupImageControl() {
96 image_control = new BImageControl(this,getCurrentScreenInfo(),image_dither,
97 colors_per_channel);
98 image_control->installRootColormap();
102 // X error handler to handle any and all X errors while blackbox is running
103 static int handleXErrors(Display *d, XErrorEvent *e) {
104 #ifdef DEBUG
105 char errtxt[128];
106 XGetErrorText(d, e->error_code, errtxt, 128);
107 fprintf(stderr,
108 "bbkeys: [ X Error event received. ]\n"
109 " X Error of failed request: %d %s\n"
110 " Major/minor opcode of failed request: %d / %d\n"
111 " Resource id in failed request: 0x%lx\n", e->error_code, errtxt,
112 e->request_code, e->minor_code, e->resourceid);
113 #endif
114 return(False);