Project

General

Profile

Actions

Bug #1234

closed

Touchscreen is not working with PiPics on Kiosk build

Added by Hammel about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Immediate
Assignee:
Target version:
Start date:
10 Oct 2025
Due date:
% Done:

100%

Estimated time:
Severity:
01 - Critical

Description

Pressing next, prev and exit on the display have no affect.

Actions #1

Updated by Hammel about 1 month ago

This is just bad design. The imageTouchGTK() function sets inProgress=1 and then calls the associated function. If inProgress is set then the function doesn't do anything, preventing multiple touches from queuing. Since that call is not immediate, the inProgress is not reset in imageTouchGTK(), but neither is it reset in the functions it calls. So this is just crap code.

I need to use a mutex here. The mutex can be a pthread_mutex_try() that just checks for EBUSY. If it's busy, just return. No need for the inProgress global.

There is more to do here.
  1. Move the dbMutex to db.c and lock the getNext/getPrev with it. Don't use dbMutex in pipics.c.
  2. gtk_pbimage_set_path() needs to append or prepend to an internal list. The list can be any size - it's a GSList.
    1. set_path(append, size) appends an new image to the list. If the list is larger than size, drop the list head.
    2. set_path(prepend, size) appends a new image to the front of the list. If the list is larger than size, drop the list tail.
    3. Preload the first 10 images at widget creation time by calling set_path() 10 times with APPEND option.
    4. Init index location to 0.
    5. When main does next, call display_next() in widget which returns index of displayed image.
      1. If index > 1/2 list size, call set_path(append) in a timer func.
    6. When main does prev, call display_prev() in widget which returns index of displayed image.
      1. When index < 1/2 list size (and has previously been >1/2 size) then call set_path(prepend) in a timer func().

Basically, we want to change the API so the caller to the widget is asking for the next or previous index. set_path is used to append or prepend an image to the list.

Actions #2

Updated by Hammel about 1 month ago

  • % Done changed from 0 to 10
Actions #3

Updated by Hammel about 1 month ago

Here's a more detailed description of what is required.

pigtk-pbimage Updates
-------------------------
1.  gtk_pbimage_set_path( GtkWidget *widget, PIC_T *pic ) 
    a. New API: gtk_pbimage_add_image( GtkWidget *widget, PIC_T *pic, int prepend, int size )
    b. Check if pic is in list.
        1. Do nothing and return if it is.
    c. Load and orientate image
    d. If prepend=1 then prepend image, else append, to pbimage->images GSList.
    e. If new size > size, 
        1. remove head or tail based on prepend.
        2. update current_index down (append) or up (prepend) by 1, clamped to 0..size.
    f. Return updated current_index.
2. Change references to ->pixbuf to use current index to retrieve loaded image.
3. Remove file loading from db.c.  Let the widget handle it.
    This will deprecate gtk_pbimage_set_pixbuf()

New functions
-------------------------
1. static IsPicInList(): looks through list for specific PIC_T, by filename.
2. static clearEntry(): Removes an entry by freeing it's pixbuf and PIC_T.  Updates GSList appropriately.
3. gtk_pbimage_next(): display the next image in the GSList. Return index of displayed image().
4. gtk_pbimage_prev(): display the prev image in the GSList. Return index of displayed image().

Note: _next() and _prev() will ignore requests past ends of list.
Note: caller is responsible for extending list in either direction.
Note: GSList must be protected with a mutex for adding, deleting or retrieving current index.

Change or remove function
-------------------------
gtk_pbimage_clear( GtkWidget *widget )
    should change to clear the list and free the pixbufs allocated for it.
gtk_pbimage_set_pixbuf( GtkWidget *widget, PIC_T *pic, int prepend )
    a. Check if pic is in list.
        1. Do nothing and return if it is.
    b. If prepend=1 then prepend image, else append, to pbimage->images GSList.
    c. If new size > size, remove head or tail based on pos.
    d. Return index of new image.
Actions #4

Updated by Hammel about 1 month ago

  • Status changed from New to Closed
  • % Done changed from 10 to 100

Switching inprogress to a mutex (and removing an unneeded mutex) fixed the original problem. The use of the GSList would help speed movement through the list but for now this is good.

Closing issue so I can move on to other things.

Actions

Also available in: Atom PDF