Usermode/AxWin4 - Tweak handling of AcessNative (doesn't have SHM and mmap)
authorJohn Hodge (sonata) <[email protected]>
Thu, 6 Nov 2014 22:46:15 +0000 (06:46 +0800)
committerJohn Hodge (sonata) <[email protected]>
Thu, 6 Nov 2014 22:46:15 +0000 (06:46 +0800)
Usermode/Applications/axwin4_src/Server/CSurface.cpp
Usermode/Applications/axwin4_src/Server/CWindow.cpp
Usermode/Applications/axwin4_src/UI/main.c

index 07d8bfb..27078d8 100644 (file)
@@ -31,16 +31,27 @@ CSurface::~CSurface()
 
 uint64_t CSurface::GetSHMHandle()
 {
-       // 1. Free local buffer
-       delete m_data;
-       // 2. Allocate a copy in SHM
-       m_fd = _SysOpen("/Devices/shm/anon", OPENFLAG_WRITE|OPENFLAG_READ);
-       if(m_fd==-1)    throw ::std::system_error(errno, ::std::system_category());
        size_t  size = m_rect.m_w*m_rect.m_h*4;
-       _SysTruncate(m_fd, size);
+       if( m_fd == -1 )
+       {
+               // 2. Allocate a copy in SHM
+               m_fd = _SysOpen("/Devices/shm/anon", OPENFLAG_WRITE|OPENFLAG_READ);
+               if(m_fd == -1) {
+                       _SysDebug("GetSHMHandle: Unable to open anon SHM");
+                       return -1;
+               }
+               // 1. Free local buffer
+               delete m_data;
+               _SysTruncate(m_fd, size);
+       }
+       else
+       {
+               _SysMUnMap(m_data, size);
+       }
        // 3. mmap shm copy
        m_data = static_cast<uint32_t*>( _SysMMap(nullptr, size, MMAP_PROT_WRITE, 0, m_fd, 0) );
        if(!m_data)     throw ::std::system_error(errno, ::std::system_category());
+       
        return _SysMarshalFD(m_fd);
 }
 
index a0067a7..392fd47 100644 (file)
@@ -16,7 +16,8 @@ CWindow::CWindow(CCompositor& compositor, CClient& client, const ::std::string&
        m_surface(0,0,0,0),
        m_compositor(compositor),
        m_client(client),
-       m_name(name)
+       m_name(name),
+       m_is_shown(false)
 {
        _SysDebug("CWindow::CWindow()");
 }
index 37ee08c..c831558 100644 (file)
@@ -44,16 +44,23 @@ tAxWin4_Window *CreateBGWin(int w, int h)
        
        // Load background image
        uint32_t *buf = AxWin4_GetWindowBuffer(bgwin);
-       for( size_t y = 0; y < h; y ++ )
+       if( buf )
        {
-               for(size_t x = 0; x < w; x ++ )
+               for( size_t y = 0; y < h; y ++ )
                {
-                       uint8_t r = y * 256 / h;
-                       uint8_t g = 0;
-                       uint8_t b = x * 256 / w;
-                       buf[y*w+x] = (r << 16) | (g << 8) | b;
+                       for(size_t x = 0; x < w; x ++ )
+                       {
+                               uint8_t r = y * 256 / h;
+                               uint8_t g = 0;
+                               uint8_t b = x * 256 / w;
+                               buf[y*w+x] = (r << 16) | (g << 8) | b;
+                       }
                }
        }
+       else
+       {
+               //AxWin4_FillRect(bgwin, 0, 0, w, h, 0x0000CC);
+       }
        //AxWin4_DamageRect(bgwin, 0, 0, w, h);
        AxWin4_ShowWindow(bgwin, true);
        

UCC git Repository :: git.ucc.asn.au