64 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)    65   #error "Only <final/final.h> can be included directly."    74 #include "final/input/fkeyboard.h"    75 #include "final/util/fpoint.h"    77 #if defined(__linux__)    78   #include <linux/keyboard.h>     114     virtual auto getClassName() 
const -> 
FString;
   115     auto getPos() 
const & noexcept -> 
const FPoint&;
   118     auto isLeftButtonPressed() 
const noexcept -> bool;
   119     auto isLeftButtonReleased() 
const noexcept -> bool;
   120     auto isLeftButtonDoubleClick() 
const noexcept -> bool;
   121     auto isRightButtonPressed() 
const noexcept -> bool;
   122     auto isRightButtonReleased() 
const noexcept -> bool;
   123     auto isMiddleButtonPressed() 
const noexcept -> bool;
   124     auto isMiddleButtonReleased() 
const noexcept -> bool;
   125     auto isShiftKeyPressed() 
const noexcept -> bool;
   126     auto isControlKeyPressed() 
const noexcept -> bool;
   127     auto isMetaKeyPressed() 
const noexcept -> bool;
   128     auto isWheelUp() 
const noexcept -> bool;
   129     auto isWheelDown() 
const noexcept -> bool;
   130     auto isWheelLeft() 
const noexcept -> bool;
   131     auto isWheelRight() 
const noexcept -> bool;
   132     auto isMoved() 
const noexcept -> bool;
   135     void clearButtonState() noexcept;
   139     enum class State : uChar
   150       State right_button{};
   151       State middle_button{};
   153       bool  control_button{};
   164     auto getButtonState() 
const & noexcept -> 
const FMouseButton&;
   167     void setPos (
const FPoint&) noexcept;
   197     auto getClassName() 
const -> 
FString override;
   198     auto getMouseTypeID() 
const noexcept -> MouseType;
   199     void clearEvent() noexcept;
   202     void setMaxWidth (uInt16) noexcept;
   203     void setMaxHeight (uInt16) noexcept;
   204     void setDblclickInterval (
const uInt64) noexcept;
   207     virtual auto hasData() -> 
bool = 0;
   208     auto hasEvent() 
const noexcept -> bool;
   209     auto hasUnprocessedInput() 
const noexcept -> bool;
   212     template <
typename ClassT>
   213     static auto  createMouseObject() -> std::unique_ptr<ClassT>;
   215     virtual void processEvent (
const TimeValue&) = 0;
   219     auto getNewPos() 
const & noexcept -> 
const FPoint&;
   220     auto getMaxWidth() 
const noexcept -> uInt16;
   221     auto getMaxHeight() 
const noexcept -> uInt16;
   222     auto getDblclickInterval() 
const noexcept -> uInt64;
   223     auto getMousePressedTime() 
const noexcept -> TimeValue;
   226     void setMouseTypeID (MouseType) noexcept;
   227     void setNewPos (
int, 
int) noexcept;
   228     void useNewPos() noexcept;
   229     void setPending (
bool = 
true) noexcept;
   230     void setEvent() noexcept;
   231     void setMousePressedTime (
const TimeValue&) noexcept;
   232     void resetMousePressedTime() noexcept;
   235     auto isDblclickTimeout (
const TimeValue&) 
const -> bool;
   239     bool       mouse_event_occurred{
false};
   240     bool       unprocessed_buffer_data{
false};
   241     MouseType  MouseType_id{MouseType::None};
   242     uInt16     max_width{80};
   243     uInt16     max_height{25};
   244     uInt64     dblclick_interval{500000};  
   245     TimeValue  time_mousepressed{};
   246     FPoint     new_mouse_position{};
   250 template <
typename ClassT>
   251 inline auto FMouse::createMouseObject() -> std::unique_ptr<ClassT>
   253   return std::make_unique<ClassT>();
   262 class FMouseGPM final : 
public FMouse   269     auto getClassName() 
const -> 
FString override;
   272     void setStdinNo(
int) noexcept;
   275     auto hasData() noexcept -> 
bool override;
   276     auto isGpmMouseEnabled() 
const noexcept -> bool;
   280     void processEvent (
const TimeValue&) 
override;
   281     auto gpmMouse (
bool = 
true) -> bool;
   282     auto enableGpmMouse() -> bool;
   283     auto disableGpmMouse() -> bool;
   284     auto hasSignificantEvents() 
const noexcept -> bool;
   285     void interpretKeyDown() noexcept;
   286     void interpretKeyUp() noexcept;
   287     auto getGpmKeyPressed (
bool = 
true) -> bool;
   288     void drawPointer() 
const;
   292     enum class gpmEventType
   300     void handleMouseEvent();
   301     void resetMouseState();
   302     void handleMouseMovement();
   303     void handleMouseWheel();
   304     void interpretMouseEvent();
   305     void updateMousePosition();
   306     auto gpmEvent (
bool = 
true) 
const -> gpmEventType;
   310     bool      has_gpm_mouse_data{
false};
   311     bool      gpm_mouse_enabled{
false};
   316 inline auto FMouseGPM::enableGpmMouse() -> 
bool   317 { 
return gpmMouse(
true); }
   320 inline auto FMouseGPM::disableGpmMouse() -> 
bool   321 { 
return gpmMouse(
false); }
   324 inline auto FMouseGPM::isGpmMouseEnabled() 
const noexcept -> 
bool   325 { 
return gpm_mouse_enabled; }
   326 #endif  // F_HAVE_LIBGPM   340     auto getClassName() 
const -> 
FString override;
   343     auto hasData() noexcept -> 
bool override;
   347     void processEvent (
const TimeValue&) 
override;
   356       key_button_mask      = 0x1c,
   357       button1_pressed      = 0x20,
   358       button2_pressed      = 0x21,
   359       button3_pressed      = 0x22,
   360       all_buttons_released = 0x23,
   361       button1_pressed_move = 0x40,
   362       button2_pressed_move = 0x41,
   363       button3_pressed_move = 0x42,
   372     static constexpr std::size_t MOUSE_BUF_SIZE = 4;
   375     void setKeyState (
int) noexcept;
   376     void setMoveState (
const FPoint&, 
int) noexcept;
   377     auto isMouseClickButton (
const int) 
const noexcept -> bool;
   378     auto isMouseWheelButton (
const int) 
const noexcept -> bool;
   379     auto noChanges (
const FPoint&, uChar) 
const noexcept -> bool;
   380     void handleMouseClickButton (
int, 
const TimeValue&) noexcept;
   381     void handleMouseWheelButton (
int) noexcept;
   382     void setButtonState (
const int, 
const TimeValue&) noexcept;
   383     void handleButton1Pressed (
const TimeValue& time) noexcept;
   384     void handleButtonRelease() noexcept;
   387     std::array<char, MOUSE_BUF_SIZE>x11_mouse{};
   388     uChar x11_button_state{all_buttons_released};
   403     auto getClassName() 
const -> 
FString override;
   406     auto hasData() noexcept -> 
bool override;
   410     void processEvent (
const TimeValue&) 
override;
   418       const char* p{
nullptr};  
   422     enum class ParseError { No, Yes };
   424     enum x11_ext_btn_states
   429       key_button_mask = 0x1c,
   446     static constexpr std::size_t MOUSE_BUF_SIZE = 13;
   449     void setKeyState (
int) noexcept;
   450     void setMoveState (
const FPoint&, 
int) noexcept;
   451     auto isMouseClickButton (
const int) 
const noexcept -> bool;
   452     auto isMouseWheelButton (
const int) 
const noexcept -> bool;
   453     auto parseSGRMouseString (Tokens&) 
const noexcept -> ParseError;
   454     auto noChanges (
const FPoint&, uChar) 
const noexcept -> bool;
   455     void handleMouseClickButton (
int, 
const TimeValue&) noexcept;
   456     void handleMouseWheelButton (
int) noexcept;
   457     void setPressedButtonState (
const int, 
const TimeValue&) noexcept;
   458     void handleButton1Pressed (
const TimeValue& time) noexcept;
   459     void setReleasedButtonState (
const int) noexcept;
   462     std::array<char, MOUSE_BUF_SIZE> sgr_mouse{};
   463     uChar sgr_button_state{0x23};
   478     auto getClassName() 
const -> 
FString override;
   481     auto hasData() noexcept -> 
bool override;
   485     void processEvent (
const TimeValue&) 
override;
   495       const char* p{
nullptr};  
   499     enum class ParseError { No, Yes };
   501     enum urxvt_btn_states
   506       key_button_mask      = 0x1c,
   507       button1_pressed      = 0x20,
   508       button2_pressed      = 0x21,
   509       button3_pressed      = 0x22,
   510       all_buttons_released = 0x23,
   511       button1_pressed_move = 0x40,
   512       button2_pressed_move = 0x41,
   513       button3_pressed_move = 0x42,
   522     static constexpr std::size_t MOUSE_BUF_SIZE = 14;
   525     void setKeyState (
int) noexcept;
   526     void setMoveState (
const FPoint&, 
int) noexcept;
   527     auto isMouseClickButton (
const int) 
const noexcept -> bool;
   528     auto isMouseWheelButton (
const int) 
const noexcept -> bool;
   529     auto parseUrxvtMouseString (Tokens&) 
const noexcept -> ParseError;
   530     void adjustAndSetPosition (Tokens&);
   531     auto noChanges (
const FPoint&, uChar) 
const noexcept -> bool;
   532     void handleMouseClickButton (
int, 
const TimeValue&) noexcept;
   533     void handleButtonRelease() noexcept;
   534     void handleMouseWheelButton (
int) noexcept;
   535     void setButtonState (
const int, 
const TimeValue&) noexcept;
   538     std::array<char, MOUSE_BUF_SIZE>  urxvt_mouse{};
   539     uChar urxvt_button_state{all_buttons_released};
   554       : handler1(std::move(fn))
   558       : handler2(std::move(fn))
   562     inline void execute()
 const   567     template <
typename T>
   568     inline void execute(T&& arg)
 const   570       handler2(std::forward<T>(arg));
   575     std::function<void()> handler1{};
   576     std::function<void(const FMouseData&)> handler2{};
   588     using FMouseDataPtr = std::shared_ptr<FMouseData>;
   597     virtual auto getClassName() 
const -> 
FString;
   599     static auto  getCurrentMouseEvent() -> FMouseDataPtr&;
   600     auto  getPos() & -> 
const FPoint&;
   604     void  setStdinNo (
int);
   605     void  setMaxWidth (uInt16);
   606     void  setMaxHeight (uInt16);
   607     void  setDblclickInterval (
const uInt64) 
const;
   611     void  useGpmMouse (
bool = 
true);
   612     void  useXtermMouse (
bool = 
true);
   615     auto  hasData() -> bool;
   616     auto  hasEvent() -> bool;
   617     auto  isLeftButtonPressed() -> bool;
   618     auto  isLeftButtonReleased() -> bool;
   619     auto  isLeftButtonDoubleClick() -> bool;
   620     auto  isRightButtonPressed() -> bool;
   621     auto  isRightButtonReleased() -> bool;
   622     auto  isMiddleButtonPressed() -> bool;
   623     auto  isMiddleButtonReleased() -> bool;
   624     auto  isShiftKeyPressed() -> bool;
   625     auto  isControlKeyPressed() -> bool;
   626     auto  isMetaKeyPressed() -> bool;
   627     auto  isWheelUp() -> bool;
   628     auto  isWheelDown() -> bool;
   629     auto  isWheelLeft() -> bool;
   630     auto  isWheelRight() -> bool;
   631     auto  isMoved() -> bool;
   632     auto  hasUnprocessedInput() 
const -> bool;
   633     auto  hasDataInQueue() 
const -> bool;
   634     auto  isGpmMouseEnabled() noexcept -> bool;
   639     virtual void setRawData ( 
const FMouse::MouseType&
   641     virtual void processEvent (
const TimeValue&);
   642     void  processQueuedInput();
   643     auto  getGpmKeyPressed (
bool = 
true) -> bool;
   648     static constexpr std::size_t MAX_QUEUE_SIZE = 64;
   651     using FMousePtr = std::unique_ptr<FMouse>;
   652     using FMouseProtocol = std::vector<FMousePtr>;
   656     auto  findMouseWithType (
const FMouse::MouseType&) 
const -> FMouseProtocol::const_iterator;
   657     auto  findMouseWithData() 
const -> FMouseProtocol::const_iterator;
   658     auto  findMouseWithEvent() 
const -> FMouseProtocol::const_iterator;
   661     void  xtermMouse (
bool = 
true) 
const;
   662     void  enableXTermMouse() 
const;
   663     void  disableXTermMouse() 
const;
   664     static void  setCurrentMouseEvent (
const FMouseDataPtr&);
   665     static void  resetCurrentMouseEvent();
   668     FMouseProtocol  mouse_protocol{};
   674     bool            use_gpm_mouse{
false};
   675     bool            use_xterm_mouse{
false};
   680 inline auto FMouseControl::getClassName() 
const -> 
FString   681 { 
return "FMouseControl"; }
   684 inline void FMouseControl::setEventCommand (
const FMouseCommand& cmd)
   688 inline void FMouseControl::setEnableXTermMouseCommand (
const FMouseCommand& cmd)
   689 { enable_xterm_mouse_cmd = cmd; }
   692 inline void FMouseControl::setDisableXTermMouseCommand (
const FMouseCommand& cmd)
   693 { disable_xterm_mouse_cmd = cmd; }
   696 inline auto FMouseControl::hasDataInQueue() 
const -> 
bool   697 { 
return ! fmousedata_queue.isEmpty(); }
   700 inline void FMouseControl::enableXTermMouse()
 const   701 { xtermMouse(
true); }
   704 inline void FMouseControl::disableXTermMouse()
 const   705 { xtermMouse(
false); }
 
Definition: class_template.cpp:25