Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6345737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:52:54+00:00 2026-05-24T20:52:54+00:00

I wrote an app that uses Cairo to draw things on screen (on a

  • 0

I wrote an app that uses Cairo to draw things on screen (on a Gtk::DrawingArea, to be exact). It needs to redraw everything frequently. It turns out, that despite the draphics drawn are very simple, the X server uses LOTS of CPU when redrawing, and the applications works terribly slow. Is there any way to speed this up? Or maybe I shouldn’t use DrawingArea and some other widget?

What I draw is set of rectangles, which user can move around by dragging them with mouse. The whole drawing is done withing on_expose_event, but as the mouse pointer moves around (with button pressed), I call queue_draw() to refresh drawing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:52:57+00:00Added an answer on May 24, 2026 at 8:52 pm

    I finally forced to use maximally 25 fps, by using a lock flag.

    bool lock = 0;
    bool needs_redraw = 0;
    
    void Redraw(){
        if(lock){
            needs_redraw = 1;
            return;
        }
    
        //draw image to a surface
    
        needs_redraw = 0;
        lock = 1;
        Glib::signal_timeout().connect(Unlock, 20);
    
        queue_draw();
    }
    
    bool Unlock(){
        lock = 0;
        if(needs_redraw) Redraw();
        return false;
    }
    
    void on_expose_event(something){
        //copy image from surface to widget's context
    }
    

    This is a sample code, but that’s the idea. It will disallow redraw to be done more often then once per 20 ms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a C app that uses the PCRE library. Everything works on my
We have a c# app that uses a number of libraries (that we wrote
I wrote an app that uses UITabBarController , but if I add a lot
I wrote an app that uses XPath to query some XML config files. When
i wrote a Delphi 5 app that uses TIdFTP. it's been working great for
I have an app that I wrote a couple years ago that uses Canvas/FBML
I've wrote an App that streams a short movie over a fix URL. Everything
I wrote an iPhone app some time ago that creates sound programatically. It uses
Anyone know if it is possible to write an app that uses the Java
I am trying to write a PHP script that uses the pdftk app to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.