⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 agg_platform_support.cpp

📁 gnash 在pc和嵌入式下开发需要的源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        trans_affine_resizing(width, height);        on_resize(width, height);        m_specific->m_update_flag = true;        XSizeHints *hints = XAllocSizeHints();        if(hints)         {            if(flags & window_resize)            {                hints->min_width = 32;                hints->min_height = 32;                hints->max_width = 4096;                hints->max_height = 4096;            }            else            {                hints->min_width  = width;                hints->min_height = height;                hints->max_width  = width;                hints->max_height = height;            }            hints->flags = PMaxSize | PMinSize;            XSetWMNormalHints(m_specific->m_display,                               m_specific->m_window,                               hints);            XFree(hints);        }        XMapWindow(m_specific->m_display,                    m_specific->m_window);        XSelectInput(m_specific->m_display,                      m_specific->m_window,                      xevent_mask);                m_specific->m_close_atom = XInternAtom(m_specific->m_display,                                                "WM_DELETE_WINDOW",                                                false);        XSetWMProtocols(m_specific->m_display,                         m_specific->m_window,                         &m_specific->m_close_atom,                         1);        return true;    }    //------------------------------------------------------------------------    void platform_support::update_window()    {        m_specific->put_image(&m_rbuf_window);                // When m_wait_mode is true we can discard all the events         // came while the image is being drawn. In this case         // the X server does not accumulate mouse motion events.        // When m_wait_mode is false, i.e. we have some idle drawing        // we cannot afford to miss any events        XSync(m_specific->m_display, m_wait_mode);    }    //------------------------------------------------------------------------    int platform_support::run()    {        XFlush(m_specific->m_display);                bool quit = false;        unsigned flags;        int cur_x;        int cur_y;        while(!quit)        {            if(m_specific->m_update_flag)            {                on_draw();                update_window();                m_specific->m_update_flag = false;            }            if(!m_wait_mode)            {                if(XPending(m_specific->m_display) == 0)                {                    on_idle();                    continue;                }            }            XEvent x_event;            XNextEvent(m_specific->m_display, &x_event);                        // In the Idle mode discard all intermediate MotionNotify events            if(!m_wait_mode && x_event.type == MotionNotify)            {                XEvent te = x_event;                for(;;)                {                    if(XPending(m_specific->m_display) == 0) break;                    XNextEvent(m_specific->m_display, &te);                    if(te.type != MotionNotify) break;                }                x_event = te;            }            switch(x_event.type)             {            case ConfigureNotify:                 {                    if(x_event.xconfigure.width  != int(m_rbuf_window.width()) ||                       x_event.xconfigure.height != int(m_rbuf_window.height()))                    {                        int width  = x_event.xconfigure.width;                        int height = x_event.xconfigure.height;                        delete [] m_specific->m_buf_window;                        m_specific->m_ximg_window->data = 0;                        XDestroyImage(m_specific->m_ximg_window);                        m_specific->m_buf_window =                             new unsigned char[width * height * (m_bpp / 8)];                        m_rbuf_window.attach(m_specific->m_buf_window,                                             width,                                             height,                                             m_flip_y ?                                              -width * (m_bpp / 8) :                                              width * (m_bpp / 8));                                    m_specific->m_ximg_window =                             XCreateImage(m_specific->m_display,                                          m_specific->m_visual, //CopyFromParent,                                          m_specific->m_depth,                                          ZPixmap,                                          0,                                         (char*)m_specific->m_buf_window,                                          width,                                         height,                                          m_specific->m_sys_bpp,                                         width * (m_specific->m_sys_bpp / 8));                        m_specific->m_ximg_window->byte_order = m_specific->m_byte_order;                        trans_affine_resizing(width, height);                        on_resize(width, height);                        on_draw();                        update_window();                    }                }                break;            case Expose:                m_specific->put_image(&m_rbuf_window);                XFlush(m_specific->m_display);                XSync(m_specific->m_display, false);                break;            case KeyPress:                {                    KeySym key = XLookupKeysym(&x_event.xkey, 0);                    flags = 0;                    if(x_event.xkey.state & Button1Mask) flags |= mouse_left;                    if(x_event.xkey.state & Button3Mask) flags |= mouse_right;                    if(x_event.xkey.state & ShiftMask)   flags |= kbd_shift;                    if(x_event.xkey.state & ControlMask) flags |= kbd_ctrl;                    bool left  = false;                    bool up    = false;                    bool right = false;                    bool down  = false;                    switch(m_specific->m_keymap[key & 0xFF])                    {                    case key_left:                        left = true;                        break;                    case key_up:                        up = true;                        break;                    case key_right:                        right = true;                        break;                    case key_down:                        down = true;                        break;                    case key_f2:                                                copy_window_to_img(max_images - 1);                        save_img(max_images - 1, "screenshot");                        break;                    }                    if(m_ctrls.on_arrow_keys(left, right, down, up))                    {                        on_ctrl_change();                        force_redraw();                    }                    else                    {                        on_key(x_event.xkey.x,                                m_flip_y ?                                    m_rbuf_window.height() - x_event.xkey.y :                                   x_event.xkey.y,                               m_specific->m_keymap[key & 0xFF],                               flags);                    }                }                break;            case ButtonPress:                {                    flags = 0;                    if(x_event.xbutton.state & ShiftMask)   flags |= kbd_shift;                    if(x_event.xbutton.state & ControlMask) flags |= kbd_ctrl;                    if(x_event.xbutton.button == Button1)   flags |= mouse_left;                    if(x_event.xbutton.button == Button3)   flags |= mouse_right;                    cur_x = x_event.xbutton.x;                    cur_y = m_flip_y ? m_rbuf_window.height() - x_event.xbutton.y :                                       x_event.xbutton.y;                    if(flags & mouse_left)                    {                        if(m_ctrls.on_mouse_button_down(cur_x, cur_y))                        {                            m_ctrls.set_cur(cur_x, cur_y);                            on_ctrl_change();                            force_redraw();                        }                        else                        {                            if(m_ctrls.in_rect(cur_x, cur_y))                            {                                if(m_ctrls.set_cur(cur_x, cur_y))                                {                                    on_ctrl_change();                                    force_redraw();                                }                            }                            else                            {                                on_mouse_button_down(cur_x, cur_y, flags);                            }                        }                    }                    if(flags & mouse_right)                    {                        on_mouse_button_down(cur_x, cur_y, flags);                    }                    //m_specific->m_wait_mode = m_wait_mode;                    //m_wait_mode = true;                }                break;                            case MotionNotify:                {                    flags = 0;                    if(x_event.xmotion.state & Button1Mask) flags |= mouse_left;                    if(x_event.xmotion.state & Button3Mask) flags |= mouse_right;                    if(x_event.xmotion.state & ShiftMask)   flags |= kbd_shift;                    if(x_event.xmotion.state & ControlMask) flags |= kbd_ctrl;                    cur_x = x_event.xbutton.x;                    cur_y = m_flip_y ? m_rbuf_window.height() - x_event.xbutton.y :                                       x_event.xbutton.y;                    if(m_ctrls.on_mouse_move(cur_x, cur_y, (flags & mouse_left) != 0))                    {                        on_ctrl_change();                        force_redraw();                    }                    else                    {                        if(!m_ctrls.in_rect(cur_x, cur_y))                        {                            on_mouse_move(cur_x, cur_y, flags);                        }                    }                }                break;                            case ButtonRelease:                {                    flags = 0;                    if(x_event.xbutton.state & ShiftMask)   flags |= kbd_shift;                    if(x_event.xbutton.state & ControlMask) flags |= kbd_ctrl;                    if(x_event.xbutton.button == Button1)   flags |= mouse_left;                    if(x_event.xbutton.button == Button3)   flags |= mouse_right;                    cur_x = x_event.xbutton.x;                    cur_y = m_flip_y ? m_rbuf_window.height() - x_event.xbutton.y :                                       x_event.xbutton.y;                    if(flags & mouse_left)                    {                        if(m_ctrls.on_mouse_button_up(cur_x, cur_y))                        {                            on_ctrl_change();                            force_redraw();                        }                    }                    if(flags & (mouse_left | mouse_right))                    {                        on_mouse_button_up(cur_x, cur_y, flags);                    }                }                //m_wait_mode = m_specific->m_wait_mode;                break;            case ClientMessage:                if((x_event.xclient.format == 32) &&                (x_event.xclient.data.l[0] == int(m_specific->m_close_atom)))                {                    quit = true;                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -