Getting X Cursor in WebKit GTK2+ widget if run by startx

91 views Asked by At

I try to write kiosk web browser and run it automaticly after system boot. It's simple GTK2+ application, with WebKit used as browser.
It starts from ~/.xinitrc:

exec /home/kiosk-user/bin/browser 'http://localhost/'

Source code browser.c:

#include <stdio.h>
#include <signal.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <webkit/webkit.h>

int main( int argc, char* argv[] ) {
    WebKitWebView* web_view;
    GtkWidget* window;
    GtkWidget* scrollable_content;

    if( argc < 2 ) {
        fprintf( stderr, "The first argument have to be URI" );
        return 1;
    }
    gchar* uri = argv[1];

    gtk_init( &argc, &argv );

    gint 
        screen_width = gdk_screen_width(),
        screen_height = gdk_screen_height();

    window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    scrollable_content = gtk_scrolled_window_new( NULL, NULL );

    gtk_window_set_default_size( GTK_WINDOW( window ), screen_width, screen_height );

    web_view = WEBKIT_WEB_VIEW( webkit_web_view_new() );

    gtk_container_add( GTK_CONTAINER( scrollable_content ), GTK_WIDGET( web_view ) );
    gtk_container_add( GTK_CONTAINER( window ), scrollable_content );

    GdkCursor* cursor = gdk_cursor_new( GDK_ARROW );
    gdk_window_set_cursor( window->window, cursor );

    webkit_web_view_load_uri( web_view, uri );

    gtk_widget_show_all( window );
    gtk_main();

    return 0;
}

The problem is cursor, it's not showing on application start, until I will click somewhere. When it will appear, it looks good on text input, links etc. but when I move from that kind of element, it changes appeariance to GDK_X_CURSOR(screenshot) instead of default arrow. Running it from desktop manager displays cursor properly. On web page cursor is default.

Testing on: Virtual Machine => Debian GNU/Linux 8.1 (jessie)

Thank you in advance for your help and sorry if my English is not good enough.

1

There are 1 answers

0
Adam Krause On BEST ANSWER

You can find solution here. Just put xsetroot -cursor_name left_ptr in your ~/.xinitrc.