CtrlLib: Fixed to compile in Posix

git-svn-id: svn://ultimatepp.org/upp/trunk@9907 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-06-07 12:48:12 +00:00
parent 9c66f416b7
commit 2e381aa4c6
3 changed files with 24 additions and 24 deletions

View file

@ -32,7 +32,7 @@ _DBG_
EVENT_TEXT,
};
struct Event0 {
struct GEvent0 {
int time;
int windowid;
int type;
@ -42,16 +42,16 @@ _DBG_
int count;
};
struct Event : Moveable<Event, Event0> {
struct GEvent : Moveable<GEvent, GEvent0> {
GdkEvent *event;
void Free();
void Set(const Event& e);
Event(const Event& e);
void operator=(const Event& e);
void Set(const GEvent& e);
GEvent(const GEvent& e);
void operator=(const GEvent& e);
Event();
~Event();
GEvent();
~GEvent();
};
struct Win : Moveable<Win> {
@ -65,7 +65,7 @@ _DBG_
bool SweepConfigure(bool wait);
bool SweepFocus(bool wait);
static BiVector<Event> Events;
static BiVector<GEvent> Events;
static Vector< Ptr<Ctrl> > activePopup; // created with 'activate' flag - usually menu
static Vector< Ptr<Ctrl> > visiblePopup; // any popup visible on screen
static Vector<Win> wins;
@ -176,7 +176,7 @@ public:
static Point CurrentMousePos;
static guint CurrentState;
static guint32 CurrentTime;
static Event CurrentEvent;
static GEvent CurrentEvent;
GdkWindow *gdk() const { return top ? top->window->window : NULL; }
GtkWindow *gtk() const { return top ? (GtkWindow *)top->window : NULL; }

View file

@ -7,12 +7,12 @@ NAMESPACE_UPP
#define LLOG(x) // DLOG(rmsecs() << ' ' << x)
//_DBG_ #define LOG_EVENTS
BiVector<Ctrl::Event> Ctrl::Events;
BiVector<Ctrl::GEvent> Ctrl::Events;
Point Ctrl::CurrentMousePos;
guint Ctrl::CurrentState;
guint32 Ctrl::CurrentTime;
Ctrl::Event Ctrl::CurrentEvent;
Ctrl::GEvent Ctrl::CurrentEvent;
bool GetShift() { return Ctrl::CurrentState & GDK_SHIFT_MASK; }
bool GetCtrl() { return Ctrl::CurrentState & GDK_CONTROL_MASK; }
@ -194,12 +194,12 @@ int Ctrl::DoButtonEvent(GdkEvent *event, bool press)
return Null;
}
Ctrl::Event::Event()
Ctrl::GEvent::GEvent()
{
event = NULL;
}
void Ctrl::Event::Free()
void Ctrl::GEvent::Free()
{
if(event) {
gdk_event_free(event);
@ -207,23 +207,23 @@ void Ctrl::Event::Free()
}
}
void Ctrl::Event::Set(const Event& e)
void Ctrl::GEvent::Set(const GEvent& e)
{
*(Event0 *)this = e;
*(GEvent0 *)this = e;
event = e.event ? gdk_event_copy(e.event) : NULL;
}
Ctrl::Event::~Event()
Ctrl::GEvent::~GEvent()
{
Free();
}
Ctrl::Event::Event(const Event& e)
Ctrl::GEvent::GEvent(const GEvent& e)
{
Set(e);
}
void Ctrl::Event::operator=(const Event& e)
void Ctrl::GEvent::operator=(const GEvent& e)
{
if(this == &e)
return;
@ -235,7 +235,7 @@ void Ctrl::AddEvent(gpointer user_data, int type, const Value& value, GdkEvent *
{
if(Events.GetCount() > 50000)
return;
Event& e = Events.AddTail();
GEvent& e = Events.AddTail();
e.windowid = (uint32)(uintptr_t)user_data;
e.type = type;
e.value = value;
@ -502,9 +502,9 @@ bool Ctrl::ProcessEvent0(bool *quit, bool fetch)
ASSERT(IsMainThread());
bool r = false;
if(IsWaitingEvent0(fetch)) {
while(Events.GetCount() > 1) { // Event compression (coalesce autorepeat, mouse moves/wheel, configure)
Event& a = Events[0];
Event& b = Events[1];
while(Events.GetCount() > 1) { // GEvent compression (coalesce autorepeat, mouse moves/wheel, configure)
GEvent& a = Events[0];
GEvent& b = Events[1];
if(b.type == a.type && a.windowid == b.windowid && a.state == b.state) {
if(a.type == GDK_KEY_PRESS && a.value == b.value)
b.count += a.count;
@ -520,7 +520,7 @@ bool Ctrl::ProcessEvent0(bool *quit, bool fetch)
break;
FocusSync();
}
Event& e = Events.Head();
GEvent& e = Events.Head();
CurrentTime = e.time;
CurrentMousePos = e.mousepos;
CurrentState = e.state;

View file

@ -407,7 +407,7 @@ bool Ctrl::SweepConfigure(bool wait)
bool r = false;
FetchEvents(wait);
for(int i = 0; i < Events.GetCount() && this_; i++) {
Event& e = Events[i];
GEvent& e = Events[i];
if(e.type == GDK_CONFIGURE && this_ && top->id == e.windowid) {
Rect rect = e.value;
LLOG("SweepConfigure " << rect);