diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-03-15 06:42:06 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-08-29 12:15:32 +0200 |
| commit | c720aae51515907ae82ee02df80bd084f291d4b1 (patch) | |
| tree | 7fbf3569f35966891df68490b047b30c9ec20bcd /src/drivers/Cocoa | |
| parent | 28981f6fd3971aaf7ff6527ee1cdeb9d886c4a4a (diff) | |
Make hybrid Wayland/X11 platform.
Diffstat (limited to 'src/drivers/Cocoa')
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx | 30 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm | 2 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx | 6 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx | 14 |
4 files changed, 34 insertions, 18 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx index 6491332e3..d1ed8df1e 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Gl_Window_Driver.cxx @@ -1,7 +1,7 @@ // // Class Fl_Cocoa_Gl_Window_Driver for the Fast Light Tool Kit (FLTK). // -// Copyright 2021 by Bill Spitzak and others. +// Copyright 2021-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -66,7 +66,7 @@ GLContext Fl_Cocoa_Gl_Window_Driver::create_gl_context(Fl_Window* window, const // resets the pile of string textures used to draw strings // necessary before the first context is created if (!shared_ctx) gl_texture_reset(); - context = Fl_Cocoa_Window_Driver::create_GLcontext_for_window(((Fl_Cocoa_Gl_Choice*)g)->pixelformat, shared_ctx, window); + context = Fl_Cocoa_Window_Driver::create_GLcontext_for_window(((Fl_Cocoa_Gl_Choice*)g)->pixelformat, (NSOpenGLContext*)shared_ctx, window); if (!context) return 0; add_context(context); return (context); @@ -76,7 +76,7 @@ void Fl_Cocoa_Gl_Window_Driver::set_gl_context(Fl_Window* w, GLContext context) if (context != cached_context || w != cached_window) { cached_context = context; cached_window = w; - Fl_Cocoa_Window_Driver::GLcontext_makecurrent(context); + Fl_Cocoa_Window_Driver::GLcontext_makecurrent((NSOpenGLContext*)context); } } @@ -86,7 +86,7 @@ void Fl_Cocoa_Gl_Window_Driver::delete_gl_context(GLContext context) { cached_window = 0; Fl_Cocoa_Window_Driver::GL_cleardrawable(); } - Fl_Cocoa_Window_Driver::GLcontext_release(context); + Fl_Cocoa_Window_Driver::GLcontext_release((NSOpenGLContext*)context); del_context(context); } @@ -143,7 +143,7 @@ void Fl_Cocoa_Gl_Window_Driver::make_current_before() { if (d->changed_resolution()){ d->changed_resolution(false); pWindow->invalidate(); - Fl_Cocoa_Window_Driver::GLcontext_update(pWindow->context()); + Fl_Cocoa_Window_Driver::GLcontext_update((NSOpenGLContext*)pWindow->context()); } } @@ -179,13 +179,13 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() { glRasterPos3f(pos[0], pos[1], pos[2]); // restore original glRasterPos } else - Fl_Cocoa_Window_Driver::flush_context(pWindow->context());//aglSwapBuffers((AGLContext)context_); + Fl_Cocoa_Window_Driver::flush_context((NSOpenGLContext*)pWindow->context());//aglSwapBuffers((AGLContext)context_); } char Fl_Cocoa_Gl_Window_Driver::swap_type() {return copy;} void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int w, int h) { - Fl_Cocoa_Window_Driver::GLcontext_update(pWindow->context()); + Fl_Cocoa_Window_Driver::GLcontext_update((NSOpenGLContext*)pWindow->context()); } /* Some old Apple hardware doesn't implement the GL_EXT_texture_rectangle extension. @@ -202,7 +202,7 @@ char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, i fl_draw(str, n, 0, fl_height() - fl_descent()); // get the alpha channel only of the bitmap char *alpha_buf = new char[w*h], *r = alpha_buf, *q; - q = (char*)CGBitmapContextGetData(surf->offscreen()); + q = (char*)CGBitmapContextGetData((CGContextRef)surf->offscreen()); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { *r++ = *(q+3); @@ -215,7 +215,7 @@ char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, i } void Fl_Cocoa_Gl_Window_Driver::gl_start() { - Fl_Cocoa_Window_Driver::gl_start(gl_start_context); + Fl_Cocoa_Window_Driver::gl_start((NSOpenGLContext*)gl_start_context); } // convert BGRA to RGB and also exchange top and bottom @@ -247,8 +247,8 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int if (factor != 1) { w *= factor; h *= factor; x *= factor; y *= factor; } - Fl_Cocoa_Window_Driver::GLcontext_makecurrent(glw->context()); - Fl_Cocoa_Window_Driver::flush_context(glw->context()); // to capture also the overlay and for directGL demo + Fl_Cocoa_Window_Driver::GLcontext_makecurrent((NSOpenGLContext*)glw->context()); + Fl_Cocoa_Window_Driver::flush_context((NSOpenGLContext*)glw->context()); // to capture also the overlay and for directGL demo // Read OpenGL context pixels directly. // For extra safety, save & restore OpenGL states that are changed glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); @@ -266,10 +266,16 @@ Fl_RGB_Image* Fl_Cocoa_Gl_Window_Driver::capture_gl_rectangle(int x, int y, int baseAddress = convert_BGRA_to_RGB(baseAddress, w, h, mByteWidth); Fl_RGB_Image *img = new Fl_RGB_Image(baseAddress, w, h, 3, 3 * w); img->alloc_array = 1; - Fl_Cocoa_Window_Driver::flush_context(glw->context()); + Fl_Cocoa_Window_Driver::flush_context((NSOpenGLContext*)glw->context()); return img; } + +FL_EXPORT NSOpenGLContext *fl_mac_glcontext(GLContext rc) { + return (NSOpenGLContext*)rc; +} + + class Fl_Gl_Cocoa_Plugin : public Fl_Cocoa_Plugin { public: Fl_Gl_Cocoa_Plugin() : Fl_Cocoa_Plugin(name()) { } diff --git a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm index fd278cf75..c587caf37 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm @@ -347,7 +347,7 @@ int Fl_Cocoa_Printer_Driver::begin_page (void) CGContextSaveGState(gc); CGContextSaveGState(gc); fl_line_style(FL_SOLID); - fl_window = (Window)1; // TODO: something better + fl_window = (FLWindow*)1; // TODO: something better fl_clip_region(0); return status != noErr; } diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx index 01c3b0f95..33b0392c4 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx @@ -140,7 +140,7 @@ void Fl_Cocoa_Screen_Driver::grab(Fl_Window* win) { if (win) { if (!Fl::grab_) { - fl_capture = Fl_X::i(Fl::first_window())->xid; + fl_capture = (FLWindow*)(Fl_X::i(Fl::first_window())->xid); Fl_Cocoa_Window_Driver::driver(Fl::first_window())->set_key_window(); } Fl::grab_ = win; @@ -315,8 +315,8 @@ int Fl_Cocoa_Screen_Driver::input_widget_handle_key(int key, unsigned mods, unsi void Fl_Cocoa_Screen_Driver::offscreen_size(Fl_Offscreen off, int &width, int &height) { - width = CGBitmapContextGetWidth(off); - height = CGBitmapContextGetHeight(off); + width = CGBitmapContextGetWidth((CGContextRef)off); + height = CGBitmapContextGetHeight((CGContextRef)off); } Fl_RGB_Image *Fl_Cocoa_Screen_Driver::read_win_rectangle(int X, int Y, int w, int h, Fl_Window *window, diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx index b7f213da0..019e2b7f5 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx @@ -224,10 +224,10 @@ void Fl_Cocoa_Window_Driver::hide() { if (ip && !parent()) pWindow->cursor(FL_CURSOR_DEFAULT); if ( hide_common() ) return; q_release_context(this); - if ( ip->xid == fl_window ) + if ( ip->xid == (fl_uintptr_t)fl_window ) fl_window = 0; if (ip->region) Fl_Graphics_Driver::default_driver().XDestroyRegion(ip->region); - destroy(ip->xid); + destroy((FLWindow*)ip->xid); delete subRect(); delete ip; } @@ -338,3 +338,13 @@ int Fl_Cocoa_Window_Driver::screen_num() { if (pWindow->parent()) return pWindow->top_window()->screen_num(); else return screen_num_; } + + +FLWindow *fl_mac_xid(const Fl_Window *win) { + return (FLWindow*)Fl_Window_Driver::xid(win); +} + + +Fl_Window *fl_mac_find(FLWindow *xid) { + return Fl_Window_Driver::find((fl_uintptr_t)xid); +} |
