This file is indexed.

/usr/include/Nux-4.0/Nux/InputArea.h is in libnux-4.0-dev 4.0.8+17.10.20170922-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/*
 * Copyright 2010 Inalogic® Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License, as
 * published by the  Free Software Foundation; either version 2.1 or 3.0
 * of the License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of both the GNU Lesser General Public
 * License along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 *
 */


#ifndef INPUTAREA_H
#define INPUTAREA_H

#include "Area.h"

#if defined(NUX_OS_WINDOWS)
  #include "NuxGraphics/Events.h"
#elif defined(NUX_OS_LINUX)
  #include "NuxGraphics/Events.h"
#endif
#include "NuxGraphics/GraphicsDisplay.h"

#ifdef NUX_GESTURES_SUPPORT
#include <list>
#include <memory>
#include "Nux/GesturesSubscription.h"
#endif

namespace nux
{
#ifdef NUX_GESTURES_SUPPORT
  class GestureEvent;
#endif
  class WindowCompositor;
  class InputArea;

  typedef InputArea CoreArea;

  class InputArea : public Area
  {
  public:
    NUX_DECLARE_OBJECT_TYPE(InputArea, Area);
  public:
    InputArea(NUX_FILE_LINE_PROTO);
    virtual ~InputArea();

    //! Draw InputArea.
    /*!
        Draw a colored quad using m_AreaColor.
        Override this function to define a custom drawing function.
        If force_draw is true then the system requests that all objects redraw themselves completely.
        \param force_draw.
    */
    virtual void OnDraw(GraphicsEngine &graphics_engine, bool force_draw);

    virtual void OverlayDrawing(GraphicsEngine & /* graphics_engine */) {}

    bool HasKeyboardFocus();

    bool MouseFocusOnOtherArea();
    void CaptureMouseDownAnyWhereElse(bool b);
    bool IsCaptureMouseDownAnyWhereElse() const;

    Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
    Area* FindKeyFocusArea(unsigned int key_symbol,
                          unsigned long x11_key_code,
                          unsigned long special_keys_state);

    virtual bool AcceptKeyNavFocus() const;

    /*!
      Sets whether this InputArea wants to know about all mouse events
      sent to a child InputArea.

      ChildMouseEvent() will be called for every mouse event that a child
      InputArea receives.

      \param enable Whether this InputArea should be informed about child mouse
                    events
      \sa ChildMouseEvent(), IsTrackingChildMouseEvents()
     */
    void SetTrackChildMouseEvents(bool enable);

    /*!
      Returns whether this InputArea wants to be informed about child mouse events.

      This property is false by default.

      \sa SetTrackChildMouseEvents(), ChildMouseEvent()
     */
    bool IsTrackingChildMouseEvents() const;

    /*!
      Called when a mouse event is sent to a child InputArea.

      If you return true, mouse ownership will be moved to this InputArea and the
      child InputArea will receive a MOUSE_CANCEL event.

      If you return false, nothing happens and the child will keep its ownership
      over the mouse and therefore get further mouse events.

      The default implementation just returns false;

      \return Whether you want to take ownership over the mouse.
      \sa SetTrackChildMouseEvents
     */
    virtual bool ChildMouseEvent(const Event& event);

  protected:

  private:
    bool _dnd_enabled_as_source;
    bool _dnd_enabled_as_target;
  public:
    // Override the virtual methods from Object Base
    // Here, we get a change to update the text of the keyboard handler.
    void SetKeyboardReceiverIgnoreMouseDownOutside(bool ignore_mouse_down_outside);

    void SetAcceptKeyNavFocusOnMouseDown(bool accept);
    void SetAcceptKeyNavFocusOnMouseEnter(bool accept);

    bool KeyboardReceiverIgnoreMouseDownOutside();

    virtual bool IsArea() const
    {
      return true;
    }

    void GrabPointer();
    void GrabKeyboard();
    void UnGrabPointer();
    void UnGrabKeyboard();
    bool OwnsPointerGrab();
    bool OwnsKeyboardGrab();

    //! Return true if this Area is the owner of the mouse pointer.
    /*!
        The owner of the mouse pointer is the Area that has received a Mouse down event and the 
        mouse button responsible for the event is still pressed.
        
        @return True if this Area is the owner of the mouse pointer.
    */
    bool IsMouseOwner();

    //! Returns true if the mouse pointer has been determined as inside the this area, following event processing.
    /*!
        Returns true if during a call to FindAreaUnderMouse, this area has been determined to be directly under the
        mouse pointer. Note that this is true only for the first area that is found. There might be other areas that 
        which have the mouse pointer inside of them. \n
        Call Area::IsMousePointerInside to find out if the mouse pointer is inside an area.
        
        @return Return true if the mouse pointer is inside the Area.
    */
    bool IsMouseInside();

    //! Enable the double click event signal on this InputArea.
    void EnableDoubleClick(bool double_click);

    //! Returns true if the double click signal is enable for this InputArea.
    bool DoubleClickEnabled() const;

    bool mouse_in_;

#if defined(NUX_OS_LINUX)
    void HandleDndEnter() {ProcessDndEnter();}
    void HandleDndLeave() {ProcessDndLeave();}
#endif
  private:

    //! Event processing in exclusive mode.
    /*!
        Bypass OnEvent and performs a simplified event processing mechanism.
    */
    long ProcessEventInExclusiveMode(Event &event, long TraverseInfo, long ProcessEventInfo);

    void HandleDndMove  (Event &event);
    void HandleDndDrop  (Event &event);

    //! Color of the InputArea
    /*
        Color of the InputArea use to draw a colored quad when OnDraw() is called.
    */
    Color area_color_;
    
    int _dnd_safety_x;
    int _dnd_safety_y;

  protected:
    bool _capture_mouse_down_any_where_else;
    bool _double_click;     //!< If True, this InputArea can emit the signal mouse_double_click. Default is false.

    bool _keyboard_receiver_ignore_mouse_down_outside;

    bool accept_key_nav_focus_on_mouse_down_;
    bool accept_key_nav_focus_on_mouse_enter_;


#if defined(NUX_OS_LINUX)
    // DnD support
    // Rather than being implemented with signals, DND support is implemented with protected virtual function.
    // This ensure that a class and it subclass don't process the same event more than once!

    virtual void ProcessDndMove  (int x, int y, std::list<char *>mimes);
    virtual void ProcessDndDrop  (int x, int y);
    virtual void ProcessDndEnter();
    virtual void ProcessDndLeave();

    void SendDndStatus(bool accept, DndAction action, Geometry region);
    void SendDndFinished(bool accepted, DndAction action);
    
    void SetDndEnabled(bool as_source, bool as_target);
    
    virtual bool                    DndSourceDragBegin      ();
    virtual NBitmapData *           DndSourceGetDragImage   ();
    virtual std::list<const char *> DndSourceGetDragTypes   ();
    virtual const char *            DndSourceGetDataForType(const char *type, int *size, int *format);
    virtual void                    DndSourceDragFinished   (DndAction result);
    
    void StartDragAsSource();
    
    static NBitmapData *           InnerDndSourceGetDragImage(void *data) { return static_cast<InputArea *> (data)->DndSourceGetDragImage();       }
    static std::list<const char *> InnerDndSourceGetDragTypes(void *data) { return static_cast<InputArea *> (data)->DndSourceGetDragTypes();       }
    static void                    InnerDndSourceDragFinished(DndAction result, void *data);
    
    static const char * InnerDndSourceGetDataForType(const char *type, int *size, int *format, void *data) 
      { return static_cast<InputArea *> (data)->DndSourceGetDataForType(type, size, format); }
#endif

  public:

#ifdef NUX_GESTURES_SUPPORT
    //! Creates a new gesture subscription for this input area and activates it
    /*
      Convenience function.
      It's the same as doing the following:
        ShGesturesSubscription sub(new GesturesSubscription);
        sub->SetGestureClasses(gesture_classes);
        sub->SetNumTouches(num_touches);
        sub->Activate();
        input_area->AddGesturesSubscription(sub);
     */
    void CreateGesturesSubscription(int gesture_classes,
                                    unsigned int num_touches);

    //! Adds a gestures subscription to this input area.
    /*!
      A single subscription can be shared among multiple InputAreas.
     */
    void AddGesturesSubscription(ShGesturesSubscription &subscription);

    //! Removes a gestures subscription from this input area.
    void RemoveGesturesSubscription(ShGesturesSubscription &subscription);

    //! Returns all multitouch gestures subscriptions that this area cares about.
    /*!
      An input area will receive GestureEvents for multitouch gestures that
      hit his area and matches any active subscription present in this list.
     */
    const std::list<ShGesturesSubscription> &GetGesturesSubscriptions() const;

    //! Returns whether this area has a subscription that matches the gesture event
    bool HasSubscriptionForGesture(const GestureEvent &event) const;

    //! Returns the InputArea hit by the given gesture
    /*!
      If this area or any of its children is hit by the gesture from the given
      event, that area will be returned. Otherwise, it returns nullptr.
     */
    virtual Area* GetInputAreaHitByGesture(const GestureEvent &event);

  private:
    std::list<ShGesturesSubscription> gestures_subscriptions_;
#endif // NUX_GESTURES_SUPPORT

  public:
    //! Signal emitted when the Mouse moves over the InputArea surface.
    sigc::signal<void, int, int, int, int, unsigned long, unsigned long> mouse_move;  // send the current position inside the area
    
    //! Signal emitted when the InputArea receives a mouse down event.
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param unsigned long Mouse button states(3rd parameter of the callback).
        @param unsigned long Keyboard special keys states(4th parameter of the callback).
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_down;
    
    //! Signal emitted when the InputArea receives a mouse up event.
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param unsigned long Mouse button states(3rd parameter of the callback).
        @param unsigned long Keyboard special keys states(4th parameter of the callback).
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_up;
    
    //! Signal emitted when the InputArea receives a mouse enter event.
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param unsigned long Mouse button states(3rd parameter of the callback).
        @param unsigned long Keyboard special keys states(4th parameter of the callback).
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_enter;
    
    //! Signal emitted when the InputArea receives a mouse leave event.
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param unsigned long Mouse button states(3rd parameter of the callback).
        @param unsigned long Keyboard special keys states(4th parameter of the callback).
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_leave;
    
    //! Signal emitted when the InputArea receives a mouse down followed later by a mouse release over its surface.
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param unsigned long Mouse button states(3rd parameter of the callback).
        @param unsigned long Keyboard special keys states(4th parameter of the callback).
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_click;
    
    //! Signal emitted when the InputArea receives a double click event.
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param unsigned long Mouse button states(3rd parameter of the callback).
        @param unsigned long Keyboard special keys states(4th parameter of the callback).
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_double_click;

    //! Signal emitted when the InputArea receives a mouse down event, followed later by a mouse move event(while the mouse is still pressed).
    /*!
        @param void Return type of the callback hooked to this signal.
        @param int Mouse X position(1st parameter of the callback).
        @param int Mouse Y position(2nd parameter of the callback).
        @param int Mouse X delta(3thr parameter of the callback).
        @param int Mouse Y delta(4th parameter of the callback).
        @param unsigned long Mouse button states(5th parameter of the callback).
        @param unsigned long Keyboard special keys states(6th parameter of the callback).
    */
    sigc::signal<void, int, int, int, int, unsigned long, unsigned long> mouse_drag; // send(current X, current Y, delta X, delta Y)

    //! Signal emitted when the InputArea receives a mouse wheel event.
    sigc::signal < void,
         int,            // window x
         int,            // window y
         int,            // mouse wheel delta: +120/-120 correspond to one notch of the wheel
         unsigned long,  // mouse state
         unsigned long   // key state
         > mouse_wheel; // send(current X, current Y, delta X, delta Y)

    //! Signal emitted when the InputArea loses ownership over a pressed mouse.
    /*!
      Any actions or changes caused by the previous mouse_down should be reverted.
     */
    sigc::signal<void> mouse_cancel;

    //! Signal emitted when the InputArea receives a key release event.
    sigc::signal<void, unsigned int, unsigned long, unsigned long> key_up;

    //! Signal emitted when the area gets the keyboard focus. The is a result of a mouse down event or a call to ForceStartFocus.
    sigc::signal<void> begin_key_focus;
    //! Signal emitted when the area looses the keyboard focus.
    sigc::signal<void> end_key_focus;

    sigc::signal < void,
         unsigned long       ,   /*event type*/
         unsigned long       ,   /*event keysym*/
         unsigned long       ,   /*event state*/
         const char*        ,   /*character*/
         unsigned short          /*key repeat count*/
         > key_down;

    //! Signal emitted when a mouse down event occurs outside of this area
    /*!
        If this area is inside the main layout, then the position is relative to the top left corner of the window.
        If this area is a BaseWindow, then the position is relative to the top left corner of the window.
        If this area is inside a BaseWindow, then the position is relative to the top left corner of the BaseWIndow.

        @param int    Position of the mouse down event.
        @param int    Position of the mouse down event.
        @param ulong  Mouse button states.
        @param ulong  Keyboard modifiers states.
    */
    sigc::signal<void, int, int, unsigned long, unsigned long> mouse_down_outside_pointer_grab_area;

    sigc::signal<void, InputArea*> start_keyboard_grab;
    sigc::signal<void, InputArea*> end_keyboard_grab;

#ifdef NUX_GESTURES_SUPPORT
    //! Called whenever a GestureEvent is received
    /*!
      You should reimplement this method to handle gestures. Typically you would
      add code to make this area react to the gestures received.

      In order to receive events from a given kind of gesture, an area has to
      have a corresponding gesture subscription. See CreateGesturesSubscription()
      and AddGesturesSubscription().

      This method is called only with gestures that have already
      been accepted. Therefore you shouldn't call GestureEvent::Accept()
      or GestureEvent::Reject() from here as there's no point in doing so.

      Default implementation just returns GestureDeliveryRequest::NONE.
     */
    virtual GestureDeliveryRequest GestureEvent(const GestureEvent & /* event */)
    {
      return GestureDeliveryRequest::NONE;
    }
#endif

    protected:

      virtual bool AcceptKeyNavFocus();
      virtual bool AcceptKeyNavFocusOnMouseDown() const;
      virtual bool AcceptKeyNavFocusOnMouseEnter() const;

      // == Signals with 1 to 1 mapping to input device ==
      virtual void EmitMouseDownSignal        (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitMouseUpSignal          (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitMouseMoveSignal        (int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitMouseWheelSignal       (int x, int y, int wheel_delta, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitKeyDownSignal          (unsigned int key_symbol, unsigned long x11_key_code, unsigned long special_keys_state);
      virtual void EmitKeyUpSignal            (unsigned int key_symbol, unsigned long x11_key_code, unsigned long special_keys_state);
      virtual void EmitKeyEventSignal         (unsigned long event_type,
                                              unsigned int key_symbol,
                                              unsigned long special_keys_state,
                                              const char* text,
                                              int key_repeat_count);

      // == Interpreted signals ==

      // Mouse down + mouse move on an area
      virtual void EmitMouseDragSignal        (int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitMouseEnterSignal       (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitMouseLeaveSignal       (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);

      virtual void EmitMouseClickSignal       (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
      virtual void EmitMouseDoubleClickSignal(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);

      virtual void EmitMouseDownOutsideArea   (int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);

      virtual void EmitMouseCancelSignal();

      friend class WindowCompositor;

    private:
      bool is_tracking_child_mouse_events_;
  };

}

#endif // INPUTAREA_H