Back to index

im-sdk  12.3.91
Functions | Variables
neima_aux.c File Reference
#include <stdio.h>
#include "aux_module.h"
#include <gdk/gdkx.h>
#include <gtk/gtk.h>

Go to the source code of this file.

Functions

AuxResult neima_aux_Start (aux_ext_data_t *aux_ext_data)
AuxResult neima_aux_Draw (aux_ext_data_t *aux_ext_data)
AuxResult neima_aux_Done (aux_ext_data_t *aux_ext_data)
static int ui_screen_width (void)
static int ui_screen_height (void)
static void ui_toolbar_set_position (gint pos_x, gint pos_y)
static gboolean ui_toolbar_motion_cb (GtkWidget *window, GdkEventMotion *event, gpointer user_data)
static gboolean ui_toolbar_click_cb (GtkWidget *window, GdkEventButton *event, gpointer user_data)
static void GetWindowPosition (Display *display, Window clientwindow, int *win_x, int *win_y)
static void GetDefaultPosition (int *win_x, int *win_y)
static void SetCandidateAuxPosition (aux_ext_data_t *aux_ext_data)

Variables

AuxModuleMethodsRec aux_module_methods
AuxModuleRec neima_aux_module
static GtkWidget * _toolbar = NULL
static GtkWidget * _label = NULL
static gboolean _toolbar_draging = FALSE
static gint _toolbar_drag_x = 0
static gint _toolbar_drag_y = 0
static gint _toolbar_pos_x = 0
static gint _toolbar_pos_y = 0
static gboolean _toolbar_show_status = FALSE

Function Documentation

static void GetDefaultPosition ( int *  win_x,
int *  win_y 
) [static]

Definition at line 156 of file neima_aux.c.

{
       GtkRequisition ws;

       gtk_widget_size_request (_toolbar, &ws);

       *win_x = (gdk_screen_width () > 640)?200:100;
       *win_y = (gdk_screen_height () - ws.height - 10 - 36);
}

Here is the caller graph for this function:

static void GetWindowPosition ( Display *  display,
Window  clientwindow,
int *  win_x,
int *  win_y 
) [static]

Definition at line 139 of file neima_aux.c.

{
       int x=0, y=0;
       Window w_none;
       XWindowAttributes attr;

       if (clientwindow && display) {
              XGetWindowAttributes(display, clientwindow, &attr);
              if (attr.root)
                     XTranslateCoordinates(display, clientwindow, 
                            attr.root, -(attr.border_width), -(attr.border_width), &x, &y,
                             &w_none );
       }
       *win_x = x;
       *win_y = y;
}

Here is the caller graph for this function:

static void SetCandidateAuxPosition ( aux_ext_data_t aux_ext_data) [static]

Definition at line 167 of file neima_aux.c.

{
       int win_x = 0, win_y = 0;

       GetWindowPosition((Display *)GDK_WINDOW_XDISPLAY(_toolbar->window), aux_ext_data->clientwin, &win_x, &win_y);
       if ((win_x == 0 && win_y == 0) || 
           (aux_ext_data->point.x == 0 && aux_ext_data->point.y == 0)) {
              GetDefaultPosition(&win_x, &win_y);
       } else {
              win_x += aux_ext_data->point.x;
              win_y += aux_ext_data->point.y + 22;
       }

       ui_toolbar_set_position(win_x, win_y);
}

Here is the call graph for this function:

static int ui_screen_height ( void  ) [static]

Definition at line 43 of file neima_aux.c.

{
    return gdk_screen_height ();
}

Here is the caller graph for this function:

static int ui_screen_width ( void  ) [static]

Definition at line 37 of file neima_aux.c.

{
    return gdk_screen_width ();
}

Here is the caller graph for this function:

static gboolean ui_toolbar_click_cb ( GtkWidget *  window,
GdkEventButton *  event,
gpointer  user_data 
) [static]

Definition at line 95 of file neima_aux.c.

{
    int click_type = GPOINTER_TO_INT (user_data);
    static gulong motion_handler;
    GdkCursor *cursor;
                                                                                                          
    if (click_type == 0 && event->button <= 1) {
        if (_toolbar_draging)
            return FALSE;
                                                                                                          
        // Connection pointer motion handler to this window.
        motion_handler = g_signal_connect (G_OBJECT (window), "motion-notify-event",
                                           G_CALLBACK (ui_toolbar_motion_cb),
                                           NULL);
                                                                                                          
        _toolbar_draging = TRUE;
        _toolbar_drag_x = (gint) event->x_root;
        _toolbar_drag_y = (gint) event->y_root;
                                                                                                          
        cursor = gdk_cursor_new (GDK_TOP_LEFT_ARROW);
                                                                                                          
        // Grab the cursor to prevent losing events.
        gdk_pointer_grab (window->window, TRUE,
                          (GdkEventMask) (GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
                          NULL, cursor, event->time);
        gdk_cursor_unref (cursor);
        return TRUE;
    } else if (click_type == 1 && event->button <= 1) {
        if (!_toolbar_draging)
            return FALSE;
                                                                                                          
        g_signal_handler_disconnect (G_OBJECT (window), motion_handler);
        gdk_pointer_ungrab (event->time);
        _toolbar_draging = FALSE;

        return TRUE;
    } else if (click_type == 1 && event->button > 1) {
        return TRUE;
    }
    return FALSE;
}

Here is the call graph for this function:

static gboolean ui_toolbar_motion_cb ( GtkWidget *  window,
GdkEventMotion *  event,
gpointer  user_data 
) [static]

Definition at line 74 of file neima_aux.c.

{
    gint pos_x, pos_y;
    if ((event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0 &&
        _toolbar_draging) {
        gtk_window_get_position (GTK_WINDOW (window), &pos_x, &pos_y);
        ui_toolbar_set_position(
            pos_x + ((gint) event->x_root - _toolbar_drag_x),
            pos_y + ((gint) event->y_root - _toolbar_drag_y));

        _toolbar_drag_x = (gint) event->x_root;
        _toolbar_drag_y = (gint) event->y_root;

        return TRUE;
    }
    return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ui_toolbar_set_position ( gint  pos_x,
gint  pos_y 
) [static]

Definition at line 48 of file neima_aux.c.

{
    GtkRequisition ws;

    gtk_widget_size_request (_toolbar, &ws);
                                                                                                         
    if (pos_x <= 0) {
        pos_x = ui_screen_width () - 400;
    } else if (pos_x + ws.width > ui_screen_width ()) {
        pos_x = ui_screen_width () - ws.width;
    }

    if (pos_y <= 0) {
        pos_y = ui_screen_height () - 76;
    } else if (pos_y + ws.height > ui_screen_height ()) {
        pos_y = ui_screen_height () - ws.height;
    }
                                                                                                                  
    if (_toolbar_pos_x != pos_x || _toolbar_pos_y != pos_y) {
        gtk_window_move (GTK_WINDOW (_toolbar), pos_x, pos_y);
        _toolbar_pos_x = pos_x;
        _toolbar_pos_y = pos_y;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GtkWidget* _label = NULL [static]

Definition at line 25 of file neima_aux.c.

GtkWidget* _toolbar = NULL [static]

Definition at line 24 of file neima_aux.c.

gint _toolbar_drag_x = 0 [static]

Definition at line 28 of file neima_aux.c.

gint _toolbar_drag_y = 0 [static]

Definition at line 29 of file neima_aux.c.

gboolean _toolbar_draging = FALSE [static]

Definition at line 27 of file neima_aux.c.

gint _toolbar_pos_x = 0 [static]

Definition at line 31 of file neima_aux.c.

gint _toolbar_pos_y = 0 [static]

Definition at line 32 of file neima_aux.c.

gboolean _toolbar_show_status = FALSE [static]

Definition at line 34 of file neima_aux.c.

Initial value:

Definition at line 11 of file neima_aux.c.

Initial value:
 {
       NULL,
       NULL,
       "com.sun.iiim.cle.aux.neima",
       &aux_module_methods,
}

Definition at line 17 of file neima_aux.c.