sysd/src/display.c File Reference

#include "config.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <string.h>
#include <pthread.h>
#include <liberipc/eripc.h>
#include <liberipc/eripc_support.h>
#include <liberutils/display_utils.h>
#include "log.h"
#include "delta.h"
#include "system.h"
#include "tasks.h"
#include "xwindow.h"
#include "ipc.h"
Include dependency graph for sysd/src/display.c:

Go to the source code of this file.

Data Structures

struct  DMCommandInfo
struct  DMCommandForce
struct  DMCommand
struct  erDmCmd_t
struct  WMInfo

Defines

#define UNUSED(x)   (void)(x)
#define DMPORT   50555
#define LOCALHOST   0x7f000001L
#define DM_MAXCHARONLINE   1024
#define DM_CMD_NAME   128
#define DM_ARGLENGTH   256
#define DM_N_ARG   16
#define WMPORT   50556
#define WM_NAME   64
#define WAVEFORM_QUICK   6
#define WAVEFORM_PARTIAL   9
#define WAVEFORM_FULL   1
#define DELTA_TIME_FULL   900*1000
#define DELTA_TIME_QUICK   50*1000
#define CLIENT_IS_SPLASH_WIN   (1<<0)
#define CLIENT_FULLSCREEN_FLAG   (1<<1)
#define CLIENT_TITLE_HIDDEN_FLAG   (1<<2)
#define CLIENT_SHRUNK_FOR_TB_FLAG   (1<<3)
#define CLIENT_HELP_BUTTON_FLAG   (1<<4)
#define CLIENT_ACCEPT_BUTTON_FLAG   (1<<5)
#define CLIENT_DOCK_NORTH   (1<<6)
#define CLIENT_DOCK_SOUTH   (1<<7)
#define CLIENT_DOCK_EAST   (1<<8)
#define CLIENT_DOCK_WEST   (1<<9)
#define CLIENT_WANTS_MASK_FLAG   (1<<10)
#define CLIENT_IS_MODAL_FLAG   (1<<11)
#define CLIENT_BORDERS_ONLY_FLAG   (1<<12)
#define CLIENT_IS_MESSAGE_DIALOG   (1<<14)
#define CLIENT_IS_DESKTOP_FLAG   (1<<15)
#define CLIENT_NEW_FOR_DESKTOP   (1<<16)
#define CLIENT_DOCK_TITLEBAR   (1<<17)
#define CLIENT_CUSTOM_BUTTON_FLAG   (1<<18)
#define CLIENT_IS_MOVING   (1<<19)
#define CLIENT_DOCK_TITLEBAR_SHOW_ON_DESKTOP   (1<<20)
#define CLIENT_NO_FOCUS_ON_MAP   (1<<21)
#define CLIENT_IS_MINIMIZED   (1<<23)
#define CLIENT_TOOLBARS_MOVED_FOR_FULLSCREEN   (1<<24)
#define CLIENT_IS_TRANSIENT_FOR_ROOT   (1<<25)
#define CLIENT_HAS_URGENCY_FLAG   (1<<26)
#define CLIENT_HAS_ABOVE_STATE   (1<<27)
#define CLIENT_IS_MENU_DIALOG   (1<<30)
#define CLIENT_DELAY_MAPPING   (1<<31)
#define N_FILENAME   1024
#define BUFFERSIZE   1024
#define BUSY_ANIMATION_SPEED   50

Typedefs

typedef struct display_update_info DisplayUpdateInfo
typedef struct wave_info WaveInfo
typedef struct busy_info BusyInfo

Enumerations

enum  DMCommandCode {
  DM_INFO, DM_FORCE, DM_UNDEFINED, DM_INFO,
  DM_FORCE, DM_UNDEFINED
}
enum  MBClientTypeEnum {
  MBCLIENT_TYPE_DIALOG = (1<<1), MBCLIENT_TYPE_TOOLBAR = (1<<2), MBCLIENT_TYPE_PANEL = (1<<3), MBCLIENT_TYPE_TASK_MENU = (1<<4),
  MBCLIENT_TYPE_APP = (1<<5), MBCLIENT_TYPE_DESKTOP = (1<<6), MBCLIENT_TYPE_OVERRIDE = (1<<7), MBCLIENT_TYPE_ANY = (1<<8),
  MBCLIENT_TYPE_DIALOG = (1<<1), MBCLIENT_TYPE_TOOLBAR = (1<<2), MBCLIENT_TYPE_PANEL = (1<<3), MBCLIENT_TYPE_TASK_MENU = (1<<4),
  MBCLIENT_TYPE_APP = (1<<5), MBCLIENT_TYPE_DESKTOP = (1<<6), MBCLIENT_TYPE_OVERRIDE = (1<<7), MBCLIENT_TYPE_ANY = (1<<8)
}

Functions

static gboolean handle_gtk_socket (GIOChannel *source, GIOCondition condition, gpointer data)
static gint parse_message (char *szCommand, erDmCmd_t *pCmd)
static gint parse_command (erDmCmd_t *pCmd, DMCommand *command)
static void get_arguments (char *pChar, erDmCmd_t *pCmd, int nReqArgs)
static void on_message_timeout (void)
static void * gtk_messages (void *arg)
static void display_update (gint waveform)
static void schedule_update (gint delay, const char *rule)
static gint delta_vcom_set (gfloat vcom)
static int delta_uploadwave (char *filename, glong offset)
static gint delta_erase (gint color)
static gint delta_update_display (DisplayUpdateInfo *displayUpdateInfo)
static gint delta_busy (gint xpos, gint ypos, gint speed)
static void delta_init (void)
static gboolean ignore_pid (gint pid)
static void ignore_pid_add (gint pid)
static void ignore_pid_remove (gint pid)
static gboolean locked_display (void)
static void lock_display (void)
static void unlock_display (void)
static void parse_wm_messages (char *buffer)
gboolean handle_wm_socket (GIOChannel *source, GIOCondition condition, gpointer data)
void display_set_services ()
 Initialize diplay update handling.
void display_blank (void)
 Erase display.
void display_busy_animation (gint xpos, gint ypos)
 Show the busy animation.
gchar * display_get_active_window (void)
 Get the name of the active window.
void display_cleanup_pid (gint pid)
 Remove PID from display information.
void display_set_vcom (gfloat vcom)
void display_set_waveforms (void)
void display_init (void)
static uint64_t getCurrentTime ()
static void promote_waveform (gint waveform)
static void parse_gtk_message (char *buffer)
void display_set_ctb_window (gint wid)

Variables

static int fbDev = 0
static int useSpecialWaveform = 0
static DMCommand DisplayCommand
static WMInfo WindowInfo
static uint64_t deltaAvailableAgain = 0
static GSList * g_ignorelist = NULL
static int g_ctb_window = 0
static int g_prev_window = 0
static gboolean g_display_locked = FALSE
static gboolean g_vcom_is_set = FALSE
static pthread_t dm_thread
static struct timeval g_timeout

Define Documentation

#define BUFFERSIZE   1024

Definition at line 191 of file sysd/src/display.c.

Referenced by gtk_messages().

#define BUSY_ANIMATION_SPEED   50

Definition at line 192 of file sysd/src/display.c.

Referenced by display_busy_animation().

#define CLIENT_ACCEPT_BUTTON_FLAG   (1<<5)

Definition at line 148 of file sysd/src/display.c.

#define CLIENT_BORDERS_ONLY_FLAG   (1<<12)

Definition at line 155 of file sysd/src/display.c.

#define CLIENT_CUSTOM_BUTTON_FLAG   (1<<18)

Definition at line 160 of file sysd/src/display.c.

#define CLIENT_DELAY_MAPPING   (1<<31)

Definition at line 170 of file sysd/src/display.c.

#define CLIENT_DOCK_EAST   (1<<8)

Definition at line 151 of file sysd/src/display.c.

#define CLIENT_DOCK_NORTH   (1<<6)

Definition at line 149 of file sysd/src/display.c.

#define CLIENT_DOCK_SOUTH   (1<<7)

Definition at line 150 of file sysd/src/display.c.

#define CLIENT_DOCK_TITLEBAR   (1<<17)

Definition at line 159 of file sysd/src/display.c.

#define CLIENT_DOCK_TITLEBAR_SHOW_ON_DESKTOP   (1<<20)

Definition at line 162 of file sysd/src/display.c.

#define CLIENT_DOCK_WEST   (1<<9)

Definition at line 152 of file sysd/src/display.c.

#define CLIENT_FULLSCREEN_FLAG   (1<<1)

Definition at line 144 of file sysd/src/display.c.

#define CLIENT_HAS_ABOVE_STATE   (1<<27)

Definition at line 168 of file sysd/src/display.c.

#define CLIENT_HAS_URGENCY_FLAG   (1<<26)

Definition at line 167 of file sysd/src/display.c.

#define CLIENT_HELP_BUTTON_FLAG   (1<<4)

Definition at line 147 of file sysd/src/display.c.

#define CLIENT_IS_DESKTOP_FLAG   (1<<15)

Definition at line 157 of file sysd/src/display.c.

#define CLIENT_IS_MENU_DIALOG   (1<<30)

Definition at line 169 of file sysd/src/display.c.

Referenced by parse_wm_messages().

#define CLIENT_IS_MESSAGE_DIALOG   (1<<14)

Definition at line 156 of file sysd/src/display.c.

#define CLIENT_IS_MINIMIZED   (1<<23)

Definition at line 164 of file sysd/src/display.c.

#define CLIENT_IS_MODAL_FLAG   (1<<11)

Definition at line 154 of file sysd/src/display.c.

#define CLIENT_IS_MOVING   (1<<19)

Definition at line 161 of file sysd/src/display.c.

#define CLIENT_IS_SPLASH_WIN   (1<<0)

Definition at line 143 of file sysd/src/display.c.

#define CLIENT_IS_TRANSIENT_FOR_ROOT   (1<<25)

Definition at line 166 of file sysd/src/display.c.

#define CLIENT_NEW_FOR_DESKTOP   (1<<16)

Definition at line 158 of file sysd/src/display.c.

#define CLIENT_NO_FOCUS_ON_MAP   (1<<21)

Definition at line 163 of file sysd/src/display.c.

#define CLIENT_SHRUNK_FOR_TB_FLAG   (1<<3)

Definition at line 146 of file sysd/src/display.c.

#define CLIENT_TITLE_HIDDEN_FLAG   (1<<2)

Definition at line 145 of file sysd/src/display.c.

#define CLIENT_TOOLBARS_MOVED_FOR_FULLSCREEN   (1<<24)

Definition at line 165 of file sysd/src/display.c.

#define CLIENT_WANTS_MASK_FLAG   (1<<10)

Definition at line 153 of file sysd/src/display.c.

#define DELTA_TIME_FULL   900*1000

Definition at line 83 of file sysd/src/display.c.

Referenced by on_message_timeout(), and schedule_update().

#define DELTA_TIME_QUICK   50*1000

Definition at line 85 of file sysd/src/display.c.

Referenced by on_message_timeout().

#define DM_ARGLENGTH   256

Definition at line 71 of file sysd/src/display.c.

#define DM_CMD_NAME   128

Definition at line 70 of file sysd/src/display.c.

#define DM_MAXCHARONLINE   1024

Definition at line 69 of file sysd/src/display.c.

Referenced by get_arguments(), and parse_message().

#define DM_N_ARG   16

Definition at line 72 of file sysd/src/display.c.

Referenced by parse_message().

#define DMPORT   50555

Definition at line 66 of file sysd/src/display.c.

#define LOCALHOST   0x7f000001L

Definition at line 67 of file sysd/src/display.c.

Referenced by gtk_messages().

#define N_FILENAME   1024

Definition at line 190 of file sysd/src/display.c.

#define UNUSED (  )     (void)(x)

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 58 of file sysd/src/display.c.

#define WAVEFORM_FULL   1
#define WAVEFORM_PARTIAL   9
#define WAVEFORM_QUICK   6
#define WM_NAME   64

Definition at line 76 of file sysd/src/display.c.

Referenced by parse_wm_messages().

#define WMPORT   50556

Definition at line 75 of file sysd/src/display.c.

Referenced by display_set_services().


Typedef Documentation

typedef struct busy_info BusyInfo

Definition at line 140 of file sysd/src/display.c.

Definition at line 138 of file sysd/src/display.c.

typedef struct wave_info WaveInfo

Definition at line 139 of file sysd/src/display.c.


Enumeration Type Documentation

Enumerator:
DM_INFO 
DM_FORCE 
DM_UNDEFINED 
DM_INFO 
DM_FORCE 
DM_UNDEFINED 

Definition at line 87 of file sysd/src/display.c.

00088 {
00089     DM_INFO,      // automically by GTK
00090     DM_FORCE,     // forced by application
00091     DM_UNDEFINED
00092 } DMCommandCode;

Enumerator:
MBCLIENT_TYPE_DIALOG 
MBCLIENT_TYPE_TOOLBAR 
MBCLIENT_TYPE_PANEL 
MBCLIENT_TYPE_TASK_MENU 
MBCLIENT_TYPE_APP 
MBCLIENT_TYPE_DESKTOP 
MBCLIENT_TYPE_OVERRIDE 
MBCLIENT_TYPE_ANY 
MBCLIENT_TYPE_DIALOG 
MBCLIENT_TYPE_TOOLBAR 
MBCLIENT_TYPE_PANEL 
MBCLIENT_TYPE_TASK_MENU 
MBCLIENT_TYPE_APP 
MBCLIENT_TYPE_DESKTOP 
MBCLIENT_TYPE_OVERRIDE 
MBCLIENT_TYPE_ANY 

Definition at line 173 of file sysd/src/display.c.

00174 { 
00175   MBCLIENT_TYPE_DIALOG    = (1<<1),
00176   MBCLIENT_TYPE_TOOLBAR   = (1<<2),
00177   MBCLIENT_TYPE_PANEL     = (1<<3),
00178   MBCLIENT_TYPE_TASK_MENU = (1<<4),
00179   MBCLIENT_TYPE_APP       = (1<<5),
00180   MBCLIENT_TYPE_DESKTOP   = (1<<6),
00181   MBCLIENT_TYPE_OVERRIDE  = (1<<7),
00182   MBCLIENT_TYPE_ANY       = (1<<8)
00183 } MBClientTypeEnum;


Function Documentation

static gint delta_busy ( gint  xpos,
gint  ypos,
gint  speed 
) [static]

Definition at line 1037 of file sysd/src/display.c.

References busy_info::delay, ERRORPRINTF, FBIO_DELTA_BUSY, LOGPRINTF, busy_info::x, and busy_info::y.

Referenced by display_busy_animation().

01038 {
01039     LOGPRINTF("entry");
01040     
01041     BusyInfo info;
01042 
01043     info.x     = (unsigned short) xpos;
01044     info.y     = (unsigned short) ypos;
01045     info.delay = (unsigned short) speed;
01046 
01047     int ret = ioctl(fbDev, FBIO_DELTA_BUSY, &info);
01048     if (ret != 0)
01049     { 
01050         ERRORPRINTF("Error sending FBIO_DELTA_BUSY: %x",ret);
01051     }
01052     return ret;
01053 }

Here is the caller graph for this function:

static gint delta_erase ( gint  color  )  [static]

Definition at line 1017 of file sysd/src/display.c.

References display_update_info::color, ERRORPRINTF, FBIO_DELTA_ERASE, LOGPRINTF, and display_update_info::waveform.

Referenced by display_blank().

01018 {
01019     LOGPRINTF("entry");
01020 
01021     DisplayUpdateInfo updateinfo;
01022     
01023     updateinfo.waveform = 0; // full
01024     updateinfo.color = color;
01025     
01026     color = ((color & 0xf) << 4) + color;
01027     
01028     int ret =  ioctl(fbDev, FBIO_DELTA_ERASE, &updateinfo);
01029     if (ret != 0)
01030     { 
01031         ERRORPRINTF("Error sending FBIO_DELTA_ERASE: %x",ret); 
01032     }
01033     return ret;
01034 }

Here is the caller graph for this function:

static void delta_init ( void   )  [static]

Definition at line 977 of file sysd/src/display.c.

References ERRORPRINTF, FBIO_DELTA_INIT, and LOGPRINTF.

Referenced by display_init().

00978 {
00979     LOGPRINTF("entry");
00980     
00981     gint ret = 0;
00982     
00983     if ((ret = ioctl(fbDev, FBIO_DELTA_INIT, NULL)))
00984     {
00985         ERRORPRINTF("Error sending FBIO_DELTA_INIT: %x\n", ret);
00986     }
00987 }

Here is the caller graph for this function:

static gint delta_update_display ( DisplayUpdateInfo displayUpdateInfo  )  [static]

Definition at line 1056 of file sysd/src/display.c.

References ERRORPRINTF, and FBIO_DELTA_UPDATE_DISPLAY.

Referenced by display_update().

01057 {
01058 //    LOGPRINTF("entry");
01059 
01060     int ret = ioctl(fbDev, FBIO_DELTA_UPDATE_DISPLAY, displayUpdateInfo);
01061     if (ret != 0)
01062     {
01063         ERRORPRINTF("Error sending FBIO_DELTA_UPDATE_DISPLAY: %x", ret);
01064     }
01065     return ret;
01066 }

Here is the caller graph for this function:

static int delta_uploadwave ( char *  filename,
glong  offset 
) [static]

Definition at line 928 of file sysd/src/display.c.

References ERRORPRINTF, FBIO_DELTA_UPLOADWAVES, LOGPRINTF, wave_info::size, wave_info::wave, and WAVEFORM_SIZE.

Referenced by display_set_waveforms().

00929 {
00930     LOGPRINTF("entry");
00931 
00932     int ret = 0;
00933     FILE *file = NULL;
00934     WaveInfo info;
00935     
00936     // open the wave file
00937     file = fopen(filename, "rb");
00938     if (file == NULL)
00939     {
00940         ERRORPRINTF("Error opening file %s", filename);
00941         return -1;
00942     }
00943     
00944     if (offset > 0)
00945     {
00946         if (fseek(file, offset, SEEK_SET) != 0)
00947         {
00948             ERRORPRINTF("Error seeking file in %s [%d]", filename, errno);
00949             return -1;
00950         }
00951     }
00952     
00953     info.wave = malloc(WAVEFORM_SIZE);
00954     if (info.wave == NULL)
00955     {
00956         ERRORPRINTF("Not enough memory\n");
00957         return -1;
00958     }
00959     
00960     info.size = fread(info.wave, 1, WAVEFORM_SIZE, file);
00961 
00962     // close the image
00963     fclose(file);
00964 
00965     ret = ioctl(fbDev, FBIO_DELTA_UPLOADWAVES, &info);
00966     if (ret != 0)
00967     {
00968         ERRORPRINTF("Error sending FBIO_DELTA_UPLOADWAVES: %x", ret);
00969     }
00970     
00971     free(info.wave);
00972 
00973     return ret;
00974 }

Here is the caller graph for this function:

static gint delta_vcom_set ( gfloat  vcom  )  [static]

Definition at line 990 of file sysd/src/display.c.

References ERRORPRINTF, FBIO_DETA_VCOM_SET, and LOGPRINTF.

Referenced by display_set_vcom().

00991 {
00992     LOGPRINTF("entry");
00993 
00994     glong vcom_int = 0;
00995     gint ret = 0;
00996     
00997     if(vcom < -5) 
00998     {
00999         vcom = -5;
01000     }
01001     else if(vcom > 5) 
01002     {
01003         vcom = 5;
01004     }
01005     
01006     vcom_int = (signed long)(1000 * vcom);
01007     
01008     if ((ret=ioctl(fbDev, FBIO_DETA_VCOM_SET, &vcom_int)))
01009     { 
01010         ERRORPRINTF("Error sending FBIO_DETA_VCOM_SET: %x",ret); 
01011     }
01012     
01013     return ret;    
01014 }

Here is the caller graph for this function:

void display_blank ( void   ) 

Erase display.

---------------------------------------------------------------------------

Name : display_blank

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 412 of file sysd/src/display.c.

References delta_erase(), g_timeout, and LOGPRINTF.

00413 {
00414     LOGPRINTF("entry");
00415 
00416     // cancel scheduled dislay update 
00417     if (g_timeout.tv_sec > 0 || g_timeout.tv_usec > 0) 
00418     { 
00419         bzero(&DisplayCommand, sizeof(DMCommand));
00420         g_timeout.tv_sec = -1;
00421         g_timeout.tv_usec = -1;
00422     }
00423 
00424     // clear display
00425     delta_erase(15);   
00426 }

Here is the call graph for this function:

void display_busy_animation ( gint  xpos,
gint  ypos 
)

Show the busy animation.

---------------------------------------------------------------------------

Name : display_busy_animation

Parameters:
xpos 
ypos 
Returns:
--

--------------------------------------------------------------------------

Definition at line 429 of file sysd/src/display.c.

References BUSY_ANIMATION_SPEED, delta_busy(), and LOGPRINTF.

00430 {
00431     LOGPRINTF("entry: x %d, y %d", xpos, ypos);
00432     delta_busy(xpos, ypos, BUSY_ANIMATION_SPEED);
00433 }

Here is the call graph for this function:

void display_cleanup_pid ( gint  pid  ) 

Remove PID from display information.

---------------------------------------------------------------------------

Name : display_cleanup_pid

Parameters:
gint Process ID
Returns:
--

--------------------------------------------------------------------------

Definition at line 443 of file sysd/src/display.c.

References ignore_pid_remove(), and LOGPRINTF.

Referenced by on_process_exit().

00444 {
00445     LOGPRINTF("entry");
00446     ignore_pid_remove(pid);    
00447 }

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* display_get_active_window (  ) 

Get the name of the active window.

---------------------------------------------------------------------------

Name : display_get_active_window

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 436 of file sysd/src/display.c.

References LOGPRINTF, and WMInfo::name.

Referenced by process_activate_ctb().

00437 {
00438     LOGPRINTF("entry");
00439     return WindowInfo.name;
00440 }

Here is the caller graph for this function:

void display_init ( void   ) 

Definition at line 464 of file sysd/src/display.c.

References delta_init(), dm_socket, init_socket(), and LOGPRINTF.

00465 {
00466     LOGPRINTF("entry");
00467     delta_init();
00468 }

Here is the call graph for this function:

void display_set_ctb_window ( gint  wid  ) 

Definition at line 1190 of file sysd/src/display.c.

Referenced by process_startup_complete().

01191 {
01192     g_ctb_window = wid;
01193 }

Here is the caller graph for this function:

void display_set_services ( void   ) 

Initialize diplay update handling.

File Name : display.h

Description: The Display update functions Copyright (C) 2008 iRex Technologies B.V. All rights reserved.---------------------------------------------------------------------------

Name : display_set_services

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 376 of file sysd/src/display.c.

References ERRORPRINTF, gtk_messages(), handle_wm_socket(), LOGPRINTF, and WMPORT.

Referenced by main().

00377 {
00378     LOGPRINTF("entry");
00379     
00380     if (pthread_create(&dm_thread, NULL, gtk_messages, NULL) != 0)
00381     {
00382         ERRORPRINTF("Could not create thread");
00383         return;
00384     }
00385 
00386     // add GIOChannel for WM socket
00387     //
00388     int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
00389     if (sockfd == -1) {
00390         perror("Error invoking socket");
00391         return;
00392     }
00393     bzero(&WindowInfo, sizeof(WMInfo));
00394     struct sockaddr_in server_addr;
00395     bzero(&server_addr, sizeof(struct sockaddr_in));
00396     server_addr.sin_family = AF_INET;
00397     server_addr.sin_port = htons(WMPORT);
00398     server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
00399     memset(server_addr.sin_zero, 0, sizeof(server_addr.sin_zero));
00400 
00401     int error = bind(sockfd, &server_addr, sizeof(server_addr));
00402     if (error) {
00403         perror("Error invoking bind");
00404         return;
00405     }
00406     GIOChannel* channel = g_io_channel_unix_new(sockfd);
00407     g_io_channel_set_encoding(channel, NULL, NULL);
00408     g_io_add_watch(channel, G_IO_IN|G_IO_PRI|G_IO_ERR, handle_wm_socket, NULL);
00409 }

Here is the call graph for this function:

Here is the caller graph for this function:

void display_set_vcom ( gfloat  vcom  ) 

Definition at line 450 of file sysd/src/display.c.

References delta_vcom_set(), and LOGPRINTF.

Referenced by display_update().

00451 {
00452     LOGPRINTF("entry [%f]", vcom);
00453     delta_vcom_set(vcom);
00454 }

Here is the call graph for this function:

Here is the caller graph for this function:

void display_set_waveforms ( void   ) 

Definition at line 457 of file sysd/src/display.c.

References delta_uploadwave(), and LOGPRINTF.

00458 {
00459     LOGPRINTF("entry");
00460     delta_uploadwave("/var/tmp/waves", 0);
00461 }

Here is the call graph for this function:

static void display_update ( gint  waveform  )  [static]

Definition at line 865 of file sysd/src/display.c.

References display_update_info::color, delta_update_display(), display_set_vcom(), DMPPRINTF, sys_get_display_vcom(), sys_reset_idle_time(), and display_update_info::waveform.

Referenced by on_message_timeout().

00866 {
00867     DisplayUpdateInfo displayUpdateInfo;
00868     
00869     displayUpdateInfo.color = 0;
00870     displayUpdateInfo.waveform = waveform;
00871     
00872 #if DMLOGGING_ON 
00873     GTimeVal curtime;
00874     g_get_current_time(&curtime);
00875     
00876     DMPPRINTF("\n\n%ld:%3ld update waveform %d\n",
00877            curtime.tv_sec, curtime.tv_usec / 1000, 
00878            displayUpdateInfo.waveform);
00879 #endif
00880 
00881     // init VCOM for delta driver
00882     if (!g_vcom_is_set)
00883     {
00884         display_set_vcom(sys_get_display_vcom());
00885         g_vcom_is_set = TRUE;
00886     }
00887 
00888     // perform display update
00889     delta_update_display(&displayUpdateInfo);
00890     
00891     // reset idle timer
00892     sys_reset_idle_time();
00893 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void get_arguments ( char *  pChar,
erDmCmd_t pCmd,
int  nReqArgs 
) [static]

Definition at line 1164 of file sysd/src/display.c.

References erDmCmd_t::arg, and DM_MAXCHARONLINE.

Referenced by parse_message().

01165 {
01166     int     nArg;
01167     int     i;
01168     char    szToken[DM_MAXCHARONLINE];
01169 
01170     for (nArg = 0; nArg < nReqArgs; nArg++)
01171     {
01172         i = 0;
01173         while (*pChar != '\0')
01174         {
01175             szToken[i] = '\0';
01176             if (*pChar == ',')
01177             {
01178                 pChar++;
01179                 break;
01180             }
01181             szToken[i] = *pChar++;
01182             i++;
01183             szToken[i] = '\0';
01184         }
01185         strcpy(pCmd->arg[nArg], szToken);
01186     }
01187 }

Here is the caller graph for this function:

static uint64_t getCurrentTime (  )  [static]

Definition at line 475 of file sysd/src/display.c.

00476 {
00477     struct timespec now;
00478 
00479     clock_gettime(CLOCK_MONOTONIC, &now);
00480     u_int64_t now64 = now.tv_sec;
00481     now64 *= 1000000;
00482     now64 += (now.tv_nsec/1000);
00483     return now64;
00484 }

static void * gtk_messages ( void *  arg  )  [static]

Definition at line 1196 of file sysd/src/display.c.

References buffer, BUFFERSIZE, DMPORT, ERRORPRINTF, g_timeout, LOCALHOST, on_message_timeout(), parse_gtk_message(), STATE_POWER_IDLE, STATE_POWER_STANDBY, sys_get_power_state(), and WARNPRINTF.

Referenced by display_set_services().

01197 {
01198     int        sockfd = -1;
01199     int        error = 0;
01200     struct     sockaddr_in server_addr;
01201     DMCommand  command;
01202     erDmCmd_t  cmd;
01203     gchar      buffer[BUFFERSIZE];
01204     gsize      n;
01205     
01206     // open framebuffer device
01207     fbDev = open("/dev/fb0", O_RDWR);
01208     if (fbDev == -1)
01209     {
01210         ERRORPRINTF("Cannot open framebufferdevice. # mknod /dev/fb0 c 29 0");
01211         return NULL;
01212     }
01213 
01214     // create and bind socket
01215     //
01216     sockfd = socket(PF_INET, SOCK_DGRAM, 0);
01217     bzero(&server_addr, sizeof(struct sockaddr_in));
01218     server_addr.sin_family = AF_INET;
01219     server_addr.sin_port = htons(DMPORT);
01220     server_addr.sin_addr.s_addr = htonl(LOCALHOST);
01221     memset(server_addr.sin_zero, '\0', sizeof(server_addr.sin_zero));
01222     
01223     bzero(&DisplayCommand, sizeof(DMCommand));
01224     
01225     error = bind(sockfd, &server_addr, sizeof(server_addr));
01226     if (error)
01227     {
01228         perror("Error invoking bind");
01229         return NULL;
01230     }
01231     
01232     int retval;
01233     fd_set rfds;
01234     
01235     // process incoming messages
01236     //
01237     for (;;)
01238     {
01239         FD_ZERO(&rfds);
01240         FD_SET(sockfd, &rfds);
01241         
01242         if (g_timeout.tv_sec > 0 || g_timeout.tv_usec > 0) 
01243         {
01244 //            WARNPRINTF("wait for data or timeout");
01245             retval = select(sockfd+1, &rfds, NULL, NULL, &g_timeout);
01246         }
01247         else
01248         {
01249 //            WARNPRINTF("wait for data indefinately");
01250             retval = select(sockfd+1, &rfds, NULL, NULL, NULL);
01251         }
01252         
01253         if (retval == -1 && errno == EINTR)
01254         {
01255             continue;        
01256         }
01257         if (retval < 0)
01258         {
01259             ERRORPRINTF("error in select");
01260             return arg;
01261         }
01262         if (retval > 0)
01263         {
01264             if (FD_ISSET(sockfd, &rfds))
01265             {
01266 //                WARNPRINTF("data available");
01267                 recv(sockfd, buffer, BUFFERSIZE, MSG_PEEK);
01268                 gint state  = sys_get_power_state();
01269                 if ((state == STATE_POWER_IDLE) || (state == STATE_POWER_STANDBY))
01270                 {
01271                     // device is not ready, check again after a little while
01272                     g_usleep(10*1000);
01273                     continue;
01274                 }
01275                 
01276                 n = recv(sockfd, buffer, BUFFERSIZE, 0);
01277                 buffer[n] = '\0';
01278                 parse_gtk_message(buffer);
01279             }
01280             else
01281             {
01282                 WARNPRINTF("huh? data for other channel");
01283             }
01284         }
01285         else
01286         {
01287             if (g_timeout.tv_sec >= 0 || g_timeout.tv_usec >= 0) 
01288             {
01289 //                WARNPRINTF("timeout, update");
01290                 on_message_timeout();
01291             }
01292             else
01293             {
01294 //                WARNPRINTF("timeout was reset");
01295             }
01296         }
01297     }
01298     return arg;
01299 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean handle_gtk_socket ( GIOChannel *  source,
GIOCondition  condition,
gpointer  data 
) [static]

Definition at line 843 of file dm.c.

References buffer, LOGPRINTF, parse_gtk_messages(), UNUSED, and WARNPRINTF.

Referenced by main().

00844 {
00845     UNUSED(data);
00846     
00847     LOGPRINTF("entry");
00848     
00849     if (condition != G_IO_IN) {
00850         WARNPRINTF("%s() UNKNOWN CONDITION (%d)", __func__, condition);
00851         return FALSE;
00852     }
00853 
00854     gchar *buffer = NULL;
00855     gsize last_byte = 0;
00856     gsize bytes_read = 0;
00857     GError *error = NULL;
00858     g_io_channel_read_line(source, &buffer, &bytes_read, &last_byte, &error);
00859     buffer[last_byte] = '\0';
00860     if (error) {
00861         WARNPRINTF("GTK socket read failed: %s", error->message);
00862         g_error_free(error);
00863     } else {
00864         parse_gtk_messages(buffer);
00865     }
00866     g_free(buffer);
00867     return TRUE;    // keep listening
00868 } 

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean handle_wm_socket ( GIOChannel *  source,
GIOCondition  condition,
gpointer  data 
)

Definition at line 350 of file sysd/src/display.c.

References buffer, parse_wm_messages(), UNUSED, and WARNPRINTF.

Referenced by display_set_services().

00351 {
00352     UNUSED(data);
00353     
00354     if (condition != G_IO_IN) {
00355         WARNPRINTF("%s() UNKNOWN CONDITION (%d)", __func__, condition);
00356         return FALSE;
00357     }
00358 
00359     gchar* buffer = NULL;
00360     gsize bytes_read = 0;
00361     gsize last_byte = 0;
00362     GError *error = NULL;
00363     g_io_channel_read_line(source, &buffer, &bytes_read, &last_byte, &error);
00364     buffer[last_byte] = 0;
00365     if (error) {
00366         WARNPRINTF("WM socket read failed: %s", error->message);
00367         g_error_free(error);
00368     } else {
00369         parse_wm_messages(buffer);
00370     }
00371     g_free(buffer);
00372     return TRUE;    // keep listening
00373 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean ignore_pid ( gint  pid  )  [static]

Definition at line 487 of file sysd/src/display.c.

Referenced by parse_gtk_message().

00488 {
00489     // just test if ANY pid ignored
00490     return (g_slist_length(g_ignorelist) > 0);
00491 }

Here is the caller graph for this function:

static void ignore_pid_add ( gint  pid  )  [static]

Definition at line 494 of file sysd/src/display.c.

References LOGPRINTF.

Referenced by parse_gtk_message().

00495 {
00496     LOGPRINTF("entry [%d]", pid);
00497 
00498     GSList *found = g_slist_find(g_ignorelist, (gconstpointer) pid);
00499     if (found == NULL) 
00500     {
00501         LOGPRINTF("added [%d]", pid);
00502         g_ignorelist = g_slist_prepend(g_ignorelist, (gpointer) pid);
00503     }
00504 }

Here is the caller graph for this function:

static void ignore_pid_remove ( gint  pid  )  [static]

Definition at line 507 of file sysd/src/display.c.

References LOGPRINTF.

Referenced by display_cleanup_pid(), and parse_gtk_message().

00508 {
00509     LOGPRINTF("entry [%d]", pid);
00510     g_ignorelist = g_slist_remove(g_ignorelist, (gpointer) pid);
00511 }

Here is the caller graph for this function:

static void lock_display ( void   )  [static]

Definition at line 264 of file sysd/src/display.c.

Referenced by parse_gtk_message().

00264 { g_display_locked = TRUE; }

Here is the caller graph for this function:

static gboolean locked_display ( void   )  [static]

Definition at line 263 of file sysd/src/display.c.

Referenced by parse_gtk_message().

00263 { return g_display_locked; }

Here is the caller graph for this function:

static void on_message_timeout ( void   )  [static]

Definition at line 896 of file sysd/src/display.c.

References DELTA_TIME_FULL, DELTA_TIME_QUICK, display_update(), g_timeout, getCurrentTime(), WAVEFORM_FULL, WAVEFORM_PARTIAL, and WAVEFORM_QUICK.

Referenced by gtk_messages().

00897 {
00898     gint waveform = WAVEFORM_FULL;
00899     
00900     if (useSpecialWaveform != 0)
00901     {
00902         waveform = useSpecialWaveform;
00903     }
00904 
00905     // set time when delta is available again
00906     deltaAvailableAgain = getCurrentTime();
00907     if ((waveform == WAVEFORM_FULL) || (waveform == WAVEFORM_PARTIAL)) 
00908     {
00909         deltaAvailableAgain += DELTA_TIME_FULL;
00910     } 
00911     else if (waveform == WAVEFORM_QUICK) 
00912     {
00913         deltaAvailableAgain += DELTA_TIME_QUICK;
00914     }
00915     
00916     // reset display command
00917     bzero(&DisplayCommand, sizeof(DMCommand));
00918     useSpecialWaveform = 0;
00919     
00920     // perform display update
00921     display_update(waveform);
00922 
00923     g_timeout.tv_sec = -1;
00924     g_timeout.tv_usec = -1;
00925 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gint parse_command ( erDmCmd_t pCmd,
DMCommand command 
) [static]

Definition at line 1130 of file sysd/src/display.c.

References erDmCmd_t::arg, erDmCmd_t::cc, DMCommand::cmd, DM_FORCE, DM_INFO, ERRORPRINTF, DMCommand::force, DMCommandInfo::h, DMCommandForce::hint, DMCommand::info, DMCommandInfo::isFocus, DMCommandInfo::isWindow, DMCommandForce::pid, DMCommandInfo::pid, DMCommandInfo::shouldIgnore, DMCommandForce::takeControl, DMCommandInfo::w, DMCommandInfo::widgetType, DMCommandInfo::windowType, DMCommandInfo::x, and DMCommandInfo::y.

Referenced by parse_gtk_message().

01131 {
01132     switch (pCmd->cc)
01133     {
01134     case DM_INFO:
01135         command->cmd                = DM_INFO;
01136         command->info.pid           = atoi(pCmd->arg[0]);
01137         command->info.x             = atoi(pCmd->arg[1]);
01138         command->info.y             = atoi(pCmd->arg[2]);
01139         command->info.w             = atoi(pCmd->arg[3]);
01140         command->info.h             = atoi(pCmd->arg[4]);
01141         command->info.shouldIgnore  = atoi(pCmd->arg[5]);
01142         command->info.isWindow      = atoi(pCmd->arg[6]);
01143         command->info.windowType    = atoi(pCmd->arg[7]);
01144         strcpy(command->info.widgetType,pCmd->arg[8]);   
01145         command->info.isFocus       = atoi(pCmd->arg[9]);
01146         break;
01147 
01148     case DM_FORCE:
01149         command->cmd                = DM_FORCE;
01150         command->force.pid          = atoi(pCmd->arg[0]);
01151         command->force.takeControl  = atoi(pCmd->arg[1]);
01152         command->force.hint         = atoi(pCmd->arg[2]);
01153         break;
01154 
01155     default:
01156         ERRORPRINTF("Undefined command");
01157         return -1;
01158         break;
01159     }
01160     return 0;
01161 }

Here is the caller graph for this function:

static void parse_gtk_message ( char *  buffer  )  [static]

Definition at line 543 of file sysd/src/display.c.

References DMCommand::cmd, DM_FORCE, DM_HINT_CURSOR, DM_HINT_FULL, DM_HINT_KEY, DM_HINT_LOCK, DM_HINT_NONE, DM_HINT_PARTIAL, DM_HINT_SPLASH, DM_HINT_UNLOCK, DM_INFO, DMPPRINTF, DMCommand::force, g_timeout, DMCommandInfo::h, DMCommandForce::hint, ignore_pid(), ignore_pid_add(), ignore_pid_remove(), DMCommand::info, DMCommandInfo::isFocus, DMCommandInfo::isWindow, lock_display(), locked_display(), WMInfo::name, ORIENTATION_PORTRAIT, parse_command(), parse_message(), DMCommandInfo::pid, DMCommandForce::pid, promote_waveform(), schedule_update(), DMCommandInfo::shouldIgnore, sys_get_orientation(), DMCommandForce::takeControl, unlock_display(), DMCommandInfo::w, WARNPRINTF, WAVEFORM_FULL, WAVEFORM_PARTIAL, WAVEFORM_QUICK, DMCommandInfo::widgetType, and DMCommandInfo::windowType.

Referenced by gtk_messages().

00544 {    
00545 //    LOGPRINTF("entry");
00546 
00547 #if DMLOGGING_ON
00548     static GTimeVal   oldtime = {0};
00549 #endif    
00550     erDmCmd_t  cmd;
00551     DMCommand  command;
00552     bzero(&command, sizeof(command));
00553 
00554     if ((parse_message(buffer, &cmd)==0) && (parse_command(&cmd, &command) == 0))
00555     {
00556 #if DMLOGGING_ON
00557         GTimeVal curtime;
00558         g_get_current_time(&curtime);
00559         
00560         guint timediff = ((curtime.tv_sec - oldtime.tv_sec) * 1000) + 
00561             ((curtime.tv_usec / 1000 ) - (oldtime.tv_usec / 1000));
00562 #endif
00563 
00564         if (command.cmd == DM_FORCE)
00565         {
00566             DMCommandForce force = command.force;
00567             
00568             DMPPRINTF("%ld:%3ld [%4d] checking msg: %d, %d, %d", 
00569                 curtime.tv_sec, curtime.tv_usec / 1000, timediff, 
00570                 force.pid, force.takeControl, force.hint); 
00571 
00572             if (force.takeControl > 0)
00573             {
00574                 DMPPRINTF(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
00575                 ignore_pid_add(force.pid);
00576                 if (!locked_display() && (g_timeout.tv_sec > 0 || g_timeout.tv_usec > 0))
00577                 {
00578                     // cancel pending update
00579                     DMPPRINTF("cancel pending update");
00580                     bzero(&DisplayCommand, sizeof(DMCommand));
00581                     g_timeout.tv_sec = -1;
00582                     g_timeout.tv_usec = -1;
00583                 }
00584             }
00585             else
00586             {
00587                 DMPPRINTF("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
00588                 ignore_pid_remove(force.pid);
00589             }
00590             
00591             if (force.hint != DM_HINT_NONE)
00592             {
00593                 gint update_delay = UPDATE_TIMEOUT_FORCED;
00594                 switch (force.hint)
00595                 {
00596                     case DM_HINT_LOCK:
00597                         lock_display();
00598                         break;
00599                     case DM_HINT_UNLOCK:
00600                         unlock_display();
00601                         break;
00602                     case DM_HINT_FULL:
00603                     case DM_HINT_SPLASH:
00604                         useSpecialWaveform = WAVEFORM_FULL;
00605                         break;
00606                     case DM_HINT_CURSOR:
00607                         useSpecialWaveform = WAVEFORM_QUICK;
00608                         break;
00609                     case DM_HINT_PARTIAL:
00610                         useSpecialWaveform = WAVEFORM_PARTIAL;
00611                         break;
00612                     case DM_HINT_KEY:
00613                         update_delay = 20;
00614                         useSpecialWaveform = WAVEFORM_QUICK;
00615                         break;
00616                     default:
00617                         WARNPRINTF("unsupported display manager hint [%d]", force.hint);
00618                         useSpecialWaveform = WAVEFORM_FULL;
00619                         break;
00620                 }
00621 
00622                 if (sys_get_orientation() != ORIENTATION_PORTRAIT)
00623                 {
00624                     // account for slower updates when display is rotated
00625                     switch (force.hint)
00626                     {
00627                         case DM_HINT_FULL:
00628                             update_delay = UPDATE_TIMEOUT_NORMAL_LANDSCAPE;
00629                             break;
00630                         case DM_HINT_SPLASH:
00631                             // splash screens are shown in portrait mode
00632                             update_delay = UPDATE_TIMEOUT_NORMAL_PORTRAIT; 
00633                             break;
00634                         case DM_HINT_PARTIAL:
00635                             update_delay = UPDATE_TIMEOUT_NORMAL_LANDSCAPE;
00636                             break;
00637                         case DM_HINT_CURSOR:
00638                         case DM_HINT_KEY:
00639                             update_delay = 150;
00640                             break;
00641                         case DM_HINT_LOCK:
00642                         case DM_HINT_UNLOCK:
00643                             break;
00644                         default:
00645                             WARNPRINTF("unsupported display manager hint [%d]", force.hint);
00646                             break;
00647                     }
00648                 }
00649 
00650                 if ( (!locked_display() && !(force.hint == DM_HINT_UNLOCK)) || (force.hint == DM_HINT_SPLASH)  )
00651                 {
00652                     schedule_update(update_delay, "forced by application");
00653                 }
00654             }
00655         }
00656         else if (command.cmd == DM_INFO) 
00657         {
00658             DMCommandInfo  info  = command.info;
00659             const gchar   *rule        = NULL;
00660             gboolean      save         = FALSE;
00661             gboolean      trigger      = FALSE;
00662             gboolean      skip         = FALSE;
00663             guint         area_pending = DisplayCommand.info.w * DisplayCommand.info.h;
00664             gboolean      is_portait   = (sys_get_orientation() == ORIENTATION_PORTRAIT) ? TRUE : FALSE;
00665             gboolean      is_pending   = (area_pending > 0) ? TRUE : FALSE;
00666             guint      delay        = is_portait ? UPDATE_TIMEOUT_NORMAL_PORTRAIT : UPDATE_TIMEOUT_NORMAL_LANDSCAPE;
00667             guint         area         = info.w * info.h;
00668             
00669             if ((info.pid != -1) && ignore_pid(info.pid) && 
00670                 (strcmp(info.widgetType,"erGtkBusyDialog") != 0) && (strcmp(info.widgetType,"GtkMessageDialog") != 0))
00671             {
00672                 // skip updates when busy or loading dialog is shown
00673                 skip = TRUE;
00674             }
00675 
00676             DMPPRINTF("%ld:%3ld [%4d] %s pid [%d] %4dx%4d flags: i[%d] w[%d] t[%d] f[%d] %s",
00677                 curtime.tv_sec, curtime.tv_usec / 1000, timediff, skip ? "SKIPPED" : "checking", 
00678                 info.pid, info.w, info.h, info.shouldIgnore,
00679                 info.isWindow, info.windowType, info.isFocus,
00680                 info.widgetType);
00681             
00682             //
00683             // SPECIAL RULES - pre
00684             //
00685            
00686             if (!is_pending && info.h == 32 &&
00687                 strcmp(info.widgetType, "GtkEventBox") == 0)
00688             {
00689                 rule = "statusbar";
00690                 promote_waveform(WAVEFORM_PARTIAL);
00691                 save  = TRUE;
00692             }
00693 
00694             if (!is_pending && strcmp(info.widgetType,"GtkEntry")==0)
00695             {
00696                 rule = "keyboard entry";
00697                 promote_waveform( WAVEFORM_QUICK);
00698                 delay = UPDATE_TIMEOUT_TYPE;
00699                 save  = TRUE;
00700             }
00701             
00702             //
00703             // GENERAL RULES
00704             //
00705 
00706             if (!info.shouldIgnore ||
00707                 (strcmp(info.widgetType,"HtmlView")         == 0) || /* for libgtkhtml */
00708                 (strcmp(info.widgetType,"GtkDrawingArea")   == 0) ||
00709                 (strcmp(info.widgetType,"GtkCalendar")      == 0) ||
00710                 (strcmp(info.widgetType,"GtkTreeView")      == 0) ||
00711                 (strcmp(info.widgetType,"GtkIconView")      == 0) ||
00712                 (strcmp(info.widgetType,"erGtkIconView")    == 0) ||
00713                 (strcmp(info.widgetType,"erGtkListView")    == 0) ||
00714                 (strcmp(info.widgetType,"erGtkNetworkList") == 0) ||
00715                 (strcmp(info.widgetType,"WebKitWebView")    == 0) ||
00716                 (strcmp(info.widgetType,"GtkMenu")          == 0) ||
00717                 (strcmp(info.widgetType,"GtkProgressBar")   == 0) )
00718             {
00719                 if (!is_pending &&
00720                     info.isFocus && 
00721                     (area<UPDATE_AREA_CONTENT) &&
00722                     ((strcmp(info.widgetType, "erGtkIconView") == 0) ||
00723                      (strcmp(info.widgetType, "erGtkNetworkList") == 0) ||
00724                      (strcmp(info.widgetType, "erGtkListView") == 0)) ) 
00725                 {
00726                     rule = "cursor";
00727                     promote_waveform(WAVEFORM_QUICK);
00728                     delay = is_portait ? UPDATE_TIMEOUT_CURSOR : 3*UPDATE_TIMEOUT_CURSOR;
00729                     save  = TRUE;
00730                 }
00731                 else if (strcmp(WindowInfo.name, "erbrowser") == 0)
00732                 {
00733                     if ( !((strcmp(info.widgetType, "GtkWindow") == 0) && is_pending)
00734                         && ((area * 3) < UPDATE_AREA_FULL) )
00735                     {
00736                         rule = "paint, partial (browser)";
00737                         promote_waveform(WAVEFORM_PARTIAL);
00738                     }
00739                     else
00740                     {
00741                         rule = "paint, full (browser)";
00742                         promote_waveform(WAVEFORM_FULL);
00743                         delay = 1000;
00744                     }
00745                     save = TRUE;
00746                 }
00747                 else if (area > area_pending)
00748                 {
00749                     if ((area * 3) < UPDATE_AREA_FULL)
00750                     {
00751                         promote_waveform(WAVEFORM_PARTIAL);
00752                         rule = "paint, partial";
00753                     }
00754                     else
00755                     {
00756                         promote_waveform(WAVEFORM_FULL);
00757                         rule = "paint, full";
00758                         
00759                         if (is_portait && strcmp(info.widgetType,"GtkDrawingArea") == 0)
00760                         {
00761                             rule = "paint, full (UDS)";
00762                             delay /= 2;
00763                         }
00764                     }
00765                     save = TRUE;
00766                 }
00767                 else if (is_pending)
00768                 {
00769                     if (is_portait && strcmp(info.widgetType,"erGtkIconView")  == 0)
00770                     {
00771                         delay /= 2;
00772                     }
00773                     rule    = "delay";
00774                     trigger = TRUE;
00775                 }
00776             }
00777             
00778             //
00779             // SPECIAL RULES - post - override general rules
00780             //
00781            
00782             if (!is_pending && info.h == 29 && 
00783                 ((strcmp(info.widgetType,"GtkMessageDialog")==0) ||
00784                  (strcmp(info.widgetType,"GtkDialog")==0)))
00785             {
00786                 rule = "button cursor";
00787                 useSpecialWaveform = WAVEFORM_QUICK;
00788                 delay = is_portait ? UPDATE_TIMEOUT_CURSOR : 2*UPDATE_TIMEOUT_CURSOR;
00789                 save  = TRUE;
00790             }
00791             
00792             if (!is_pending && strcmp(info.widgetType,"erscribble")==0)
00793             {
00794                 rule = "scribble";
00795                 useSpecialWaveform = WAVEFORM_PARTIAL;
00796                 delay = UPDATE_TIMEOUT_SCRIBBLE;
00797                 save  = TRUE;
00798             }
00799             
00800             // NOTE: check is_pending
00801             if (is_pending && 
00802                 (useSpecialWaveform != WAVEFORM_FULL) &&
00803                 ( (strcmp(info.widgetType, "WebKitWebView")==0) ||
00804                   (strcmp(info.widgetType, "GtkEntry")==0) ) )
00805             {
00806                 rule = "entry speedup";
00807                 save = FALSE;
00808                 delay /= 2;
00809                 trigger = FALSE;
00810             }
00811             
00812             //
00813             // Save command and (re)set timeout
00814             //
00815             
00816             if (save)
00817             {
00818                 DMPPRINTF("%ld:%3ld save area %d (rule: %s)", curtime.tv_sec, curtime.tv_usec / 1000, area, rule);
00819                 
00820                 memcpy(&DisplayCommand, &command, sizeof(DMCommand));
00821                 trigger = TRUE;
00822             }
00823                 
00824             if (trigger && !skip)
00825             {
00826                 schedule_update(delay, rule);
00827             }
00828         }
00829 #if DMLOGGING_ON
00830         memcpy(&oldtime, &curtime, sizeof(GTimeVal));
00831 #endif                
00832     }
00833 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gint parse_message ( char *  szCommand,
erDmCmd_t pCmd 
) [static]

Definition at line 1069 of file sysd/src/display.c.

References erDmCmd_t::arg, erDmCmd_t::cc, DM_FORCE, DM_INFO, DM_MAXCHARONLINE, DM_N_ARG, DM_UNDEFINED, ERRORPRINTF, get_arguments(), erDmCmd_t::name, and erDmCmd_t::nArg.

Referenced by parse_gtk_message().

01070 {
01071     int     i;
01072     char   *pChar;
01073     char    szToken[DM_MAXCHARONLINE];
01074 
01075     pCmd->cc = (int) DM_UNDEFINED;
01076     for (i = 0; i < DM_N_ARG; i++)
01077     {
01078         strcpy(pCmd->arg[i], "");
01079     }
01080 
01081     // parse command, form of a command is: !n1,n2,n3...
01082     if (szCommand[0] != '!')
01083     {
01084         ERRORPRINTF("Command should start with \'!\'. (%s)", szCommand);
01085         return -1;
01086     }
01087 
01088     // move beyond initial '!'
01089     pChar = szCommand + 1;
01090     i = 0;
01091     while (*pChar != '\0')
01092     {
01093         szToken[i] = '\0';
01094         if (*pChar == ',')
01095         {
01096             pChar++;
01097             break;
01098         }
01099         szToken[i] = *pChar++;
01100         i++;
01101         szToken[i] = '\0';
01102     }
01103 
01104     // we have found the command token, figure out what the command is
01105     if (!strcmp(szToken, "I"))
01106     {
01107         strcpy(pCmd->name, szToken);
01108         pCmd->cc = DM_INFO;
01109         pCmd->nArg = 10;
01110     }
01111     else if (!strcmp(szToken, "F"))
01112     {
01113         strcpy(pCmd->name, szToken);
01114         pCmd->cc = DM_FORCE;
01115         pCmd->nArg = 3;
01116     }
01117     else
01118     {
01119         return -1;
01120     }
01121 
01122     if (pCmd->nArg > 0)
01123     {
01124         get_arguments(pChar, pCmd, pCmd->nArg);
01125     }
01126     return 0;
01127 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void parse_wm_messages ( char *  buffer  )  [static]

Definition at line 272 of file sysd/src/display.c.

References CLIENT_IS_MENU_DIALOG, DMPPRINTF, WMInfo::flags, ipc_send_window_activated(), ipc_send_window_deactivated(), LOGPRINTF, MBCLIENT_TYPE_DIALOG, WMInfo::name, name, WMInfo::pid, proc_t::pid, process_get_by_name(), service, task_service_by_window(), WMInfo::type, WAVEFORM_FULL, WMInfo::window, and WM_NAME.

Referenced by handle_wm_socket().

00273 {
00274     // handle single message
00275     gchar **args = g_strsplit_set(buffer, ",", 4);
00276 
00277     gint window = atoi(args[0]);
00278     gint type   = atoi(args[1]);
00279     glong flags  = atol(args[2]);
00280     gchar *endp   = strchr(args[3], ' ');
00281     if (endp) {
00282         *endp = '\0';
00283     }
00284     gchar *name   = args[3];
00285 
00286     proc_t *proc = process_get_by_name(name);
00287 
00288     if ( ((type & MBCLIENT_TYPE_DIALOG) == MBCLIENT_TYPE_DIALOG) &&
00289          ((flags & CLIENT_IS_MENU_DIALOG) != CLIENT_IS_MENU_DIALOG) )
00290     {
00291         DMPPRINTF("ignored dialog, window [%d] name [%s] pid [%d]", WindowInfo.window, name, proc ? proc->pid : -1);
00292     }
00293     else
00294     {
00295         if ( (g_prev_window != window) &&
00296              ((flags & CLIENT_IS_MENU_DIALOG) != CLIENT_IS_MENU_DIALOG) )
00297         {
00298             LOGPRINTF("changed window and not menu, deactivate previous: %d", g_prev_window);
00299 
00300             // new window set as foreground, send deactivated to window
00301             if (g_prev_window > 0)
00302             {
00303                 const gchar *service = task_service_by_window(g_prev_window);
00304                 if (service)
00305                 {
00306                     ipc_send_window_deactivated(service,  g_prev_window);
00307                 }
00308                 else if (g_ctb_window != 0 && g_prev_window == g_ctb_window)
00309                 {
00310                     ipc_send_window_deactivated("com.irexnet.ctb", g_ctb_window);
00311                 }
00312             }
00313 
00314             if (window > 0)
00315             {
00316                 // send activatedWindow to window's application
00317                 const gchar *service = task_service_by_window(window);
00318                 if (service)
00319                 {
00320                     ipc_send_window_activated(service, window);
00321                 }
00322                 else if (g_ctb_window != 0 && window == g_ctb_window)
00323                 {
00324                     ipc_send_window_activated("com.irexnet.ctb", g_ctb_window);
00325                 }
00326             }
00327             g_prev_window = window;
00328         }
00329 
00330         // set current window info
00331         strncpy(WindowInfo.name, name, WM_NAME);
00332         WindowInfo.name[WM_NAME-1] = '\0';
00333         WindowInfo.window = window;
00334         WindowInfo.type   = type;
00335         WindowInfo.flags  = flags;
00336         WindowInfo.pid    = proc ? proc->pid : -1;
00337 
00338         DMPPRINTF("set window info [%d] type [%d] flags [%ld] name [%s] pid [%d]",
00339                   WindowInfo.window, WindowInfo.type, WindowInfo.flags, WindowInfo.name,
00340                   WindowInfo.pid);
00341     }
00342 
00343     // force next update to be full screen
00344     useSpecialWaveform = WAVEFORM_FULL;
00345 
00346     g_strfreev(args);
00347 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void promote_waveform ( gint  waveform  )  [static]

Definition at line 514 of file sysd/src/display.c.

References WAVEFORM_FULL, WAVEFORM_PARTIAL, and WAVEFORM_QUICK.

Referenced by parse_gtk_message().

00515 {
00516     if (useSpecialWaveform == waveform)
00517         return;
00518     
00519     switch (waveform)
00520     {
00521     case WAVEFORM_QUICK: 
00522         if (useSpecialWaveform == 0)
00523         {
00524             useSpecialWaveform = waveform;
00525         }
00526         break;
00527                 
00528     case WAVEFORM_PARTIAL: 
00529         if ((useSpecialWaveform == 0) || (useSpecialWaveform  == WAVEFORM_QUICK))
00530         {
00531             useSpecialWaveform = waveform;
00532         }
00533         break;
00534                 
00535     case WAVEFORM_FULL: 
00536     default: 
00537         useSpecialWaveform = waveform;
00538         break;
00539     }
00540 }

Here is the caller graph for this function:

static void schedule_update ( gint  delay,
const char *  rule 
) [static]

Definition at line 836 of file sysd/src/display.c.

References DELTA_TIME_FULL, DMPPRINTF, g_timeout, and getCurrentTime().

Referenced by parse_gtk_message().

00837 {
00838     gulong udelay;
00839     
00840     // check if sending screen updates too fast
00841     uint64_t now = getCurrentTime();
00842 #if DMLOGGING_ON
00843     guint prev_delay = mdelay;
00844 #endif                
00845     // adjust delay to after delta is available again
00846     // except when time was set back as deltaAvailableAgain can't be trusted then
00847     if (((deltaAvailableAgain != 0) && ((now + mdelay*1000) < deltaAvailableAgain))
00848         && ((deltaAvailableAgain - DELTA_TIME_FULL) < now))
00849     {
00850         udelay = (deltaAvailableAgain - now);
00851     }
00852     else
00853     {
00854         udelay = mdelay * 1000;
00855     }
00856 
00857     // set new timeout
00858     g_timeout.tv_sec  = udelay / G_USEC_PER_SEC;
00859     g_timeout.tv_usec = udelay % G_USEC_PER_SEC;
00860     
00861     DMPPRINTF("set delay %ld.%03d [was 0.%03d] (rule: %s)", g_timeout.tv_sec, g_timeout.tv_usec/1000, prev_delay, rule);
00862 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void unlock_display ( void   )  [static]

Definition at line 265 of file sysd/src/display.c.

Referenced by parse_gtk_message().

00265 { g_display_locked = FALSE; }

Here is the caller graph for this function:


Variable Documentation

uint64_t deltaAvailableAgain = 0 [static]

Definition at line 227 of file sysd/src/display.c.

Definition at line 225 of file sysd/src/display.c.

pthread_t dm_thread [static]

Definition at line 235 of file sysd/src/display.c.

int fbDev = 0 [static]

Definition at line 223 of file sysd/src/display.c.

Referenced by main().

int g_ctb_window = 0 [static]

Definition at line 230 of file sysd/src/display.c.

gboolean g_display_locked = FALSE [static]

Definition at line 232 of file sysd/src/display.c.

GSList* g_ignorelist = NULL [static]

Definition at line 228 of file sysd/src/display.c.

int g_prev_window = 0 [static]

Definition at line 231 of file sysd/src/display.c.

struct timeval g_timeout [static]
gboolean g_vcom_is_set = FALSE [static]

Definition at line 233 of file sysd/src/display.c.

int useSpecialWaveform = 0 [static]

Definition at line 224 of file sysd/src/display.c.

WMInfo WindowInfo [static]

Definition at line 226 of file sysd/src/display.c.

Generated by  doxygen 1.6.2-20100208