FLTK logo

[master] c02fba6 - Slight simplification of Fl_Wayland_Graphics_Driver::create_shm_buffer().

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] c02fba6 - Slight simplification of Fl_Wayland_Graphics_Driver::create_shm_buffer(). "ManoloFLTK" May 07, 2022  
 
commit c02fba6bb9af3254bc617eb090bce7820f58614a
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sat May 7 18:08:07 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sat May 7 18:08:07 2022 +0200

    Slight simplification of Fl_Wayland_Graphics_Driver::create_shm_buffer().

 src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
index ffc86bd..f0b4fd6 100644
--- src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Graphics_Driver.cxx
@@ -36,18 +36,6 @@ extern "C" {
   int os_create_anonymous_file(off_t);
 }
 
-static int create_anonymous_file(int size, char **pshared)
-{
-  int fd = os_create_anonymous_file(size);
-  *pshared = (char*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-  if (*pshared == MAP_FAILED) {
-    close(fd);
-    Fl::fatal("mmap failed: %s\n", strerror(errno));
-  }
-//printf("create_anonymous_file: %d\n",size);
-  return fd;
-}
-
 
 struct fl_wld_buffer *Fl_Wayland_Graphics_Driver::create_shm_buffer(int width, int height)
 {
@@ -66,7 +54,12 @@ struct fl_wld_buffer *Fl_Wayland_Graphics_Driver::create_shm_buffer(int width, i
       close(fd);
     }
     if (size > pool_size) pool_size = 2 * size;
-    fd = create_anonymous_file(pool_size, &pool_memory);
+    fd = os_create_anonymous_file(pool_size);
+    pool_memory = (char*)mmap(NULL, pool_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+    if (pool_memory == MAP_FAILED) {
+      close(fd);
+      Fl::fatal("mmap failed: %s\n", strerror(errno));
+    }
     Fl_Wayland_Screen_Driver *scr_driver = (Fl_Wayland_Screen_Driver*)Fl::screen_driver();
     pool = wl_shm_create_pool(scr_driver->wl_shm, fd, pool_size);
   }
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.