mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
rainbow: LinuxFb: doublecklick support, font metrics init fix, SDLFb: undo repeat click fix
git-svn-id: svn://ultimatepp.org/upp/trunk@3685 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
bb411c52c9
commit
0283f092a3
4 changed files with 61 additions and 22 deletions
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
using namespace Upp;
|
using namespace Upp;
|
||||||
|
|
||||||
struct App : TopWindow {
|
class App : public TopWindow {
|
||||||
|
public:
|
||||||
|
typedef App CLASSNAME;
|
||||||
ArrayCtrl log;
|
ArrayCtrl log;
|
||||||
|
|
||||||
void Log(const String& s)
|
void Log(const String& s)
|
||||||
|
|
@ -205,6 +207,11 @@ struct App : TopWindow {
|
||||||
Log("Layout");
|
Log("Layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnTimer()
|
||||||
|
{
|
||||||
|
Log("Timer");
|
||||||
|
}
|
||||||
|
|
||||||
App()
|
App()
|
||||||
{
|
{
|
||||||
SetFrame(InsetFrame());
|
SetFrame(InsetFrame());
|
||||||
|
|
@ -214,6 +221,7 @@ struct App : TopWindow {
|
||||||
log.AddColumn("");
|
log.AddColumn("");
|
||||||
log.NoHeader();
|
log.NoHeader();
|
||||||
Add(log.HSizePos().BottomPos(0, 200));
|
Add(log.HSizePos().BottomPos(0, 200));
|
||||||
|
SetTimeCallback(-1000, THISBACK(OnTimer));
|
||||||
}
|
}
|
||||||
|
|
||||||
~App()
|
~App()
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ NAMESPACE_UPP
|
||||||
|
|
||||||
#define LLOG(x) //LOG(x)
|
#define LLOG(x) //LOG(x)
|
||||||
|
|
||||||
bool GetMouseLeft() { return mouseb & 0x1; }
|
bool GetMouseLeft() { return mouseb & (1<<0); }
|
||||||
bool GetMouseRight() { return mouseb & 0x2; }
|
bool GetMouseRight() { return mouseb & (1<<1); }
|
||||||
bool GetMouseMiddle() { return mouseb & 0x4; }
|
bool GetMouseMiddle() { return mouseb & (1<<2); }
|
||||||
|
|
||||||
void purgefd(int fd)
|
void purgefd(int fd)
|
||||||
{
|
{
|
||||||
|
|
@ -66,6 +66,41 @@ int has_imps2(int fd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dword lastbdowntime[8] = {0};
|
||||||
|
dword isdblclick[8] = {0};
|
||||||
|
|
||||||
|
void handle_button(dword ct, dword mouseb, dword bm, int i,
|
||||||
|
dword df, dword rf, dword dbf, dword uf)
|
||||||
|
{
|
||||||
|
dword m = (1<<i);
|
||||||
|
if(bm & m)
|
||||||
|
{
|
||||||
|
if(mouseb & m) //down
|
||||||
|
{
|
||||||
|
if(isdblclick[i] && (abs(int(ct) - int(lastbdowntime[i])) < 400))
|
||||||
|
{
|
||||||
|
Ctrl::DoMouseFB(dbf, mousep);
|
||||||
|
isdblclick[i] = 0; //reset, to go ahead sending repeats
|
||||||
|
}
|
||||||
|
else if(!isdblclick[i])
|
||||||
|
{
|
||||||
|
//Ctrl::DoMouseFB(rf, mousep);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastbdowntime[i] = ct;
|
||||||
|
isdblclick[i] = 0; //prepare for repeat
|
||||||
|
Ctrl::DoMouseFB(df, mousep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //up
|
||||||
|
{
|
||||||
|
isdblclick[i] = 1; //indicate maybe a dblclick
|
||||||
|
Ctrl::DoMouseFB(uf, mousep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void handle_mouse()
|
void handle_mouse()
|
||||||
{
|
{
|
||||||
static int offs = 0;
|
static int offs = 0;
|
||||||
|
|
@ -109,11 +144,15 @@ void handle_mouse()
|
||||||
Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, mousep);
|
Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, mousep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bm = b ^ mouseb;
|
|
||||||
|
dword bm = b ^ mouseb;
|
||||||
mouseb = b; //for GetMouse*
|
mouseb = b; //for GetMouse*
|
||||||
if(bm & 0x1) Ctrl::DoMouseFB((mouseb & 0x1)?Ctrl::LEFTDOWN:Ctrl::LEFTUP, mousep);
|
dword ct = GetTickCount();
|
||||||
if(bm & 0x2) Ctrl::DoMouseFB((mouseb & 0x2)?Ctrl::RIGHTDOWN:Ctrl::RIGHTUP, mousep);
|
|
||||||
if(bm & 0x4) Ctrl::DoMouseFB((mouseb & 0x4)?Ctrl::MIDDLEDOWN:Ctrl::MIDDLEUP, mousep);
|
handle_button(ct, mouseb, bm, 0, Ctrl::LEFTDOWN, Ctrl::LEFTREPEAT, Ctrl::LEFTDOUBLE, Ctrl::LEFTUP);
|
||||||
|
handle_button(ct, mouseb, bm, 1, Ctrl::RIGHTDOWN, Ctrl::RIGHTREPEAT, Ctrl::RIGHTDOUBLE, Ctrl::RIGHTUP);
|
||||||
|
handle_button(ct, mouseb, bm, 2, Ctrl::MIDDLEDOWN, Ctrl::MIDDLEREPEAT, Ctrl::MIDDLEDOUBLE, Ctrl::MIDDLEUP);
|
||||||
|
|
||||||
if(dz) Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, mousep, dz*120);
|
if(dz) Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, mousep, dz*120);
|
||||||
}
|
}
|
||||||
if(i < n) {
|
if(i < n) {
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ void leavevt()
|
||||||
void FBInit(const String& fbdevice)
|
void FBInit(const String& fbdevice)
|
||||||
{
|
{
|
||||||
Ctrl::InitFB();
|
Ctrl::InitFB();
|
||||||
|
Font::SetStdFont(ScreenSans(12)); //FIXME general handling
|
||||||
|
|
||||||
fbfd = open(fbdevice, O_RDWR);
|
fbfd = open(fbdevice, O_RDWR);
|
||||||
if (!fbfd) {
|
if (!fbfd) {
|
||||||
|
|
@ -221,7 +222,11 @@ void FBInit(const String& fbdevice)
|
||||||
close(tfd);
|
close(tfd);
|
||||||
LLOG("probable new VT: " << cvt);
|
LLOG("probable new VT: " << cvt);
|
||||||
|
|
||||||
if((geteuid() == 0) && (cvt > 0)) {
|
if(geteuid() != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: not running as ROOT, mouse handling pobably unavailable\n");
|
||||||
|
}
|
||||||
|
else if(cvt > 0) {
|
||||||
LLOG("try to open the NEW assigned VT: " << cvt);
|
LLOG("try to open the NEW assigned VT: " << cvt);
|
||||||
for(int i=0; vcs[i] && (keyb_fd < 0); ++i) {
|
for(int i=0; vcs[i] && (keyb_fd < 0); ++i) {
|
||||||
char path[32];
|
char path[32];
|
||||||
|
|
|
||||||
|
|
@ -93,19 +93,6 @@ void HandleSDLEvent(SDL_Event* event)
|
||||||
//case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEELDOUBLE, p, -120); break;
|
//case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEELDOUBLE, p, -120); break;
|
||||||
}
|
}
|
||||||
isdblclick[bi] = 0; //reset, to go ahead sending repeats
|
isdblclick[bi] = 0; //reset, to go ahead sending repeats
|
||||||
//but sdl doesnt send repeated mouse down
|
|
||||||
//FIXME fake repeated mousedown
|
|
||||||
}
|
|
||||||
else if(!isdblclick[bi]) //events might not be right
|
|
||||||
{
|
|
||||||
switch(bi)
|
|
||||||
{
|
|
||||||
case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTREPEAT, p); break;
|
|
||||||
case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTREPEAT, p); break;
|
|
||||||
case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEREPEAT, p); break;
|
|
||||||
//case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEELDOUBLE, p, +120); break;
|
|
||||||
//case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEELDOUBLE, p, -120); break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue