Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected null screen in Linux framebuffer backend #92

Open
huaxinliao opened this issue Jan 23, 2025 · 0 comments · May be fixed by #94
Open

Unexpected null screen in Linux framebuffer backend #92

huaxinliao opened this issue Jan 23, 2025 · 0 comments · May be fixed by #94
Assignees

Comments

@huaxinliao
Copy link
Collaborator

After merging #88, I encountered issues while executing fbdev. To identify the source of the error, I conducted several experiments. I observed that the error originates from the twin_screen_update function, as I was able to successfully execute fbdev using the original twin_screen_update function.

To resolve this issue, I modified the code introduced in #88 to ensure that the updated twin_screen_update function is compatible with fbdev. Below are the modifications I made:

static twin_pixmap_t *twin_active_pixmap(twin_screen_t *screen,
                                         twin_pixmap_t **active_pix)
{
    twin_pixmap_t *p = NULL, *prev_active_pix = NULL;
    /*
     * Identify the previously active pixel map and the currently active pixel
     * map, which is on the topmost layer.
     */
    for (p = screen->bottom; p; p = p->up) {
        if (p->window->active == true) {
            prev_active_pix = p;
            prev_active_pix->window->active = false;
        }
        (*active_pix) = p;
    }
+    if(*active_pix)
+        (*active_pix)->window->active = true;
-   (*active_pix)->window->active = true;
    return prev_active_pix;
}
...
        prev_active_pix = twin_active_pixmap(screen, &active_pix);
	//active_pix = prev_active_pix;
        /*
         * Mark the previously active pixel map as damaged to update its
         * changes.
         */
-       if (prev_active_pix && active_pix != prev_active_pix)
+       if ((prev_active_pix && active_pix != prev_active_pix) && prev_active_pix){
            twin_pixmap_damage(prev_active_pix, 0, 0, prev_active_pix->width, prev_active_pix->height);
            twin_window_draw(prev_active_pix->window);
        }

        /* Mark the active pixel map as damaged to update its changes. */
+       if(active_pix){
+            twin_pixmap_damage(active_pix, 0, 0, active_pix->width,active_pix->height);
+            twin_window_draw(active_pix->window);
+       }
-        twin_pixmap_damage(active_pix, 0, 0, active_pix->width,active_pix->height);
-        twin_window_draw(active_pix->window);

The condition if(*active_pix) ensures that *active_pix is valid, as I previously encountered failures in this part of the code. Similarly, if(active_pix) verifies that active_pix is not NULL. These modifications are designed to prevent unexpected situations from occurring. Finally, I obtained the output from my VM.
messageImage_1737563693437

If I eliminate the code below, I am able to successfully run fbdev.

/* Mark the active pixel map as damaged to update its changes. */
- twin_pixmap_damage(active_pix, 0, 0, active_pix->width,
-                   active_pix->height);
- twin_window_draw(active_pix->window);
Modification.mp4
@jserv jserv changed the title Fix Compatibility Issues in twin_screen_update for fbdev Unexpected null screen in Linux framebuffer backend Jan 23, 2025
weihsinyeh added a commit to weihsinyeh/mado that referenced this issue Jan 26, 2025
Remove the inefficiently function twin_active_pixmap(). This function
finds the currently and previously active window pixel map by traversing
the list of pixel maps. This function will be called every time the
screen needs to be updated. Set the active variable of the window only
when the window's event TwinEventButtonDown is triggered to avoid
redundant operations. Additionally, implement the function
twin_window_active_paint() to only repaint the title bar instead of
calling the function twin_window_draw() to indirectly call the function
twin_window_frame to repaint the title bar of the window.

Close sysprog21#92

Signed-off-by: Wei-Hsin Yeh <[email protected]>
@weihsinyeh weihsinyeh linked a pull request Jan 26, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants