mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -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;
|
||||
|
||||
struct App : TopWindow {
|
||||
class App : public TopWindow {
|
||||
public:
|
||||
typedef App CLASSNAME;
|
||||
ArrayCtrl log;
|
||||
|
||||
void Log(const String& s)
|
||||
|
|
@ -205,6 +207,11 @@ struct App : TopWindow {
|
|||
Log("Layout");
|
||||
}
|
||||
|
||||
void OnTimer()
|
||||
{
|
||||
Log("Timer");
|
||||
}
|
||||
|
||||
App()
|
||||
{
|
||||
SetFrame(InsetFrame());
|
||||
|
|
@ -214,6 +221,7 @@ struct App : TopWindow {
|
|||
log.AddColumn("");
|
||||
log.NoHeader();
|
||||
Add(log.HSizePos().BottomPos(0, 200));
|
||||
SetTimeCallback(-1000, THISBACK(OnTimer));
|
||||
}
|
||||
|
||||
~App()
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ NAMESPACE_UPP
|
|||
|
||||
#define LLOG(x) //LOG(x)
|
||||
|
||||
bool GetMouseLeft() { return mouseb & 0x1; }
|
||||
bool GetMouseRight() { return mouseb & 0x2; }
|
||||
bool GetMouseMiddle() { return mouseb & 0x4; }
|
||||
bool GetMouseLeft() { return mouseb & (1<<0); }
|
||||
bool GetMouseRight() { return mouseb & (1<<1); }
|
||||
bool GetMouseMiddle() { return mouseb & (1<<2); }
|
||||
|
||||
void purgefd(int fd)
|
||||
{
|
||||
|
|
@ -66,6 +66,41 @@ int has_imps2(int fd)
|
|||
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()
|
||||
{
|
||||
static int offs = 0;
|
||||
|
|
@ -109,11 +144,15 @@ void handle_mouse()
|
|||
Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, mousep);
|
||||
}
|
||||
|
||||
int bm = b ^ mouseb;
|
||||
|
||||
dword bm = b ^ mouseb;
|
||||
mouseb = b; //for GetMouse*
|
||||
if(bm & 0x1) Ctrl::DoMouseFB((mouseb & 0x1)?Ctrl::LEFTDOWN:Ctrl::LEFTUP, mousep);
|
||||
if(bm & 0x2) Ctrl::DoMouseFB((mouseb & 0x2)?Ctrl::RIGHTDOWN:Ctrl::RIGHTUP, mousep);
|
||||
if(bm & 0x4) Ctrl::DoMouseFB((mouseb & 0x4)?Ctrl::MIDDLEDOWN:Ctrl::MIDDLEUP, mousep);
|
||||
dword ct = GetTickCount();
|
||||
|
||||
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(i < n) {
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ void leavevt()
|
|||
void FBInit(const String& fbdevice)
|
||||
{
|
||||
Ctrl::InitFB();
|
||||
Font::SetStdFont(ScreenSans(12)); //FIXME general handling
|
||||
|
||||
fbfd = open(fbdevice, O_RDWR);
|
||||
if (!fbfd) {
|
||||
|
|
@ -221,7 +222,11 @@ void FBInit(const String& fbdevice)
|
|||
close(tfd);
|
||||
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);
|
||||
for(int i=0; vcs[i] && (keyb_fd < 0); ++i) {
|
||||
char path[32];
|
||||
|
|
|
|||
|
|
@ -93,19 +93,6 @@ void HandleSDLEvent(SDL_Event* event)
|
|||
//case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEELDOUBLE, p, -120); break;
|
||||
}
|
||||
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
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue