~brandontschaefer/nux/xim-tests

« back to all changes in this revision

Viewing changes to NuxGraphics/XInputWindow.cpp

  • Committer: Brandon Schaefer
  • Date: 2012-08-20 18:24:40 UTC
  • Revision ID: brandontschaefer@gmail.com-20120820182440-8b04hwfzdw8z78m3
* Moved xim stuff into a class. Also each XInputWindow now makes its own XIMClient as it needs to set that up for it to work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "GraphicsDisplayX11.h"
24
24
#include "GLThread.h"
25
25
 
 
26
 
26
27
// Jay, what is this for?  It isn't referenced anywhere.
27
28
#define xdnd_version 5
28
29
 
36
37
    : strutsEnabled_(false)
37
38
    , overlayStrutsEnabled_(false)
38
39
    , display_(GetGraphicsDisplay()->GetX11Display())
 
40
    , xim_client_(NULL)
39
41
    , geometry_(0, 0, 1, 1)
40
42
    , shown_(false)
41
43
    , mapped_(false)
62
64
                            CopyFromParent, InputOutput, CopyFromParent,
63
65
                            CWOverrideRedirect | CWEventMask, &attrib);
64
66
 
 
67
    xim_client_ = new XIMClient(display_, window_);
 
68
 
65
69
    native_windows_.push_back(window_);
66
70
 
67
71
    Atom data[32];
93
97
 
94
98
  XInputWindow::~XInputWindow()
95
99
  {
 
100
    if (xim_client_)
 
101
      delete xim_client_;
 
102
 
96
103
    native_windows_.erase(std::find(native_windows_.begin(), native_windows_.end(), window_));
97
104
    XDestroyWindow(display_, window_);
98
105
  }
364
371
 
365
372
  void XInputWindow::Hide()
366
373
  {
 
374
    if (xim_client_)
 
375
    {
 
376
      GetGraphicsDisplay()->SetCurrentXIMClient(NULL);
 
377
      xim_client_->FocusOutXIC();
 
378
    }
 
379
 
367
380
    XMoveResizeWindow(display_, window_,
368
381
                      -100 - geometry_.width,
369
382
                      -100 - geometry_.height,
374
387
 
375
388
  void XInputWindow::Show()
376
389
  {
 
390
    if (xim_client_)
 
391
    {
 
392
      GetGraphicsDisplay()->SetCurrentXIMClient(xim_client_);
 
393
      xim_client_->FocusInXIC();
 
394
    }
 
395
 
377
396
    shown_ = true;
378
 
 
379
397
    if (!mapped_)
380
398
    {
381
399
      XMapRaised(display_, window_);