GLCtrl: Removed dependency on glext

git-svn-id: svn://ultimatepp.org/upp/trunk@13881 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-01-14 10:33:43 +00:00
parent 35aa73e7d5
commit e8696e2fe8
7 changed files with 58 additions and 22 deletions

View file

@ -17,7 +17,7 @@ Atom XAtomRaw(const char *name)
Atom XAtom(const char *name)
{
GuiLock __;
GuiLock __;
Atom x;
INTERLOCKED {
static VectorMap<String, int> atoms;
@ -33,14 +33,14 @@ Atom XAtom(const char *name)
String XAtomName(Atom atom)
{
GuiLock __;
GuiLock __;
LLOG("GetAtomName");
return XGetAtomName(Xdisplay, atom);
}
String GetProperty(Window w, Atom property, Atom rtype)
{
GuiLock __;
GuiLock __;
LLOG("GetProperty");
String result;
int format;
@ -52,9 +52,9 @@ String GetProperty(Window w, Atom property, Atom rtype)
while(after > 0) {
if(XGetWindowProperty(Xdisplay, w, property, offset, rsize, XFalse,
rtype, &type, &format, &nitems, &after, &data) != Success)
break;
break;
if(type == None)
break;
break;
if(data) {
int len = format == 32 ? sizeof(unsigned long) * nitems : nitems * (format >> 3);
result.Cat(data, len);
@ -70,7 +70,7 @@ String GetProperty(Window w, Atom property, Atom rtype)
}
bool WaitForEvent(Window w, int type, XEvent& event){
GuiLock __;
GuiLock __;
for(int i = 0; i < 80; i++) {
if(XCheckTypedWindowEvent(Xdisplay, w, type, &event))
return true;
@ -84,7 +84,7 @@ bool WaitForEvent(Window w, int type, XEvent& event){
String ReadPropertyData(Window w, Atom property, Atom rtype)
{
GuiLock __;
GuiLock __;
static Atom XA_INCR = XAtom("INCR");
Atom type;
int format;
@ -120,7 +120,7 @@ String ReadPropertyData(Window w, Atom property, Atom rtype)
Vector<int> GetPropertyInts(Window w, Atom property, Atom rtype)
{
GuiLock __;
GuiLock __;
Vector<int> result;
String p = GetProperty(w, property, rtype);
const long int *ptr = (const long int *)~p;
@ -141,7 +141,7 @@ bool X11ErrorTrap;
bool Ctrl::TrapX11Errors()
{
GuiLock __;
GuiLock __;
bool b = X11ErrorTrap;
X11ErrorTrap = true;
return b;
@ -149,7 +149,7 @@ bool Ctrl::TrapX11Errors()
void Ctrl::UntrapX11Errors(bool b)
{
GuiLock __;
GuiLock __;
X11ErrorTrap = b;
}
@ -445,7 +445,7 @@ void Ctrl::InitX11(const char *display)
void Ctrl::ExitX11()
{
GuiLock __;
GuiLock __;
// if(xic)
// XDestroyIC(xic);
TopWindow::ShutdownWindows();

View file

@ -262,7 +262,7 @@ void Ctrl::EventProc(XWindow& w, XEvent *event)
}
#ifndef PLATFORM_OSX11
if(GetCtrl() || GetAlt()) { // fix Ctrl+Shift+1 etc...
keysym = decode(event->xkey.keycode, 0xa, '1', 0xb, '2', 0xc, '3', 0xd, '4',
keysym = decode((int)event->xkey.keycode, 0xa, '1', 0xb, '2', 0xc, '3', 0xd, '4',
0xe, '5', 0xf, '6', 0x10, '7', 0x11, '8', 0x12, '9', 0x13, '0',
keysym);
}

View file

@ -6,14 +6,15 @@
- Pushbutton push does not look nice
- Disabled empty combobox (FileSel::SelectDir) does not look nice
- Problem with radio buttons in StdStyle - perhaps too big?
- ide menu in X11 ch
- disabled combobox issue
- OpenGL
NTH:
- spinbutton cosmetics
- Redmond scrollbars width
- Improve scrollbars borders
PROBABLY DONE:
- Problem with hot3 in scrollbar horizontal (check in SD)
- Improve scrollbars button borders
- Error state (red) EditField cosmetics
DONE:
@ -66,3 +67,4 @@ DONE:
- FileSel icons for Video etc
- ColumnList selected item background (Mint-X)
- disabled color in Breeze-Dark
- Problem with hot3 in scrollbar horizontal (check in SD)

View file

@ -210,10 +210,10 @@ void SOImages(int imli, dword flags)
{
for(int st = 0; st < 4; st++) {
Gtk_State(st, flags);
CtrlsImg::Set(imli++, CairoImage(16, 16, [&](cairo_t *cr) {
gtk_render_background(sCtx, cr, 0, 0, 16, 16);
gtk_render_frame(sCtx, cr, 0, 0, 16, 16);
gtk_render_check(sCtx, cr, 0, 0, 16, 16);
CtrlsImg::Set(imli++, CairoImage(14, 14, [&](cairo_t *cr) {
gtk_render_background(sCtx, cr, 0, 0, 14, 14);
gtk_render_frame(sCtx, cr, 0, 0, 14, 14);
gtk_render_check(sCtx, cr, 0, 0, 14, 14);
}));
}
}

View file

@ -59,6 +59,7 @@ private:
virtual Image MouseEvent(int event, Point p, int zdelta, dword keyflags);
public:
void ExecuteGL(Event<> paint, bool swap_buffers);
GLPane() { NoWantFocus(); }
};
#elif defined(PLATFORM_WIN32)

View file

@ -6,8 +6,6 @@ library(WIN32 GCC) "glaux glu32 opengl32";
library(LINUX | BSD) "GL GLU";
library((LINUX | BSD) & !X11 & !NOGTK) "gdkglext-x11-1.0 gtkglext-x11-1.0";
file
GLCtrl.h,
Win32GLCtrl.cpp,

View file

@ -44,6 +44,36 @@ void GLCtrl::GLPane::SetAttributes(unsigned long &ValueMask, XSetWindowAttribute
winAttributes.save_under = XFalse;
}
void GLCtrl::GLPane::ExecuteGL(Event<> paint, bool swap_buffers)
{
MemoryIgnoreLeaksBlock __;
glXMakeCurrent((XDisplay*)Xdisplay, GetWindow(), s_GLXContext);
ONCELOCK {
glewInit();
}
paint();
if(swap_buffers)
glXSwapBuffers((XDisplay*)Xdisplay, GetWindow());
else
glFlush();
glXMakeCurrent((XDisplay*)Xdisplay, GetWindow(), NULL);
}
#if 0
void GLCtrl::GLPane::Paint(Draw& w)
{
Size sz = GetSize();
if(!s_GLXContext || sz.cx == 0 || sz.cy == 0)
return;
ExecuteGL([&] { ctrl->DoGLPaint(); }, doubleBuffering);
}
#else
void GLCtrl::GLPane::Paint(Draw &draw)
{
if(!s_GLXContext)
@ -64,6 +94,11 @@ void GLCtrl::GLPane::Paint(Draw &draw)
glXMakeCurrent( (XDisplay*)Xdisplay, GetWindow(), NULL);
}
#endif
void GLCtrl::ExecuteGL(Event<> paint, bool swap_buffers)
{
pane.ExecuteGL(paint, swap_buffers);
}
#endif