finalcut/src/fapp.h

204 lines
6.1 KiB
C
Raw Normal View History

// File: fapplication.h
// Provides: class FApplication
//
// Inheritance diagram
// ═══════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │
// └─────┬─────┘
// │
// ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FWidget ▏
// ▕▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ 1 *▕▔▔▔▔▔▔▔▔▏
// ▕ FApplication ▏-┬- - - -▕ FEvent ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▁▏
// :
// : *▕▔▔▔▔▔▔▔▔▏
// :- - - -▕ FPoint ▏
// : ▕▁▁▁▁▁▁▁▁▏
// :
// : *▕▔▔▔▔▔▔▔▔▔▏
// └- - - -▕ FWidget ▏
// ▕▁▁▁▁▁▁▁▁▁▏
2015-05-23 13:35:12 +02:00
#ifndef _FAPPLICATION_H
#define _FAPPLICATION_H
#include <linux/keyboard.h> // need for gpm keyboard modifiers
#include <sys/time.h> // need for gettimeofday
#include <getopt.h>
#include <deque>
#include "fevent.h"
#include "fwidget.h"
//----------------------------------------------------------------------
// class FApplication
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FApplication : public FWidget
{
public:
typedef std::pair<FObject*,FEvent*> eventPair;
2015-09-20 05:44:50 +02:00
static std::deque<eventPair>* event_queue;
2015-05-23 13:35:12 +02:00
private:
int app_argc;
char** app_argv;
static int quit_code;
static bool quit_now;
static int loop_level;
static bool process_timer_event;
static FPoint* zero_point;
int skipped_terminal_update;
2015-05-23 13:35:12 +02:00
int key;
char k_buf[1024];
char x11_mouse[4];
char sgr_mouse[13];
char urxvt_mouse[13];
2015-08-22 18:53:52 +02:00
#ifdef F_HAVE_LIBGPM
2015-05-23 13:35:12 +02:00
Gpm_Event gpm_ev;
bool gpmMouseEvent;
enum gpmEventType
{
no_event = 0,
keyboard_event = 1,
mouse_event = 2
};
#endif
enum btn_state
{
Pressed = 1,
Released = 2,
DoubleClick = 3
};
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 fifo_buf[512];
int fifo_offset;
bool fifo_in_use;
int fifo_buf_size;
long key_timeout;
long dblclick_interval;
struct timeval time_keypressed;
struct timeval time_mousepressed;
FPoint newMousePosition;
static FWidget* main_widget;
static FWidget* active_window;
static FWidget* focus_widget;
static FWidget* clicked_widget;
static FWidget* open_menu;
2015-05-23 13:35:12 +02:00
private:
FApplication (const FApplication&); // Disabled copy constructor
FApplication& operator = (const FApplication&); // and operator '='
2016-02-07 22:02:38 +01:00
void init();
void setExitMessage (std::string);
2015-05-23 13:35:12 +02:00
void cmd_options();
bool KeyPressed();
ssize_t readKey();
void processKeyboardEvent();
int modifierKeyCorrection (int& key);
bool processDialogSwitchAccelerator();
2016-07-25 23:50:57 +02:00
bool processAccelerator (FWidget*&);
2015-11-12 01:33:16 +01:00
void getX11ButtonState (int);
2015-05-23 13:35:12 +02:00
bool parseX11Mouse();
bool parseSGRMouse();
bool parseUrxvtMouse();
2015-08-22 18:53:52 +02:00
#ifdef F_HAVE_LIBGPM
2015-10-17 19:40:43 +02:00
int gpmEvent (bool = true);
2015-05-23 13:35:12 +02:00
bool processGpmEvent();
#endif
void processMouseEvent();
void processResizeEvent();
int processTimerEvent();
void processTerminalUpdate();
void processCloseWidget();
2015-05-23 13:35:12 +02:00
bool processNextEvent();
friend class FDialog;
2015-05-23 13:35:12 +02:00
friend class FWidget;
friend class FWindow;
public:
2016-02-07 22:02:38 +01:00
FApplication (int&, char**& ); // constructor
2015-05-23 13:35:12 +02:00
virtual ~FApplication(); // destructor
const char* getClassName() const;
int argc() const;
char** argv() const;
FWidget* mainWidget() const;
FWidget* focusWidget() const;
bool unprocessedInput() const;
2015-05-23 13:35:12 +02:00
static void print_cmd_Options();
void setMainWidget (FWidget*);
int exec(); // run
int enter_loop();
void exit_loop();
2015-09-27 16:45:28 +02:00
static void exit (int = 0);
2015-05-23 13:35:12 +02:00
void quit();
bool isQuit();
static bool sendEvent (FObject*, FEvent*);
static void queueEvent (FObject*, FEvent*);
static void sendQueuedEvents ();
static bool eventInQueue();
static bool removeQueuedEvent(FObject*);
};
#pragma pack(pop)
// FApplication inline functions
//----------------------------------------------------------------------
inline const char* FApplication::getClassName() const
{ return "FApplication"; }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
inline int FApplication::argc() const
{ return app_argc; }
//----------------------------------------------------------------------
inline char** FApplication::argv() const
{ return app_argv; }
//----------------------------------------------------------------------
inline FWidget* FApplication::mainWidget() const
{ return main_widget; }
//----------------------------------------------------------------------
inline FWidget* FApplication::focusWidget() const
{ return focus_widget; }
//----------------------------------------------------------------------
inline bool FApplication::unprocessedInput() const
{ return input_data_pending; }
2015-05-23 13:35:12 +02:00
#endif // _FAPPLICATION_H