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

« back to all changes in this revision

Viewing changes to disp.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/disp.cc,v $
 
7
// $Id: disp.cc,v 1.1.1.1 2003/06/23 14:47:22 bwise837 Exp $
 
8
// $RCSfile: disp.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        <X11/X.h>
 
28
#include        <X11/Xlib.h>
 
29
#include        <X11/Xutil.h>
 
30
#include        <X11/Xos.h>
 
31
#include        <X11/Xresource.h>
 
32
#include        <X11/Xatom.h>
 
33
 
 
34
#include        <stdio.h>
 
35
#include        <stdlib.h>
 
36
 
 
37
#include        "miwm.h"
 
38
#include        "mimenu.h"
 
39
#include        "ws.h"
 
40
 
 
41
//    Dispatcher for main event loop.
 
42
 
 
43
typedef struct Disp Disp;
 
44
struct Disp {
 
45
  int   type;
 
46
  void  (*handler)(XEvent *);
 
47
};
 
48
 
 
49
void logXEvents (XEvent *ev);
 
50
 
 
51
// comment these out to limit functionality
 
52
void buttonpress(XEvent *);
 
53
void buttonrelease(XEvent *);
 
54
void motionnotify(XEvent *);
 
55
 
 
56
void expose(XEvent *);
 
57
void maprequest(XEvent *);
 
58
void configurereq(XEvent *);
 
59
void unmap(XEvent *);
 
60
void destroy(XEvent *);
 
61
void clientmessage(XEvent *);
 
62
void colormap(XEvent *);
 
63
void property(XEvent *);
 
64
void reparent(XEvent *);
 
65
void enter(XEvent *);
 
66
void expose(XEvent *);
 
67
 
 
68
void leave(XEvent *);
 
69
void keypress(XEvent *);
 
70
void keyrelease(XEvent *);
 
71
 
 
72
// void motionnotifyMoving(XEvent*);
 
73
// void motionnotifyResizing(XEvent*);
 
74
void reshaping_motionnotify(XEvent*);
 
75
 
 
76
static Disp disps[] =
 
77
{
 
78
  {Expose, expose},
 
79
  {MapRequest, maprequest},
 
80
  {ConfigureRequest, configurereq},
 
81
  {UnmapNotify, unmap},
 
82
  {DestroyNotify, destroy},
 
83
  {ClientMessage, clientmessage},
 
84
  {ColormapNotify, colormap},
 
85
  {PropertyNotify, property},
 
86
  {ReparentNotify, reparent},
 
87
  {EnterNotify, enter},
 
88
 
 
89
// comment these out to limit functionality
 
90
  {MotionNotify, motionnotify},
 
91
  {ButtonPress, buttonpress},
 
92
  {ButtonRelease, buttonrelease},
 
93
 
 
94
 
 
95
  {LeaveNotify, 0},
 
96
  {CirculateRequest, 0},
 
97
  {ConfigureNotify, 0},
 
98
  {CreateNotify, 0},
 
99
  {GravityNotify, 0},
 
100
  {MapNotify, 0},
 
101
  {MappingNotify, 0},
 
102
  {SelectionClear, 0},
 
103
  {SelectionNotify, 0},
 
104
  {SelectionRequest, 0},
 
105
  {NoExpose, 0},
 
106
};
 
107
 
 
108
 void
 
109
dispatch(XEvent *ev)
 
110
{
 
111
  Disp *p;
 
112
 
 
113
#ifdef MIWM_TRACE_ALL_X_EVENTS
 
114
  logXEvents(ev);
 
115
#endif
 
116
 
 
117
 
 
118
  for (p = disps; p < disps + sizeof disps / sizeof disps[0]; p++) {
 
119
    if (p->type == ev->type) {
 
120
      if (p->handler != 0)
 
121
        p->handler(ev); // purify says this is a leak?!
 
122
      return;
 
123
    }
 
124
  }
 
125
 
 
126
  if (!shapeevent(ev))
 
127
    fprintf(stderr, "%s: unknown event %d\n", argv0, ev->type);
 
128
}
 
129
 
 
130
void
 
131
logXEvents (XEvent *ev) {
 
132
 
 
133
  cout <<  "<";
 
134
  switch (ev->type) {
 
135
  case ButtonPress:
 
136
    cout <<  "ButtonPress"; break;
 
137
  case ButtonRelease:
 
138
    cout <<  "ButtonRelease"; break;
 
139
  case MapRequest:
 
140
    cout <<  "MapRequest"; break;
 
141
  case ConfigureRequest:
 
142
    cout <<  "ConfigureRequest"; break;
 
143
  case UnmapNotify:
 
144
    cout <<  "UnmapNotify"; break;
 
145
  case DestroyNotify:
 
146
    cout <<  "DestroyNotify"; break;
 
147
  case ClientMessage:
 
148
    cout <<  "ClientMessage"; break;
 
149
  case ColormapNotify:
 
150
    cout <<  "ColormapNotify"; break;
 
151
  case PropertyNotify:
 
152
    cout <<  "PropertyNotify"; break;
 
153
  case ReparentNotify:
 
154
    cout <<  "ReparentNotify"; break;
 
155
  case EnterNotify:
 
156
    cout <<  "EnterNotify"; break;
 
157
  case LeaveNotify:
 
158
    cout <<  "LeaveNotify"; break;
 
159
  case Expose:
 
160
    // too frequent to post, usually!
 
161
    cout <<  "Expose"; break;
 
162
  case MotionNotify:
 
163
    // too frequent to post, usually!
 
164
    cout <<  "MotionNotify"; break;
 
165
    break;
 
166
  case CirculateRequest:
 
167
    cout <<  "CirculateRequest"; break;
 
168
  case ConfigureNotify:
 
169
    cout <<  "ConfigureNotify"; break;
 
170
  case CreateNotify:
 
171
    cout <<  "CreateNotify"; break;
 
172
  case GravityNotify:
 
173
    cout <<  "GravityNotify"; break;
 
174
  case MapNotify:
 
175
    cout <<  "MapNotify"; break;
 
176
  case MappingNotify:
 
177
    cout <<  "MappingNotify"; break;
 
178
  case SelectionClear:
 
179
    cout <<  "SelectionClear"; break;
 
180
  case SelectionNotify:
 
181
    cout <<  "SelectionNotify"; break;
 
182
  case SelectionRequest:
 
183
    cout <<  "SelectionRequest"; break;
 
184
  default:
 
185
    cout <<  "unknown event type " << ev->type;
 
186
}
 
187
cout <<  ">\n"  << flush;
 
188
return;
 
189
}
 
190
 
 
191
void
 
192
expose(XEvent *ev) {
 
193
  Client *c;
 
194
  Window w;     // Window the expose event is for.
 
195
 
 
196
  if (ev->xexpose.count != 0) return;
 
197
 
 
198
  w = ev->xexpose.window;
 
199
 
 
200
  // We don't draw on the root window (yet)
 
201
  if (w == root) return;
 
202
 
 
203
  // Decide what needs redrawing: window frame or menu?
 
204
  if (w == popup) {
 
205
    switch (theWM->mode) {
 
206
 
 
207
    case wmMenuing:
 
208
      theWM->menu->expose();
 
209
      break;
 
210
 
 
211
    case wmMoving:
 
212
      theWM->positionExpose();
 
213
      break;
 
214
 
 
215
    case wmResizing:
 
216
      theWM->sizeExpose();
 
217
      break;
 
218
 
 
219
    default:
 
220
      break;
 
221
    }
 
222
  } 
 
223
  else {
 
224
    c = getClient(w);
 
225
//     cout << "Exposing Client " << c->clientID << endl << flush;
 
226
//     XSync(dpy, False);
 
227
    if (c != 0) {
 
228
      theWM->drawClientBorder(c, c == current);
 
229
    }
 
230
  }
 
231
  return;
 
232
}
 
233
 
 
234
int
 
235
WindowManager::titleHeightc(Client *c)
 
236
{
 
237
 if (c->accepts_focus && c->name) 
 
238
   return titleHeight();
 
239
 else
 
240
   return 0;
 
241
}
 
242
 
 
243
void
 
244
keypress(XEvent *) {
 
245
  // do nothing, yet
 
246
}
 
247
 
 
248
void
 
249
keyrelease(XEvent *) {
 
250
  // do nothing, yet
 
251
}
 
252
 
 
253
// -------------------------------------------
 
254
// these are the big three: press button, move, release
 
255
// -------------------------------------------
 
256
 
 
257
// this should be a dispatch table on (location, button, modifiers)
 
258
// pointing at fn(Client*, XEvent*)
 
259
void
 
260
buttonpress(XEvent *ev) {
 
261
  Client *c;
 
262
  XButtonEvent *e = &ev->xbutton;
 
263
//   int quarter;
 
264
 
 
265
  if (theWM->mode != wmReady) return;
 
266
 
 
267
  c = getClient(e->window);
 
268
 
 
269
  // =================================================
 
270
  // FRAME button presses
 
271
  // =================================================
 
272
 
 
273
  if (c && (e->window == c->parent))   {    // click on frame around a client.
 
274
//     cout << "Frame button press"<<endl;
 
275
    theWM->focusOn(c);
 
276
    switch (e->button) {
 
277
  
 
278
    case Button3:   // hide client
 
279
      if (e->state & ControlMask) {
 
280
        if (theWM->mouseInDeadlyBox(current)) {
 
281
          theWM->mode = wmKilling;
 
282
          theWM->startKillingClient(e, c);
 
283
        }
 
284
        else { // raise client ops menu
 
285
          theWM->mode = wmMenuing;
 
286
          theWM->setClientOpsMenu();
 
287
          theWM->menu->startMenuing(e);
 
288
        }
 
289
      }
 
290
      else {
 
291
        hide(c);
 
292
      }
 
293
      break;
 
294
 
 
295
    case Button2: // start moving client on screen or between WS
 
296
      if (e->state & ControlMask) {
 
297
        // raise WS menu 
 
298
        theWM->mode = wmMenuing;
 
299
        theWM->setWSMenu();
 
300
        if (e->state & ShiftMask) {
 
301
          // follow client to new WS
 
302
          theWM->followClientToWS = 1;
 
303
        }
 
304
        theWM->whichMenu = sendCtoWSMenu;
 
305
        theWM->menu->startMenuing(e);
 
306
      }
 
307
      else {
 
308
        theWM->mode = wmMoving;
 
309
        theWM->startMovingClient(ev, c);
 
310
      }
 
311
       break;
 
312
 
 
313
    case Button1:
 
314
      if (e->state & ControlMask)
 
315
        theWM->backClient(c);  
 
316
      else {
 
317
        theWM->mode = wmResizing;
 
318
        theWM->startResizingClient(e, c);
 
319
      }
 
320
      break;
 
321
 
 
322
    default:
 
323
      break;
 
324
    }
 
325
  } // end of clicks on border
 
326
 
 
327
  // =================================================
 
328
  // ROOT button presses
 
329
  // =================================================
 
330
  if (e->window == root) {
 
331
//      cout << "Root button press"<<endl;
 
332
//       XChangeActivePointerGrab(dpy, 
 
333
//                             theWM->moving_event_mask, 
 
334
//                             root_cursor, CurrentTime);
 
335
    switch  (e->button) {
 
336
 
 
337
    case Button1:
 
338
//       cout << "Trying to raise topclient = " << theWM->workSpace->topClient << endl << flush;
 
339
//       if (theWM->workSpace->topClient != NULL) {
 
340
//      cout << "  named " << choose_label(theWM->workSpace->topClient) << endl;
 
341
//      theWM->raiseClient(theWM->workSpace->topClient );
 
342
//      theWM->focusOn(theWM->workSpace->topClient);
 
343
//       }
 
344
      // raise command menu
 
345
      theWM->mode = wmMenuing;
 
346
      theWM->setShellCmdMenu();
 
347
      theWM->menu->startMenuing(e);
 
348
      break;
 
349
 
 
350
    case Button2:
 
351
      // if ctrl-Button2, skip 
 
352
      if (e->state & ControlMask) {
 
353
        if (e->state & ShiftMask) 
 
354
          // skip back
 
355
          stepWS(-1);
 
356
        else
 
357
          // skip forward
 
358
          stepWS(+1);
 
359
      }
 
360
      else { // raise WS menu 
 
361
      theWM->mode = wmMenuing;
 
362
      theWM->setWSMenu();
 
363
      theWM->whichMenu = changeWSMenu;
 
364
      theWM->menu->startMenuing(e);
 
365
      }
 
366
      break;
 
367
 
 
368
    case Button3:
 
369
      if (e->state & ControlMask) {
 
370
      theWM->mode = wmMenuing;
 
371
      theWM->setWMOpsMenu();
 
372
      theWM->menu->startMenuing(e);
 
373
      }
 
374
      else {
 
375
      // raise hidden client menu
 
376
      theWM->mode = wmMenuing;
 
377
      theWM->setHiddenClientMenu();
 
378
      theWM->menu->startMenuing(e);
 
379
      }
 
380
      break;
 
381
 
 
382
    default:
 
383
      break;
 
384
    }
 
385
  }  // end of root button clicks
 
386
  return;
 
387
}
 
388
 
 
389
void
 
390
motionnotify(XEvent *ev) {
 
391
  switch (theWM->mode) {
 
392
 
 
393
  case wmResizing: 
 
394
    theWM->motionNotifyResizing();
 
395
    break;
 
396
 
 
397
  case wmKilling: 
 
398
    theWM->motionNotifyKilling();
 
399
    break;
 
400
 
 
401
  case wmMoving: 
 
402
//     cout << "Moving" << endl << flush;
 
403
    theWM->motionNotifyMoving();
 
404
    break;
 
405
 
 
406
  case wmMenuing: 
 
407
    theWM->menu->motionNotify(ev);
 
408
    break;
 
409
 
 
410
  default:
 
411
    // do nothing!
 
412
    break;
 
413
  }
 
414
  return;
 
415
}
 
416
 
 
417
 
 
418
 
 
419
 
 
420
void
 
421
buttonrelease(XEvent *ev) {
 
422
//     cout << "Button release"<<endl;
 
423
   switch (theWM->mode) {
 
424
 
 
425
   case wmMenuing:
 
426
//       cout << "Stop menuing" << endl << flush;
 
427
 
 
428
     theWM->menu->buttonRelease();
 
429
     break;
 
430
 
 
431
   case wmResizing:
 
432
     theWM->buttonReleaseResizing();
 
433
     break;
 
434
 
 
435
   case wmMoving:
 
436
     theWM->buttonReleaseMoving();
 
437
     break;
 
438
 
 
439
   case wmKilling:
 
440
     theWM->buttonReleaseKilling();
 
441
     break;
 
442
 
 
443
   default:
 
444
     break;
 
445
   }
 
446
 
 
447
   theWM->mode = wmReady;
 
448
   return;
 
449
 }
 
450
 
 
451
// -------------------------------------------
 
452
 
 
453
 
 
454
void maprequest(XEvent *ev) {
 
455
  Client *c;
 
456
  XMapRequestEvent      *e = &ev->xmaprequest;
 
457
 
 
458
  c = getClient(e->window);
 
459
 
 
460
  if (c == 0 || c->window != e->window) {
 
461
    cout << "Adding client in maprequest" << endl << flush;
 
462
    c = addClient(e->window);
 
463
    if (c == 0)
 
464
      return;
 
465
  }
 
466
 
 
467
  unhidec(c, 1);
 
468
 
 
469
  switch (c->state) {
 
470
  case WithdrawnState:
 
471
    if (c->parent == root) {
 
472
      theWM->manageClient(c);
 
473
      break;
 
474
    }
 
475
    XReparentWindow(dpy, c->window, c->parent, border, border);
 
476
    XAddToSaveSet(dpy, c->window);
 
477
    // fall through
 
478
  case NormalState:
 
479
    XMapRaised(dpy, c->parent);
 
480
    XMapWindow(dpy, c->window);
 
481
    c->isMapped = 1;
 
482
    setClientState(c, NormalState);
 
483
    break;
 
484
  }
 
485
}
 
486
 
 
487
void
 
488
unmap(XEvent *ev)
 
489
{
 
490
  Client *c;
 
491
  XUnmapEvent *e = &ev->xunmap;
 
492
 
 
493
  c = getClient(e->window);
 
494
  if (c == 0) return;
 
495
 
 
496
//  In the description of the ReparentWindow request we read: "If the window
 
497
//  is mapped, an UnmapWindow request is performed automatically first". This
 
498
//  might seem stupid, but it's the way it is. While a reparenting is pending
 
499
//  we ignore UnmapWindow requests.
 
500
 
 
501
  if (c->internal_state == IPendingReparenting) {
 
502
    c->internal_state = INormal;
 
503
    return;
 
504
  }
 
505
 
 
506
  if (c->state == IconicState) {
 
507
 
 
508
    //Is this a hidden window disappearing? If not, then we
 
509
    //are not interested because it's an unmap request caused
 
510
    //by our hiding a window.
 
511
 
 
512
    if (e->send_event)
 
513
      unhidec(c, 0); // It's a hidden window disappearing.
 
514
  } else {
 
515
  // This is a plain unmap, so withdraw the window.
 
516
    withdraw(c);
 
517
  }
 
518
 
 
519
  c->internal_state = INormal;
 
520
}
 
521
 
 
522
void
 
523
configurereq(XEvent *ev)
 
524
{
 
525
  XWindowChanges wc;
 
526
  Client *c;
 
527
  XConfigureRequestEvent *e = &ev->xconfigurerequest;
 
528
 
 
529
  c = getClient(e->window);
 
530
  if (c) {
 
531
    // ICCCM section 4.1.5 says that the x and y coordinates here
 
532
    //will have been "adjusted for the border width". 
 
533
    // NOTE: this may not be the only place to bear this in mind.
 
534
    if (e->value_mask & CWBorderWidth) {
 
535
      e->x -= e->border_width;
 
536
      e->y -= e->border_width;
 
537
    } else {
 
538
      // The ICCCM also says that clients should always set the
 
539
      //border width in a configure request. As usual, many don't.
 
540
      e->x--;
 
541
      e->y--;
 
542
    }
 
543
 
 
544
    if (e->value_mask & CWX)
 
545
      c->size.x = e->x;
 
546
    if (e->value_mask & CWY)
 
547
      c->size.y = e->y;
 
548
    if (e->value_mask & CWWidth)
 
549
      c->size.width = e->width + 2 * border;
 
550
    if (e->value_mask & CWHeight)
 
551
      c->size.height = e->height + 2 * border;
 
552
    if (e->value_mask & CWBorderWidth)
 
553
      c->border = e->border_width;
 
554
 
 
555
    if (c->parent != root && c->window == e->window) {
 
556
      wc.x = c->size.x;
 
557
      wc.y = c->size.y;
 
558
      wc.width = c->size.width;
 
559
      wc.height = c->size.height;
 
560
      if (c == current) {
 
561
        wc.y -= titleHeight();
 
562
        wc.height += titleHeight();
 
563
      }
 
564
      wc.border_width = 1;
 
565
      wc.sibling = e->above;
 
566
      wc.stack_mode = e->detail;
 
567
      XConfigureWindow(dpy, e->parent, e->value_mask, &wc);
 
568
      sendConfigureNotify(c);
 
569
    }
 
570
  }
 
571
  if (c && (c->internal_state == INormal)) {
 
572
    wc.x = border;
 
573
    wc.y = border;
 
574
  } else {
 
575
    wc.x = e->x;
 
576
    wc.y = e->y;
 
577
  }
 
578
  wc.width = e->width;
 
579
  wc.height = e->height;
 
580
  wc.border_width = 0;
 
581
  wc.sibling = e->above;
 
582
  wc.stack_mode = e->detail;
 
583
  e->value_mask |= CWBorderWidth;
 
584
 
 
585
  if (c == current)
 
586
    wc.y += titleHeight();
 
587
 
 
588
  XConfigureWindow(dpy, e->window, e->value_mask, &wc);
 
589
}
 
590
 
 
591
void
 
592
destroy(XEvent *ev)
 
593
{
 
594
  Client        *c;
 
595
  Window        w = ev->xdestroywindow.window;
 
596
 
 
597
  c = getClient(w);
 
598
  if (c == 0)
 
599
    return;
 
600
 
 
601
  removeClient(c);
 
602
}
 
603
 
 
604
void
 
605
clientmessage(XEvent *ev)
 
606
{
 
607
  Client        *c;
 
608
  XClientMessageEvent   *e = &ev->xclient;
 
609
 
 
610
  if (e->message_type == wm_change_state) {
 
611
    c = getClient(e->window);
 
612
    if (c == 0) return;
 
613
    if (e->format == 32 && e->data.l[0] == IconicState && normal(c))
 
614
      hide(c);
 
615
    return;
 
616
  }
 
617
}
 
618
 
 
619
void
 
620
colormap(XEvent *ev)
 
621
{
 
622
//   Client     *c;
 
623
//   XColormapEvent     *e = &ev->xcolormap;
 
624
 
 
625
  // I commented this out as the 'new' keyword appeared to be confusing g++
 
626
  //   if (e->new) {
 
627
  //     c = getClient(e->window);
 
628
  //     if (c) {
 
629
  //       c->cmap = e->colormap;
 
630
  //       if (c == current)
 
631
  //    cmapfocus(c);
 
632
  //     } else
 
633
  //       Client_ColorMap(ev);
 
634
  //   }
 
635
 
 
636
}
 
637
 
 
638
void
 
639
property(XEvent * ev) {
 
640
  Client * c;
 
641
  XPropertyEvent * e = &ev->xproperty;
 
642
 
 
643
  c = getClient(e->window);
 
644
  if (c == 0)
 
645
    return;
 
646
 
 
647
  switch (e->atom) {
 
648
  case XA_WM_NAME:
 
649
    getWindowName(c);
 
650
    setactive(c, c == current, 0L);
 
651
    return;
 
652
  case XA_WM_TRANSIENT_FOR:
 
653
    getTransientFor(c);
 
654
    return;
 
655
  case XA_WM_NORMAL_HINTS:
 
656
    getNormalHints(c);
 
657
    return;
 
658
  default:
 
659
    if (e->atom == wm_colormaps) {
 
660
      getColormaps(c);
 
661
      if (c == current)
 
662
        cmapfocus(c);
 
663
    }
 
664
  }
 
665
}
 
666
 
 
667
void
 
668
reparent(XEvent *ev)
 
669
{
 
670
  Client        *c;
 
671
  XReparentEvent        *e = &ev->xreparent;
 
672
 
 
673
  if (e->event != root || e->override_redirect || e->parent == root)
 
674
    return;
 
675
 
 
676
  c = getClient(e->window);
 
677
  if (c != 0 && (c->parent == root || withdrawn(c)))
 
678
    removeClient(c);
 
679
}
 
680
 
 
681
void
 
682
leave(XEvent *) {
 
683
  // do nothing for now
 
684
  return;
 
685
}
 
686
 
 
687
 
 
688
void
 
689
enter(XEvent *ev) {
 
690
  if (wmReady ==theWM->mode) {
 
691
    Client *c;
 
692
    // it is possible for a client to die when you are
 
693
    // doing a menu operation (send to WS, toggle sticky, etc.)
 
694
    // in that case, we do NOT want to apply the operation
 
695
    // to the next client, so I allow change of focus
 
696
    // only if we are in wmReady mode.
 
697
    c = getClient(ev->xcrossing.window);
 
698
    if (c == 0)
 
699
      return;
 
700
 
 
701
    //   if (c != current && !c->hidden) {
 
702
    //     // Take focus away from current holder. 
 
703
    //     if (current)
 
704
    //       setactive(current, 0, 0L);
 
705
 
 
706
    //     // Give focus to new holder.
 
707
    //     current = c;
 
708
    //     setactive(current, 1, ev->xcrossing.time);
 
709
    //   }
 
710
    XSync(dpy, False);
 
711
    //   cout << "Entering Client " << c->clientID << endl << flush;
 
712
    if (1 == theWM->insideClientP(c))
 
713
      theWM->focusOn(c);
 
714
  }
 
715
  return;
 
716
}
 
717
 
 
718
void
 
719
WindowManager::focusOn(Client* c) {
 
720
  if (c == NULL)     { // de focus
 
721
    if (current)
 
722
      setactive(current,0,0L);
 
723
    current = NULL;
 
724
  }
 
725
 
 
726
  if (c != NULL)
 
727
    if (c != current && !c->hidden) {
 
728
      // Take focus away from current holder. 
 
729
      if (current)
 
730
        setactive(current, 0, 0L);
 
731
 
 
732
      if (1 == raiseOnFocusP)
 
733
        raiseClient(c);
 
734
 
 
735
      // Give focus to new holder.
 
736
      current = c;
 
737
      setactive(current, 1, CurrentTime);
 
738
    }
 
739
  return;
 
740
}
 
741
// void 
 
742
// motionnotifyMoving(XEvent*ev) {
 
743
// //   reshaping_motionnotify(ev);
 
744
 
 
745
// //     XChangeActivePointerGrab(dpy, theWM->moving_event_mask, 
 
746
// //                      root_cursor, CurrentTime);
 
747
 
 
748
//   cout << "motionnotifyMoving"<<endl << flush;
 
749
//   switch (mode) {
 
750
 
 
751
//   case wmResizing: 
 
752
//     break;
 
753
 
 
754
//   case wmMoving: 
 
755
//     theWM->drawClientOutline(current); // erase old one
 
756
 
 
757
 
 
758
 
 
759
//     break;
 
760
 
 
761
//   case wmMenuing: 
 
762
//     break;
 
763
//   }
 
764
//   return;
 
765
// } 
 
766
 
 
767
 
 
768
// void
 
769
// reshaping_motionnotify(XEvent*)  // parameter ev was unused
 
770
// {
 
771
//   int        nx;     /* New x. */
 
772
//   int        ny;     /* New y. */
 
773
//   int        ox;     /* Original x. */
 
774
//   int        oy;     /* Original y. */
 
775
//   int        ndx;    /* New width. */
 
776
//   int        ndy;    /* New height. */
 
777
//   int        odx;    /* Original width. */
 
778
//   int        ody;    /* Original height. */
 
779
//   int        pointer_x;
 
780
//   int        pointer_y;
 
781
//   int        yTitleAdjust;
 
782
 
 
783
//   if ((theWM->mode != wmResizing) || (mode != wmMoving))
 
784
//     return;
 
785
 
 
786
//   yTitleAdjust = (current->accepts_focus && current->name) ? titleHeight() : 0;
 
787
 
 
788
//   getMouse(&pointer_x, &pointer_y);
 
789
 
 
790
//   if (interacting_edge != ENone) {
 
791
//     nx = ox = current->size.x;
 
792
//     ny = oy = current->size.y;
 
793
//     ndx = odx = current->size.width;
 
794
//     ndy = ody = current->size.height;
 
795
                
 
796
//     Client_SizeFeedback();
 
797
 
 
798
//     /* Vertical. */
 
799
//     switch (interacting_edge) {
 
800
//     case ETop:
 
801
//     case ETopLeft:
 
802
//     case ETopRight:
 
803
//       ndy += (current->size.y - pointer_y);
 
804
//       ny = pointer_y;
 
805
//       break;
 
806
//     case EBottom:
 
807
//     case EBottomLeft:
 
808
//     case EBottomRight:
 
809
//       ndy = pointer_y - current->size.y;
 
810
//       break;
 
811
//     default: break;
 
812
//     }
 
813
 
 
814
//     /* Horizontal. */
 
815
//     switch (interacting_edge) {
 
816
//     case ERight:
 
817
//     case ETopRight:
 
818
//     case EBottomRight:
 
819
//       ndx = pointer_x - current->size.x;
 
820
//       break;
 
821
//     case ELeft:
 
822
//     case ETopLeft:
 
823
//     case EBottomLeft:
 
824
//       ndx += (current->size.x - pointer_x);
 
825
//       nx = pointer_x;
 
826
//       break;
 
827
//     default: break;
 
828
//     }
 
829
 
 
830
//     adjustClientBorder(current, interacting_edge, &nx, &ny, &ndx, &ndy);
 
831
//     XMoveResizeWindow(dpy, current->parent,
 
832
//                    current->size.x, current->size.y - yTitleAdjust,
 
833
//                    current->size.width, current->size.height + yTitleAdjust);
 
834
//     if (current->size.width == odx && current->size.height == ody) {
 
835
//       if (current->size.x != ox || current->size.y != oy)
 
836
//      sendConfigureNotify(current);
 
837
//     } else
 
838
//       XMoveResizeWindow(dpy, current->window, border, border + yTitleAdjust,
 
839
//                      current->size.width - 2 * border, current->size.height - 2 * border);
 
840
//   } // edge of reshaping section, edge != ENone
 
841
//   else 
 
842
//     { // bodily  move the client
 
843
//       nx = pointer_x + start_x;
 
844
//       ny = pointer_y + start_y;
 
845
 
 
846
//       adjustClientBorder(current, interacting_edge, &nx, &ny, 0, 0);
 
847
//       XMoveWindow(dpy, current->parent,
 
848
//                current->size.x, current->size.y - yTitleAdjust);
 
849
//       sendConfigureNotify(current);
 
850
//     }
 
851
// }
 
852
 
 
853
 
 
854
// -------------------------------------------
 
855
// end of disp.cc
 
856
// -------------------------------------------
 
857