Mouse functions are now in a separate class

This commit is contained in:
Markus Gans 2018-01-14 21:21:08 +01:00
parent 3419e9e908
commit 48cdd9bb0a
20 changed files with 2359 additions and 1084 deletions

View File

@ -1,3 +1,6 @@
2017-01-14 Markus Gans <guru.mail@muenster.de>
* Mouse functions are now in a separate class
2017-01-05 Markus Gans <guru.mail@muenster.de> 2017-01-05 Markus Gans <guru.mail@muenster.de>
* Refactoring FVTerm::restoreVTerm * Refactoring FVTerm::restoreVTerm
* Fixed buffer size in FOptiMove * Fixed buffer size in FOptiMove

View File

@ -140,15 +140,15 @@ Class digramm
: │ ┌────────────┐ : │ ┌────────────┐
: ├────┤ FHideEvent │ : ├────┤ FHideEvent │
: │ └────────────┘ : │ └────────────┘
: │ ┌─────────────┐
: ├────┤ FCloseEvent │
: │ └─────────────┘
1┌───────────┐ : │ ┌─────────────┐ 1┌───────────┐ : │ ┌─────────────┐
┌-----------┤ FOptiMove │ : └────┤ FTimerEvent │ ┌-----------┤ FOptiMove │ : ├────┤ FCloseEvent │
: └───────────┘ : │ └─────────────┘
: 1┌───────────┐ : │ ┌─────────────┐
┌-----------┤ FOptiAttr │ : └────┤ FTimerEvent │
: └───────────┘ : └─────────────┘ : └───────────┘ : └─────────────┘
: 1┌───────────┐ : : 1┌───────────────┐ :
┌-----------┤ FOptiAttr │ : ┌──────────────┐ ┌-----------┤ FMouseControl │ : ┌──────────────┐
: └───────────┘ : ┌────┤ FApplication │ : └───────────────┘ : ┌────┤ FApplication │
: *┌─────────┐ : │ └──────────────┘ : *┌─────────┐ : │ └──────────────┘
: ┌--------┤ FString │ : │ ┌─────────┐ : ┌--------┤ FString │ : │ ┌─────────┐
: : └─────────┘ : ├────┤ FButton │ : : └─────────┘ : ├────┤ FButton │

View File

@ -26,15 +26,15 @@
: │ ┌────────────┐ : │ ┌────────────┐
: ├────┤ FHideEvent │ : ├────┤ FHideEvent │
: │ └────────────┘ : │ └────────────┘
: │ ┌─────────────┐
: ├────┤ FCloseEvent │
: │ └─────────────┘
1┌───────────┐ : │ ┌─────────────┐ 1┌───────────┐ : │ ┌─────────────┐
┌-----------┤ FOptiMove │ : └────┤ FTimerEvent │ ┌-----------┤ FOptiMove │ : ├────┤ FCloseEvent │
: └───────────┘ : │ └─────────────┘
: 1┌───────────┐ : │ ┌─────────────┐
┌-----------┤ FOptiAttr │ : └────┤ FTimerEvent │
: └───────────┘ : └─────────────┘ : └───────────┘ : └─────────────┘
: 1┌───────────┐ : : 1┌───────────────┐ :
┌-----------┤ FOptiAttr │ : ┌──────────────┐ ┌-----------┤ FMouseControl │ : ┌──────────────┐
: └───────────┘ : ┌────┤ FApplication │ : └───────────────┘ : ┌────┤ FApplication │
: *┌─────────┐ : │ └──────────────┘ : *┌─────────┐ : │ └──────────────┘
: ┌--------┤ FString │ : │ ┌─────────┐ : ┌--------┤ FString │ : │ ┌─────────┐
: : └─────────┘ : ├────┤ FButton │ : : └─────────┘ : ├────┤ FButton │

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2017 Markus Gans * * Copyright 2016-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -211,4 +211,5 @@ int main (int argc, char* argv[])
// Waiting for keypress // Waiting for keypress
keyPressed(); keyPressed();
app = 0; // End of TermApp object scope
} }

View File

@ -126,22 +126,6 @@ class FApplication : public FWidget
typedef std::pair<const FObject*, const FEvent*> eventPair; typedef std::pair<const FObject*, const FEvent*> eventPair;
typedef std::deque<eventPair> eventQueue; typedef std::deque<eventPair> eventQueue;
enum btn_state
{
Pressed = 1,
Released = 2,
DoubleClick = 3
};
#ifdef F_HAVE_LIBGPM
enum gpmEventType
{
no_event = 0,
keyboard_event = 1,
mouse_event = 2
};
#endif
// Constants // Constants
static const int NEED_MORE_DATA = -1; // parseKeyString return value static const int NEED_MORE_DATA = -1; // parseKeyString return value
@ -154,20 +138,11 @@ class FApplication : public FWidget
// Methods // Methods
void init(); void init();
static void cmd_options (const int&, char*[]); static void cmd_options (const int&, char*[]);
#ifdef F_HAVE_LIBGPM
int gpmEvent (bool = true);
bool processGpmEvent();
#endif
bool KeyPressed(); bool KeyPressed();
ssize_t readKey(); ssize_t readKey();
FWidget* findKeyboardWidget(); FWidget* findKeyboardWidget();
bool getKeyPressedState(); bool getKeyPressedState();
void keyboardBufferTimeout (FWidget*); void keyboardBufferTimeout (FWidget*);
void readRawX11MouseData();
void readRawExtendedMouseData();
void readRawUrxvtMouseData();
void sendEscapeKeyPressEvent (FWidget*); void sendEscapeKeyPressEvent (FWidget*);
bool sendKeyDownEvent (FWidget*); bool sendKeyDownEvent (FWidget*);
bool sendKeyPressEvent (FWidget*); bool sendKeyPressEvent (FWidget*);
@ -188,10 +163,6 @@ class FApplication : public FWidget
bool processDialogSwitchAccelerator(); bool processDialogSwitchAccelerator();
bool processAccelerator (const FWidget*&); bool processAccelerator (const FWidget*&);
void getX11ButtonState (int);
bool parseX11Mouse();
bool parseSGRMouse();
bool parseUrxvtMouse();
bool getMouseEvent(); bool getMouseEvent();
FWidget*& determineClickedWidget(); FWidget*& determineClickedWidget();
void unsetMoveSizeMode(); void unsetMoveSizeMode();
@ -221,30 +192,7 @@ class FApplication : public FWidget
int app_argc; int app_argc;
char** app_argv; char** app_argv;
int key; int key;
#ifdef F_HAVE_LIBGPM
Gpm_Event gpm_ev;
bool gpmMouseEvent;
#endif
struct button_state // bit field
{
uChar left_button : 2; // 0..3
uChar right_button : 2; // 0..3
uChar middle_button : 2; // 0..3
uChar shift_button : 1; // 0..1
uChar control_button : 1; // 0..1
uChar meta_button : 1; // 0..1
uChar wheel_up : 1; // 0..1
uChar wheel_down : 1; // 0..1
uChar mouse_moved : 1; // 0..1
uChar : 4; // padding bits
} b_state;
char k_buf[1024]; char k_buf[1024];
char x11_mouse[4];
char sgr_mouse[13];
char urxvt_mouse[13];
char fifo_buf[512]; char fifo_buf[512];
int fifo_offset; int fifo_offset;
bool fifo_in_use; bool fifo_in_use;
@ -252,15 +200,11 @@ class FApplication : public FWidget
long key_timeout; long key_timeout;
long dblclick_interval; long dblclick_interval;
struct timeval time_keypressed; struct timeval time_keypressed;
struct timeval time_mousepressed;
FPoint new_mouse_position;
static eventQueue* event_queue; static eventQueue* event_queue;
static int quit_code; static int quit_code;
static bool quit_now; static bool quit_now;
static int loop_level; static int loop_level;
static bool process_timer_event; static bool process_timer_event;
static FPoint* zero_point;
static uChar x11_button_state;
static FWidget* move_size_widget; static FWidget* move_size_widget;
static FWidget* main_widget; static FWidget* main_widget;
static FWidget* active_window; static FWidget* active_window;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2017 Markus Gans * * Copyright 2014-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *

543
include/final/fmouse.h Normal file
View File

@ -0,0 +1,543 @@
/***********************************************************************
* fmouse.h - Read mouse events *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* *
* The Final Cut 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 3 of *
* the License, or (at your option) any later version. *
* *
* The Final Cut is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
/* Inheritance diagram
*
*
*
* FMouse
*
*
*
*
*
*
* FMouseGPM FMouseX11 FMouseSGR FMouseUrxvt
*
*
*
*
* 1 1
* FMouseControl - -- - - FMouseGPM
* :
* :
* : 1
* :- - - FMouseX11
* :
* :
* : 1
* - - - FMouseSGR
* :
* :
* : 1
* - - - FMouseUrxvt
*
*/
#ifndef FMOUSE_H
#define FMOUSE_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include <cstddef>
#include <map>
#include "final/fconfig.h"
#include "final/fpoint.h"
#include "final/ftypes.h"
#if defined(__linux__)
#include <linux/keyboard.h> // need for gpm keyboard modifiers
#endif
#ifdef F_HAVE_LIBGPM
#include <gpm.h>
#undef buttons // from term.h
#endif
//----------------------------------------------------------------------
// class FMouse
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMouse
{
public:
// Enumeration
enum mouse_type
{
none = 0,
gpm = 1,
x11 = 2,
sgr = 3,
urxvt = 4
};
// Constructor
FMouse();
// Destructor
virtual ~FMouse()
{ }
// Accessors
virtual const char* getClassName() const;
FPoint& getPos();
void clearEvent();
// Mutators
void setMaxWidth (short);
void setMaxHeight (short);
// Inquiries
virtual bool hasData() = 0;
bool hasEvent();
bool isLeftButtonPressed();
bool isLeftButtonReleased();
bool isLeftButtonDoubleClick();
bool isRightButtonPressed();
bool isRightButtonReleased();
bool isMiddleButtonPressed();
bool isMiddleButtonReleased();
bool isShiftKeyPressed();
bool isControlKeyPressed();
bool isMetaKeyPressed();
bool isWheelUp();
bool isWheelDown();
bool isMoved();
bool isInputDataPending();
// Methods
static FMouse* createMouseObject (mouse_type);
virtual void setRawData (char[], int) = 0;
virtual void processEvent (struct timeval*) = 0;
protected:
// Typedef and Enumerations
typedef struct
{
uChar left_button : 2; // 0..3
uChar right_button : 2; // 0..3
uChar middle_button : 2; // 0..3
uChar shift_button : 1; // 0..1
uChar control_button : 1; // 0..1
uChar meta_button : 1; // 0..1
uChar wheel_up : 1; // 0..1
uChar wheel_down : 1; // 0..1
uChar mouse_moved : 1; // 0..1
uChar : 4; // padding bits
} button; // bit field
enum states
{
Undefined = 0,
Pressed = 1,
Released = 2,
DoubleClick = 3
};
// Mutator
void setPos (const FPoint&);
// Method
bool isDblclickTimeout (timeval*);
// Data Members
button b_state;
bool mouse_event_occurred;
bool input_data_pending;
long dblclick_interval;
short max_width;
short max_height;
struct timeval time_mousepressed;
FPoint zero_point;
FPoint mouse; // mouse click position
FPoint new_mouse_position;
};
#pragma pack(pop)
#ifdef F_HAVE_LIBGPM
//----------------------------------------------------------------------
// class FMouseGPM
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMouseGPM : public FMouse
{
public:
// Constructor
FMouseGPM();
// Destructor
virtual ~FMouseGPM();
// Accessors
const char* getClassName() const;
// Mutators
void setStdinNo(int);
// Inquiry
virtual bool hasData();
bool isGpmMouseEnabled();
// Methods
virtual void setRawData (char[], int);
virtual void processEvent (struct timeval*);
bool gpmMouse (bool);
bool enableGpmMouse();
bool disableGpmMouse();
bool getGpmKeyPressed(bool);
void drawGpmPointer();
private:
// Enumeration
enum gpmEventType
{
no_event = 0,
keyboard_event = 1,
mouse_event = 2
};
// Method
int gpmEvent (bool = true);
// Data Member
Gpm_Event gpm_ev;
bool has_gpm_mouse_data;
bool gpm_mouse_enabled;
int stdin_no;
};
#pragma pack(pop)
#endif
//----------------------------------------------------------------------
inline const char* FMouseGPM::getClassName() const
{ return "FMouseGPM"; }
//----------------------------------------------------------------------
inline bool FMouseGPM::enableGpmMouse()
{ return gpmMouse(true); }
//----------------------------------------------------------------------
inline bool FMouseGPM::disableGpmMouse()
{ return gpmMouse(false); }
//----------------------------------------------------------------------
inline bool FMouseGPM::isGpmMouseEnabled()
{ return gpm_mouse_enabled; }
//----------------------------------------------------------------------
// class FMouseX11
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMouseX11 : public FMouse
{
public:
// Constructor
FMouseX11();
// Destructor
virtual ~FMouseX11();
// Accessors
const char* getClassName() const;
// Inquiry
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void processEvent (struct timeval*);
private:
// Enumeration
enum btn_states
{
key_shift = 0x04,
key_meta = 0x08,
key_ctrl = 0x10,
key_button_mask = 0x1c,
button1_pressed = 0x20,
button2_pressed = 0x21,
button3_pressed = 0x22,
all_buttons_released = 0x23,
button1_pressed_move = 0x40,
button2_pressed_move = 0x41,
button3_pressed_move = 0x42,
button_mask = 0x63,
button_up = 0x60,
button_down = 0x61,
button_up_move = 0x60,
button_down_move = 0x61
};
// Constant
static const std::size_t MOUSE_BUF_SIZE = 4;
// Method
void setKeyState (int);
void setMoveState (const FPoint&, int);
void setButtonState (int, struct timeval*);
// Data Member
char x11_mouse[MOUSE_BUF_SIZE];
uChar x11_button_state;
};
#pragma pack(pop)
//----------------------------------------------------------------------
inline const char* FMouseX11::getClassName() const
{ return "FMouseX11"; }
//----------------------------------------------------------------------
// class FMouseSGR
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMouseSGR : public FMouse
{
public:
// Constructor
FMouseSGR();
// Destructor
virtual ~FMouseSGR();
// Accessors
const char* getClassName() const;
// Inquiry
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void processEvent (struct timeval*);
private:
// Enumeration
enum x11_ext_btn_states
{
key_shift = 0x04,
key_meta = 0x08,
key_ctrl = 0x10,
key_button_mask = 0x1c,
button1 = 0x00,
button2 = 0x01,
button3 = 0x02,
button1_move = 0x20,
button2_move = 0x21,
button3_move = 0x22,
button_mask = 0x63,
button_up = 0x40,
button_down = 0x41,
pressed = 'M',
released = 'm'
};
// Constant
static const std::size_t MOUSE_BUF_SIZE = 13;
// Methods
void setKeyState (int);
void setMoveState (const FPoint&, int);
void setPressedButtonState (int, struct timeval*);
void setReleasedButtonState (int);
// Data Members
char sgr_mouse[MOUSE_BUF_SIZE];
uChar sgr_button_state;
};
#pragma pack(pop)
//----------------------------------------------------------------------
inline const char* FMouseSGR::getClassName() const
{ return "FMouseSGR"; }
//----------------------------------------------------------------------
// class FMouseUrxvt
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMouseUrxvt : public FMouse
{
public:
// Constructor
FMouseUrxvt();
// Destructor
virtual ~FMouseUrxvt();
// Accessors
const char* getClassName() const;
// Inquiry
virtual bool hasData();
// Methods
virtual void setRawData (char[], int);
virtual void processEvent (struct timeval*);
private:
// Enumeration
enum urxvt_btn_states
{
key_shift = 0x04,
key_meta = 0x08,
key_ctrl = 0x10,
key_button_mask = 0x1c,
button1_pressed = 0x20,
button2_pressed = 0x21,
button3_pressed = 0x22,
all_buttons_released = 0x23,
button1_pressed_move = 0x40,
button2_pressed_move = 0x41,
button3_pressed_move = 0x42,
button_mask = 0x63,
button_up = 0x60,
button_down = 0x61,
button_up_move = 0x60,
button_down_move = 0x61
};
// Constant
static const std::size_t MOUSE_BUF_SIZE = 13;
// Methods
void setKeyState (int);
void setMoveState (const FPoint&, int);
void setButtonState (int, struct timeval*);
// Data Members
char urxvt_mouse[MOUSE_BUF_SIZE];
uChar urxvt_button_state;
};
#pragma pack(pop)
//----------------------------------------------------------------------
inline const char* FMouseUrxvt::getClassName() const
{ return "FMouseUrxvt"; }
//----------------------------------------------------------------------
// class FMouseControl
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FMouseControl
{
public:
// Constructor
FMouseControl();
// Destructor
virtual ~FMouseControl();
// Accessors
const char* getClassName() const;
FPoint& getPos();
void clearEvent();
// Mutators
void setStdinNo (int);
void setMaxWidth (short);
void setMaxHeight (short);
void useGpmMouse (bool = true);
void useXtermMouse (bool = true);
// Inquiries
bool hasData();
bool hasEvent();
bool isLeftButtonPressed();
bool isLeftButtonReleased();
bool isLeftButtonDoubleClick();
bool isRightButtonPressed();
bool isRightButtonReleased();
bool isMiddleButtonPressed();
bool isMiddleButtonReleased();
bool isShiftKeyPressed();
bool isControlKeyPressed();
bool isMetaKeyPressed();
bool isWheelUp();
bool isWheelDown();
bool isMoved();
bool isInputDataPending();
bool isGpmMouseEnabled();
// Methods
void enable();
void disable();
void xtermMouse (bool);
void enableXTermMouse();
void disableXTermMouse();
virtual void setRawData (FMouse::mouse_type, char[], int);
virtual void processEvent (struct timeval* time);
bool getGpmKeyPressed (bool);
void drawGpmPointer();
private:
std::map<FMouse::mouse_type, FMouse*> mouse_protocol;
std::map<FMouse::mouse_type, FMouse*>::iterator iter;
// Accessor
FMouse* getMouseWithData();
FMouse* getMouseWithEvent();
void putstring (const char[], int = 1);
// Data Member
FPoint zero_point;
bool use_gpm_mouse;
bool use_xterm_mouse;
};
#pragma pack(pop)
inline const char* FMouseControl::getClassName() const
{ return "FMouseControl"; }
//----------------------------------------------------------------------
inline void FMouseControl::enableXTermMouse()
{ xtermMouse(true); }
//----------------------------------------------------------------------
inline void FMouseControl::disableXTermMouse()
{ xtermMouse(false); }
#endif // FMOUSE_H

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2017 Markus Gans * * Copyright 2015-2018 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -96,6 +96,7 @@ class FObject
// Timer methods // Timer methods
static void getCurrentTime (timeval*); static void getCurrentTime (timeval*);
static bool isTimeout (timeval*, register long);
int addTimer (int); int addTimer (int);
bool delTimer (int); bool delTimer (int);
bool delOwnTimer(); bool delOwnTimer();

View File

@ -56,13 +56,8 @@
#include "final/fconfig.h" #include "final/fconfig.h"
#ifdef F_HAVE_LIBGPM
#include <gpm.h>
#endif
#if defined(__linux__) #if defined(__linux__)
#include <linux/fb.h> // Linux framebuffer console #include <linux/fb.h> // Linux framebuffer console
#include <linux/keyboard.h> // need for gpm keyboard modifiers
#if defined(__x86_64__) || defined(__i386) || defined(__arm__) #if defined(__x86_64__) || defined(__i386) || defined(__arm__)
#include <sys/io.h> // <asm/io.h> is deprecated #include <sys/io.h> // <asm/io.h> is deprecated
@ -88,6 +83,7 @@
#include <langinfo.h> #include <langinfo.h>
#include <termios.h> #include <termios.h>
#if defined(__sun) && defined(__SVR4) #if defined(__sun) && defined(__SVR4)
#include <termio.h> #include <termio.h>
typedef struct termio SGTTY; typedef struct termio SGTTY;
@ -104,6 +100,10 @@
#include <term.h> // termcap #include <term.h> // termcap
#endif #endif
#ifdef F_HAVE_LIBGPM
#undef buttons // from term.h
#endif
#if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H #if F_HAVE_GETTTYNAM && F_HAVE_TTYENT_H
#include <ttyent.h> #include <ttyent.h>
#endif #endif
@ -119,6 +119,7 @@
#include <string> #include <string>
#include "final/fc.h" #include "final/fc.h"
#include "final/fmouse.h"
#include "final/fobject.h" #include "final/fobject.h"
#include "final/foptiattr.h" #include "final/foptiattr.h"
#include "final/foptimove.h" #include "final/foptimove.h"
@ -128,11 +129,6 @@
#include "final/ftermcap.h" #include "final/ftermcap.h"
#ifdef F_HAVE_LIBGPM
#undef buttons // from term.h
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTerm // class FTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -169,6 +165,7 @@ class FTerm
static int getLineNumber(); static int getLineNumber();
static int getColumnNumber(); static int getColumnNumber();
static const FString getKeyName (int); static const FString getKeyName (int);
static FMouseControl* getMouseControl();
#if defined(__linux__) #if defined(__linux__)
static modifier_key& getLinuxModifierKey(); static modifier_key& getLinuxModifierKey();
@ -194,7 +191,6 @@ class FTerm
// Inquiries // Inquiries
static bool isKeypressTimeout (timeval*); static bool isKeypressTimeout (timeval*);
static bool isDblclickTimeout (timeval*);
static bool isNormal (char_data*&); static bool isNormal (char_data*&);
static bool isRaw(); static bool isRaw();
static bool hasPCcharset(); static bool hasPCcharset();
@ -348,19 +344,6 @@ class FTerm
static bool hasChangedTermSize(); static bool hasChangedTermSize();
static void changeTermSizeFinished(); static void changeTermSizeFinished();
static void xtermMetaSendsESC (bool); static void xtermMetaSendsESC (bool);
static void xtermMouse (bool);
static void enableXTermMouse();
static void disableXTermMouse();
#ifdef F_HAVE_LIBGPM
static bool gpmMouse (bool);
static bool enableGpmMouse();
static bool disableGpmMouse();
static bool isGpmMouseEnabled();
#endif // F_HAVE_LIBGPM
static FPoint& getMousePos();
static void setMousePos (const FPoint&);
static void setMousePos (short, short);
static void exitWithMessage (std::string) static void exitWithMessage (std::string)
#if defined(__clang__) || defined(__GNUC__) #if defined(__clang__) || defined(__GNUC__)
__attribute__((noreturn)) __attribute__((noreturn))
@ -425,9 +408,6 @@ class FTerm
// Disable assignment operator (=) // Disable assignment operator (=)
FTerm& operator = (const FTerm&); FTerm& operator = (const FTerm&);
// Inquiries
static bool isTimeout (timeval*, register long);
#if defined(__linux__) #if defined(__linux__)
static int isLinuxConsole(); static int isLinuxConsole();
#endif #endif
@ -556,13 +536,11 @@ class FTerm
static std::map <std::string,fc::encoding>* encoding_set; static std::map <std::string,fc::encoding>* encoding_set;
static FTermcap::tcap_map* tcap; static FTermcap::tcap_map* tcap;
static bool mouse_support;
static bool decscusr_support; static bool decscusr_support;
static bool terminal_detection; static bool terminal_detection;
static bool raw_mode; static bool raw_mode;
static bool input_data_pending; static bool input_data_pending;
static bool non_blocking_stdin; static bool non_blocking_stdin;
static bool gpm_mouse_enabled;
static bool pc_charset_console; static bool pc_charset_console;
static bool utf8_input; static bool utf8_input;
static bool utf8_state; static bool utf8_state;
@ -596,7 +574,6 @@ class FTerm
static char* locale_name; static char* locale_name;
static char* locale_xterm; static char* locale_xterm;
static FRect* term; // current terminal geometry static FRect* term; // current terminal geometry
static FPoint* mouse; // mouse click position
static int gnome_terminal_id; static int gnome_terminal_id;
static int stdin_status_flags; static int stdin_status_flags;
@ -622,6 +599,7 @@ class FTerm
static FOptiMove* opti_move; static FOptiMove* opti_move;
static FOptiAttr* opti_attr; static FOptiAttr* opti_attr;
static FMouseControl* mouse;
static const FString* xterm_font; static const FString* xterm_font;
static const FString* xterm_title; static const FString* xterm_title;
static const FString* answer_back; static const FString* answer_back;
@ -702,11 +680,7 @@ inline const FString& FTerm::getSecDAString()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::isKeypressTimeout (timeval* time) inline bool FTerm::isKeypressTimeout (timeval* time)
{ return isTimeout (time, key_timeout); } { return FObject::isTimeout (time, key_timeout); }
//----------------------------------------------------------------------
inline bool FTerm::isDblclickTimeout (timeval* time)
{ return isTimeout (time, dblclick_interval); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::isRaw() inline bool FTerm::isRaw()
@ -868,39 +842,5 @@ inline bool FTerm::hasChangedTermSize()
inline void FTerm::changeTermSizeFinished() inline void FTerm::changeTermSizeFinished()
{ resize_term = false; } { resize_term = false; }
//----------------------------------------------------------------------
inline void FTerm::enableXTermMouse()
{ xtermMouse(true); }
//----------------------------------------------------------------------
inline void FTerm::disableXTermMouse()
{ xtermMouse(false); }
#ifdef F_HAVE_LIBGPM
//----------------------------------------------------------------------
inline bool FTerm::enableGpmMouse()
{ return gpmMouse(true); }
//----------------------------------------------------------------------
inline bool FTerm::disableGpmMouse()
{ return gpmMouse(false); }
//----------------------------------------------------------------------
inline bool FTerm::isGpmMouseEnabled()
{ return gpm_mouse_enabled; }
#endif // F_HAVE_LIBGPM
//----------------------------------------------------------------------
inline FPoint& FTerm::getMousePos()
{ return *mouse; }
//----------------------------------------------------------------------
inline void FTerm::setMousePos (const FPoint& m)
{ *mouse = m; }
//----------------------------------------------------------------------
inline void FTerm::setMousePos (short x, short y)
{ mouse->setPoint (x, y); }
#endif // FTERM_H #endif // FTERM_H

View File

@ -23,6 +23,7 @@ libfinal_la_SOURCES = \
flistbox.cpp \ flistbox.cpp \
flistview.cpp \ flistview.cpp \
fmenu.cpp \ fmenu.cpp \
fmouse.cpp \
fdialoglistmenu.cpp \ fdialoglistmenu.cpp \
fmenubar.cpp \ fmenubar.cpp \
fmenuitem.cpp \ fmenuitem.cpp \
@ -71,6 +72,7 @@ finalcutinclude_HEADERS = \
../include/final/flistbox.h \ ../include/final/flistbox.h \
../include/final/flistview.h \ ../include/final/flistview.h \
../include/final/fmenu.h \ ../include/final/fmenu.h \
../include/final/fmouse.h \
../include/final/fdialoglistmenu.h \ ../include/final/fdialoglistmenu.h \
../include/final/fmenubar.h \ ../include/final/fmenubar.h \
../include/final/fmenuitem.h \ ../include/final/fmenuitem.h \

View File

@ -23,6 +23,7 @@ INCLUDE_HEADERS = \
flistbox.h \ flistbox.h \
flistview.h \ flistview.h \
fmenu.h \ fmenu.h \
fmouse.h \
fdialoglistmenu.h \ fdialoglistmenu.h \
fmenubar.h \ fmenubar.h \
fradiomenuitem.h \ fradiomenuitem.h \
@ -76,6 +77,7 @@ OBJS = \
flistbox.o \ flistbox.o \
flistview.o \ flistview.o \
fmenu.o \ fmenu.o \
fmouse.o \
fdialoglistmenu.o \ fdialoglistmenu.o \
fmenubar.o \ fmenubar.o \
fmenuitem.o \ fmenuitem.o \

View File

@ -23,6 +23,7 @@ INCLUDE_HEADERS = \
flistbox.h \ flistbox.h \
flistview.h \ flistview.h \
fmenu.h \ fmenu.h \
fmouse.h \
fdialoglistmenu.h \ fdialoglistmenu.h \
fmenubar.h \ fmenubar.h \
fradiomenuitem.h \ fradiomenuitem.h \
@ -76,6 +77,7 @@ OBJS = \
flistbox.o \ flistbox.o \
flistview.o \ flistview.o \
fmenu.o \ fmenu.o \
fmouse.o \
fdialoglistmenu.o \ fdialoglistmenu.o \
fmenubar.o \ fmenubar.o \
fmenuitem.o \ fmenuitem.o \

View File

@ -131,13 +131,13 @@ libfinal_la_LIBADD =
am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \ am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \
fprogressbar.lo flineedit.lo fbutton.lo fbuttongroup.lo \ fprogressbar.lo flineedit.lo fbutton.lo fbuttongroup.lo \
ftogglebutton.lo fradiobutton.lo fcheckbox.lo fswitch.lo \ ftogglebutton.lo fradiobutton.lo fcheckbox.lo fswitch.lo \
flabel.lo flistbox.lo flistview.lo fmenu.lo fdialoglistmenu.lo \ flabel.lo flistbox.lo flistview.lo fmenu.lo fmouse.lo \
fmenubar.lo fmenuitem.lo fradiomenuitem.lo fcheckmenuitem.lo \ fdialoglistmenu.lo fmenubar.lo fmenuitem.lo fradiomenuitem.lo \
fmenulist.lo fdialog.lo fscrollview.lo fwindow.lo \ fcheckmenuitem.lo fmenulist.lo fdialog.lo fscrollview.lo \
fmessagebox.lo ftooltip.lo ffiledialog.lo ftextview.lo \ fwindow.lo fmessagebox.lo ftooltip.lo ffiledialog.lo \
fstatusbar.lo fterm.lo fvterm.lo fevent.lo foptiattr.lo \ ftextview.lo fstatusbar.lo fterm.lo fvterm.lo fevent.lo \
foptimove.lo ftermbuffer.lo fapplication.lo fwidget.lo \ foptiattr.lo foptimove.lo ftermbuffer.lo fapplication.lo \
fobject.lo fwidget.lo fobject.lo
libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS) libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@) AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -350,6 +350,7 @@ libfinal_la_SOURCES = \
flistbox.cpp \ flistbox.cpp \
flistview.cpp \ flistview.cpp \
fmenu.cpp \ fmenu.cpp \
fmouse.cpp \
fdialoglistmenu.cpp \ fdialoglistmenu.cpp \
fmenubar.cpp \ fmenubar.cpp \
fmenuitem.cpp \ fmenuitem.cpp \
@ -396,6 +397,7 @@ finalcutinclude_HEADERS = \
../include/final/flistbox.h \ ../include/final/flistbox.h \
../include/final/flistview.h \ ../include/final/flistview.h \
../include/final/fmenu.h \ ../include/final/fmenu.h \
../include/final/fmouse.h \
../include/final/fdialoglistmenu.h \ ../include/final/fdialoglistmenu.h \
../include/final/fmenubar.h \ ../include/final/fmenubar.h \
../include/final/fmenuitem.h \ ../include/final/fmenuitem.h \
@ -522,6 +524,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmenuitem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmenuitem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmenulist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmenulist.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmessagebox.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmessagebox.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmouse.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fobject.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fobject.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptiattr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptiattr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptimove.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/foptimove.Plo@am__quote@

File diff suppressed because it is too large Load Diff

View File

@ -401,6 +401,7 @@ void FButton::onMouseMove (FMouseEvent* ev)
void FButton::onTimer (FTimerEvent* ev) void FButton::onTimer (FTimerEvent* ev)
{ {
delTimer(ev->timerId()); delTimer(ev->timerId());
clearShadow();
setUp(); setUp();
} }
@ -587,9 +588,7 @@ inline int FButton::clickAnimationIndent (FWidget* parent_widget)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FButton::clearRightMargin (FWidget* parent_widget) inline void FButton::clearRightMargin (FWidget* parent_widget)
{ {
if ( button_down if ( button_down || isNewFont() )
|| isNewFont()
|| ( ! is.flat && hasShadow() && ! isMonochron()) )
return; return;
// Restore the right background after button down // Restore the right background after button down

1587
src/fmouse.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -182,6 +182,27 @@ void FObject::getCurrentTime (timeval* time)
} }
} }
//----------------------------------------------------------------------
bool FObject::isTimeout (timeval* time, register long timeout)
{
register long diff_usec;
struct timeval now;
struct timeval diff;
FObject::getCurrentTime(&now);
diff.tv_sec = now.tv_sec - time->tv_sec;
diff.tv_usec = now.tv_usec - time->tv_usec;
if ( diff.tv_usec < 0 )
{
diff.tv_sec--;
diff.tv_usec += 1000000;
}
diff_usec = (diff.tv_sec * 1000000) + diff.tv_usec;
return ( diff_usec > timeout );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FObject::addTimer (int interval) int FObject::addTimer (int interval)
{ {

View File

@ -558,7 +558,7 @@ char* FOptiAttr::changeAttribute (char_data*& term, char_data*& next)
changeAttributeSeparately (term, next); changeAttributeSeparately (term, next);
} }
if ( term && fake_reverse ) if ( fake_reverse )
term->attr.bit.reverse = true; term->attr.bit.reverse = true;
return attr_buf; return attr_buf;

View File

@ -60,13 +60,11 @@ uInt FTerm::baudrate;
long FTerm::key_timeout; long FTerm::key_timeout;
long FTerm::dblclick_interval; long FTerm::dblclick_interval;
bool FTerm::resize_term; bool FTerm::resize_term;
bool FTerm::mouse_support;
bool FTerm::decscusr_support; bool FTerm::decscusr_support;
bool FTerm::terminal_detection; bool FTerm::terminal_detection;
bool FTerm::raw_mode; bool FTerm::raw_mode;
bool FTerm::input_data_pending; bool FTerm::input_data_pending;
bool FTerm::non_blocking_stdin; bool FTerm::non_blocking_stdin;
bool FTerm::gpm_mouse_enabled;
bool FTerm::color256; bool FTerm::color256;
bool FTerm::monochron; bool FTerm::monochron;
bool FTerm::xterm_terminal; bool FTerm::xterm_terminal;
@ -115,7 +113,6 @@ int FTerm::framebuffer_bpp = -1;
char* FTerm::locale_name = 0; char* FTerm::locale_name = 0;
char* FTerm::locale_xterm = 0; char* FTerm::locale_xterm = 0;
FPoint* FTerm::mouse = 0;
FRect* FTerm::term = 0; FRect* FTerm::term = 0;
char FTerm::exit_message[8192] = ""; char FTerm::exit_message[8192] = "";
@ -126,6 +123,7 @@ const FString* FTerm::answer_back = 0;
const FString* FTerm::sec_da = 0; const FString* FTerm::sec_da = 0;
FOptiMove* FTerm::opti_move = 0; FOptiMove* FTerm::opti_move = 0;
FOptiAttr* FTerm::opti_attr = 0; FOptiAttr* FTerm::opti_attr = 0;
FMouseControl* FTerm::mouse = 0;
std::map<uChar,uChar>* FTerm::vt100_alt_char = 0; std::map<uChar,uChar>* FTerm::vt100_alt_char = 0;
std::map<std::string,fc::encoding>* \ std::map<std::string,fc::encoding>* \
FTerm::encoding_set = 0; FTerm::encoding_set = 0;
@ -227,6 +225,15 @@ const FString FTerm::getKeyName (int keynum)
return FString(""); return FString("");
} }
//----------------------------------------------------------------------
FMouseControl* FTerm::getMouseControl()
{
if ( mouse )
return mouse;
else
return 0;
}
#if defined(__linux__) #if defined(__linux__)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTerm::modifier_key& FTerm::getLinuxModifierKey() FTerm::modifier_key& FTerm::getLinuxModifierKey()
@ -1753,77 +1760,6 @@ void FTerm::xtermMetaSendsESC (bool on)
std::fflush(stdout); std::fflush(stdout);
} }
//----------------------------------------------------------------------
void FTerm::xtermMouse (bool on)
{
// activate/deactivate the xterm mouse support
if ( ! mouse_support )
return;
if ( on )
putstring (CSI "?1001s" // save old highlight mouse tracking
CSI "?1000h" // enable x11 mouse tracking
CSI "?1002h" // enable cell motion mouse tracking
CSI "?1015h" // enable urxvt mouse mode
CSI "?1006h"); // enable SGR mouse mode
else
putstring (CSI "?1006l" // disable SGR mouse mode
CSI "?1015l" // disable urxvt mouse mode
CSI "?1002l" // disable cell motion mouse tracking
CSI "?1000l" // disable x11 mouse tracking
CSI "?1001r"); // restore old highlight mouse tracking
std::fflush(stdout);
}
#ifdef F_HAVE_LIBGPM
//----------------------------------------------------------------------
bool FTerm::gpmMouse (bool on)
{
// activate/deactivate the gpm mouse support
if ( ! linux_terminal )
return false;
if ( openConsole() == 0 )
{
if ( ! isLinuxConsole() )
return false;
closeConsole();
}
if ( on )
{
Gpm_Connect conn;
conn.eventMask = uInt16(~GPM_MOVE);
conn.defaultMask = GPM_MOVE;
conn.maxMod = uInt16(~0);
conn.minMod = 0;
Gpm_Open(&conn, 0);
switch ( gpm_fd )
{
case -1:
return false;
case -2:
Gpm_Close();
return false;
default:
break;
}
}
else
{
Gpm_Close();
}
return on;
}
#endif // F_HAVE_LIBGPM
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::exitWithMessage (std::string message) void FTerm::exitWithMessage (std::string message)
{ {
@ -1848,27 +1784,6 @@ void FTerm::exitWithMessage (std::string message)
// private methods of FTerm // private methods of FTerm
//----------------------------------------------------------------------
bool FTerm::isTimeout (timeval* time, register long timeout)
{
register long diff_usec;
struct timeval now;
struct timeval diff;
FObject::getCurrentTime(&now);
diff.tv_sec = now.tv_sec - time->tv_sec;
diff.tv_usec = now.tv_usec - time->tv_usec;
if ( diff.tv_usec < 0 )
{
diff.tv_sec--;
diff.tv_usec += 1000000;
}
diff_usec = (diff.tv_sec * 1000000) + diff.tv_usec;
return ( diff_usec > timeout );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if defined(__linux__) #if defined(__linux__)
int FTerm::isLinuxConsole() int FTerm::isLinuxConsole()
@ -2623,7 +2538,6 @@ void FTerm::init_global_values()
no_shadow_character = \ no_shadow_character = \
no_half_block_character = \ no_half_block_character = \
ascii_console = \ ascii_console = \
mouse_support = \
decscusr_support = \ decscusr_support = \
force_vt100 = \ force_vt100 = \
tera_terminal = \ tera_terminal = \
@ -4388,31 +4302,33 @@ void FTerm::restoreColorPalette()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::enableMouse() void FTerm::enableMouse()
{ {
#ifdef F_HAVE_LIBGPM bool gpm_mouse = false;
// Enable the linux general purpose mouse (gpm) server bool xterm_mouse = false;
gpm_mouse_enabled = enableGpmMouse();
#endif
// Enable xterm mouse support if ( linux_terminal && openConsole() == 0 )
if ( TCAP(fc::t_key_mouse) && ! linux_terminal )
{ {
mouse_support = true; if ( isLinuxConsole() )
enableXTermMouse(); gpm_mouse = true;
closeConsole();
} }
if ( TCAP(fc::t_key_mouse) && ! linux_terminal )
xterm_mouse = true;
mouse->setMaxWidth (short(getColumnNumber()));
mouse->setMaxHeight (short(getLineNumber()));
// Enable the linux general purpose mouse (gpm) server
mouse->useGpmMouse (gpm_mouse);
// Enable xterm mouse support
mouse->useXtermMouse (xterm_mouse);
mouse->enable();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::disableMouse() void FTerm::disableMouse()
{ {
// Disable xterm mouse support mouse->disable();
if ( mouse_support )
disableXTermMouse();
#ifdef F_HAVE_LIBGPM
// Disable the linux general purpose mouse (gpm) server
if ( gpm_mouse_enabled )
disableGpmMouse();
#endif
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -4440,8 +4356,8 @@ inline void FTerm::allocationValues()
{ {
opti_move = new FOptiMove(); opti_move = new FOptiMove();
opti_attr = new FOptiAttr(); opti_attr = new FOptiAttr();
mouse = new FMouseControl();
term = new FRect(0, 0, 0, 0); term = new FRect(0, 0, 0, 0);
mouse = new FPoint(0, 0);
vt100_alt_char = new std::map<uChar, uChar>; vt100_alt_char = new std::map<uChar, uChar>;
encoding_set = new std::map<std::string, fc::encoding>; encoding_set = new std::map<std::string, fc::encoding>;
} }
@ -4473,12 +4389,12 @@ inline void FTerm::deallocationValues()
if ( xterm_font ) if ( xterm_font )
delete xterm_font; delete xterm_font;
if ( mouse )
delete mouse;
if ( term ) if ( term )
delete term; delete term;
if ( mouse )
delete mouse;
if ( opti_attr ) if ( opti_attr )
delete opti_attr; delete opti_attr;
@ -4835,15 +4751,15 @@ inline int FTerm::getMetaKey ( char buffer[]
// Looking for meta key strings in the buffer // Looking for meta key strings in the buffer
assert ( buf_size > 0 ); assert ( buf_size > 0 );
register int len, n;
for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++) for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++)
{ {
char* kmeta = fc::Fmetakey[i].string; // The string is never null char* kmeta = fc::Fmetakey[i].string; // The string is never null
len = int(std::strlen(kmeta)); register int len = int(std::strlen(kmeta));
if ( std::strncmp(kmeta, buffer, uInt(len)) == 0 ) // found if ( std::strncmp(kmeta, buffer, uInt(len)) == 0 ) // found
{ {
register int n;
if ( len == 2 && ( buffer[1] == 'O' if ( len == 2 && ( buffer[1] == 'O'
|| buffer[1] == '[' || buffer[1] == '['
|| buffer[1] == ']' ) ) || buffer[1] == ']' ) )

View File

@ -1 +0,0 @@
timestamp for config.h