From bc3d07b66b32db0278bc379f1a397410a876b94f Mon Sep 17 00:00:00 2001 From: Tomas 'ZeXx86' Jedrzejek Date: Sun, 18 Jul 2010 18:42:30 +0200 Subject: [PATCH] ZDE improvements - global zbitmap_t structure added, added native support for buttons, added support for buttons into windows/dialogs, better mouse button handling, support for options dialog on right click onto filesystem icons, checking for multiple graphics session added; init_vgafb () syscall is able to check multiple calls; little cleanup in NDP protocol structures --- apps/zde/appcl.c | 2 - apps/zde/appcl.h | 17 +--- apps/zde/button.c | 116 +++++++++++++++++-------- apps/zde/button.h | 2 + apps/zde/cursor.c | 4 +- apps/zde/handler.h | 2 + apps/zde/icon.c | 175 +++++++++++++++++++++++++------------- apps/zde/icon.h | 2 + apps/zde/main.c | 9 +- apps/zde/window.c | 3 + kernel/drivers/char/video/video.c | 13 ++- kernel/include/net/ndp.h | 17 +--- libx/base/xinit.c | 8 +- libx/libx/base.h | 3 +- 14 files changed, 241 insertions(+), 132 deletions(-) diff --git a/apps/zde/appcl.c b/apps/zde/appcl.c index 52cd8f6..fe9d132 100755 --- a/apps/zde/appcl.c +++ b/apps/zde/appcl.c @@ -226,8 +226,6 @@ int zgui_button (unsigned short x, unsigned short y, char *str) unsigned len = strlen (str); - /*xrectfill (zappcl->x+4+x, zappcl->y+21+y, zappcl->x+8+x+(len*6), zappcl->y+31+y, ~0);*/ - bitmap_button.x = zappcl->x+4+x; bitmap_button.y = zappcl->y+21+y; bitmap_button.posx = 0; diff --git a/apps/zde/appcl.h b/apps/zde/appcl.h index d9b387b..ebc2e07 100755 --- a/apps/zde/appcl.h +++ b/apps/zde/appcl.h @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,8 @@ #ifndef _APPCL_H #define _APPCL_H +#include "bitmap.h" + #define APPCL_STATE_REDRAW 0x1 #define APPCL_STATE_RECVOK 0x2 #define APPCL_STATE_EXIT 0x4 @@ -39,20 +42,6 @@ typedef struct { unsigned char kbd; } __attribute__ ((__packed__)) appcl_t; -typedef struct { - unsigned short x; - unsigned short y; - unsigned short resx; - unsigned short resy; - - unsigned short posx; - unsigned short posy; - unsigned short sizex; - unsigned short sizey; - - unsigned short *data; -} zbitmap_t; - extern appcl_t *zgui_window (); extern void zgui_puts (unsigned short x, unsigned short y, char *str, unsigned color); extern int zgui_button (unsigned short x, unsigned short y, char *str); diff --git a/apps/zde/button.c b/apps/zde/button.c index 9b96012..5e768a4 100755 --- a/apps/zde/button.c +++ b/apps/zde/button.c @@ -29,16 +29,19 @@ #include #include +#include "bitmap.h" #include "button.h" #include "cursor.h" #include "window.h" #include "handler.h" -unsigned short *bitmap_button; +static zbitmap_t bitmap_button; -//zde_btn_t zde_btn_list; +zde_btn_t zde_btn_list; extern zde_cursor_t *zde_cursor; +extern unsigned short image_button[]; + #ifdef TEST zde_btn_t *create_button (char *name, int type, void *(*entry) (void *), void *arg) { @@ -50,7 +53,7 @@ zde_btn_t *create_button (char *name, int type, void *(*entry) (void *), void *a if (type == 0) { button->arg = arg; - button->bitmap = bitmap_folder; + button->bitmap = image_button; } else button->bitmap = 0; @@ -72,6 +75,7 @@ zde_btn_t *create_button (char *name, int type, void *(*entry) (void *), void *a return button; } +#endif zde_btn_t *create_button_window (char *name, int type, void *(*entry) (void *), void *arg, zde_win_t *window) { @@ -83,16 +87,17 @@ zde_btn_t *create_button_window (char *name, int type, void *(*entry) (void *), if (!button) return 0; - button->x = window->x + 14 + (window->objectid * 40); - button->y = window->y + 28; + button->x = 0 + (window->objectid * 40); + button->y = 0; window->objectid ++; + + unsigned short name_len = strlen (name); if (type == 0) { unsigned arg_len = strlen ((char *) arg); - unsigned name_len = strlen (name); - - button->arg = malloc (arg_len + name_len + 2); + + button->arg = malloc (arg_len + 1); if (!button->arg) return 0; @@ -100,14 +105,15 @@ zde_btn_t *create_button_window (char *name, int type, void *(*entry) (void *), char *s = button->arg; memcpy (s, arg, arg_len); - memcpy (s+arg_len, "/", 1); - memcpy (s+arg_len+1, name, name_len); - s[arg_len+name_len+1] = '\0'; + //memcpy (s+arg_len, "/", 1); + //memcpy (s+arg_len+1, name, name_len); + s[arg_len] = '\0'; - button->bitmap = bitmap_folder; + button->bitmap = (unsigned short *) image_button; } else button->bitmap = 0; + button->name_len = name_len; button->name = strdup (name); button->entry = entry; button->object = (void *) window; @@ -125,7 +131,7 @@ unsigned destroy_button_window (zde_win_t *window) { unsigned i; - while (1) { + for (;;) { i = 0; zde_btn_t *button; @@ -148,33 +154,40 @@ unsigned destroy_button_window (zde_win_t *window) return 1; } -static void draw_bitmap (unsigned short x, unsigned short y) +static void draw_bitmapspec (zbitmap_t *bitmap) { unsigned i = 0; unsigned j = 0; unsigned k = 0; unsigned pix = 0; - for (i = 0; i < 32*31; i ++) { - if (k >= 32) { + if (!bitmap) + return; + + if (!bitmap->data) + return; + + unsigned short w = bitmap->data[299+34]; + + for (i = bitmap->posx+(bitmap->posy*13); i < 13*25; i ++) { + if (k >= 14) { j ++; k = 0; } - pix = (1024-i)+2; + pix = 355-i; - if (pix > 2100) - continue; + //if (pix < 355) + // continue; - if (bitmap_folder[pix] != (unsigned short) 0) - if (k <= 32 && j <= 32) - xpixel ((unsigned) x+k, (unsigned) y+j, (unsigned) bitmap_folder[pix]); + if (bitmap->data[pix] != w) + if (k < bitmap->sizex && j < bitmap->sizey) + xpixel ((unsigned) bitmap->x+k, (unsigned) bitmap->y+j, image_button[pix]); k ++; } } - int draw_button_window (zde_win_t *window) { zde_btn_t *button; @@ -183,34 +196,67 @@ int draw_button_window (zde_win_t *window) continue; /* we click on left button */ - if (zde_cursor->state == XCURSOR_STATE_LBUTTON) { - if (zde_cursor->x >= button->x && zde_cursor->x <= button->x+32) - if (zde_cursor->y >= button->y && zde_cursor->y <= button->y+32) { + if (zde_cursor->state == XCURSOR_STATE_LBUTTON) + if (!(zde_cursor->flags & CURSOR_FLAG_LBCLICK)) + if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) { + if (window->x+4+button->x <= zde_cursor->x && window->x+button->x+12+((short) button->name_len*6) >= zde_cursor->x && + window->y+button->y+22 <= zde_cursor->y && window->y+button->y+43 >= zde_cursor->y) { zde_cursor->state = 0; + zde_cursor->flags |= CURSOR_FLAG_LBCLICK; pthread_t thread; - pthread_create (&thread, NULL, button->entry, button->arg); } } /* 32x32 bitmap */ - if (button->bitmap) - draw_bitmap (button->x, button->y); - else - xrectfill (button->x, button->y, button->x+32, button->y+32, ~0); + if (button->bitmap) { + unsigned len = button->name_len; + + bitmap_button.data = button->bitmap; + bitmap_button.x = window->x+4+button->x; + bitmap_button.y = window->y+21+button->y; + bitmap_button.posx = 0; + bitmap_button.posy = 0; + bitmap_button.sizex = 4; + bitmap_button.sizey = 23; + + draw_bitmapspec (&bitmap_button); + + unsigned l; + for (l = 0; l < len; l ++) { + bitmap_button.x = window->x+8+button->x+(l*6); + bitmap_button.y = window->y+21+button->y; + bitmap_button.posx = 4; + bitmap_button.posy = 0; + bitmap_button.sizex = 6; + bitmap_button.sizey = 23; + + draw_bitmapspec (&bitmap_button); + } + + bitmap_button.x = window->x+8+button->x+(len*6); + bitmap_button.y = window->y+21+button->y; + bitmap_button.posx = 9; + bitmap_button.posy = 0; + bitmap_button.sizex = 4; + bitmap_button.sizey = 23; + + draw_bitmapspec (&bitmap_button); + } else + xrectfill (button->x+window->x, button->y+window->y, button->x+32+window->x, button->y+32+window->y, ~0); if (button->name) - xtext_puts (button->x-7, button->y+35, 0, button->name); + xtext_puts (button->x+8+window->x, button->y+28+window->y, 0, button->name); } return 0; } -#endif + int init_button () { -// zde_btn_list.next = &zde_btn_list; -// zde_btn_list.prev = &zde_btn_list; + zde_btn_list.next = &zde_btn_list; + zde_btn_list.prev = &zde_btn_list; /* FOLDER bitmap */ /* bitmap_button = (unsigned short *) malloc (1100); diff --git a/apps/zde/button.h b/apps/zde/button.h index b2aa2d9..600aad7 100755 --- a/apps/zde/button.h +++ b/apps/zde/button.h @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +29,7 @@ typedef struct zde_btn_context { unsigned short x; unsigned short y; unsigned short *bitmap; + unsigned short name_len; char *name; void *(*entry) (void *); void *arg; diff --git a/apps/zde/cursor.c b/apps/zde/cursor.c index b421e1f..91191ac 100755 --- a/apps/zde/cursor.c +++ b/apps/zde/cursor.c @@ -91,7 +91,9 @@ int draw_cursor () if (zde_cursor->state != XCURSOR_STATE_LBUTTON) zde_cursor->flags &= ~CURSOR_FLAG_LBCLICK; - + if (zde_cursor->state != XCURSOR_STATE_RBUTTON) + zde_cursor->flags &= ~CURSOR_FLAG_RBCLICK; + return 0; } diff --git a/apps/zde/handler.h b/apps/zde/handler.h index aee02fa..cc47d36 100755 --- a/apps/zde/handler.h +++ b/apps/zde/handler.h @@ -2,6 +2,7 @@ * ZeX/OS * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +22,7 @@ #ifndef _HANDLER_H #define _HANDLER_H +extern void *handler_icon_reader (void *r); extern void *handler_icon_filesystem (void *r); extern void *handler_icon_terminal (void *r); diff --git a/apps/zde/icon.c b/apps/zde/icon.c index 286c617..0e990c4 100755 --- a/apps/zde/icon.c +++ b/apps/zde/icon.c @@ -2,6 +2,7 @@ * ZeX/OS * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +31,10 @@ #include #include "icon.h" +#include "button.h" #include "cursor.h" #include "window.h" +#include "dialog.h" #include "handler.h" unsigned short *bitmap_folder; @@ -58,9 +61,9 @@ zde_icon_t *create_icon (char *name, int type, void *(*entry) (void *), void *ar icon->name_len = strlen (name); icon->name = strdup (name); icon->entry = entry; - icon->object = 0; - + icon->type = (char) type; + /* add into list */ icon->next = &zde_icon_list; icon->prev = zde_icon_list.prev; @@ -93,51 +96,36 @@ zde_icon_t *create_icon_window (char *name, int type, void *(*entry) (void *), v unsigned arg_len; unsigned name_len; - switch (type) { - case 0: - arg_len = strlen ((char *) arg); - name_len = strlen (name); - - icon->arg = malloc (arg_len + name_len + 2); + arg_len = strlen ((char *) arg); + name_len = strlen (name); - if (!icon->arg) - return 0; + icon->arg = malloc (arg_len + name_len + 2); - s = icon->arg; + if (!icon->arg) + return 0; - memcpy (s, arg, arg_len); - memcpy (s+arg_len, "/", 1); - memcpy (s+arg_len+1, name, name_len); - s[arg_len+name_len+1] = '\0'; + s = icon->arg; + memcpy (s, arg, arg_len); + memcpy (s+arg_len, "/", 1); + memcpy (s+arg_len+1, name, name_len); + s[arg_len+name_len+1] = '\0'; + + switch (type) { + case 0: icon->bitmap = bitmap_folder; break; case 1: - arg_len = strlen ((char *) arg); - name_len = strlen (name); - - icon->arg = malloc (arg_len + name_len + 2); - - if (!icon->arg) - return 0; - - s = icon->arg; - - memcpy (s, arg, arg_len); - memcpy (s+arg_len, "/", 1); - memcpy (s+arg_len+1, name, name_len); - s[arg_len+name_len+1] = '\0'; - icon->bitmap = bitmap_file; break; } - icon->name_len = strlen (name); icon->name = strdup (name); icon->entry = entry; icon->object = (void *) window; - + icon->type = (char) type; + /* add into list */ icon->next = &zde_icon_list; icon->prev = zde_icon_list.prev; @@ -151,7 +139,7 @@ unsigned destroy_icon_window (zde_win_t *window) { unsigned i; - while (1) { + for (;;) { i = 0; zde_icon_t *icon; @@ -207,18 +195,51 @@ int draw_icon_desktop () if (icon->object) continue; - /* we click on left button */ - if (zde_cursor->state == XCURSOR_STATE_LBUTTON) { - if (!(zde_cursor->flags & CURSOR_FLAG_LBCLICK)) - if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) - if (zde_cursor->x >= icon->x && zde_cursor->x <= icon->x+32) - if (zde_cursor->y >= icon->y && zde_cursor->y <= icon->y+32) { - zde_cursor->state = 0; - zde_cursor->flags |= CURSOR_FLAG_LBCLICK; - - pthread_t thread; - - pthread_create (&thread, NULL, icon->entry, icon->arg); + /* button event */ + switch (zde_cursor->state) { + case XCURSOR_STATE_LBUTTON: + { + if (!(zde_cursor->flags & CURSOR_FLAG_LBCLICK)) + if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) { + if (zde_cursor->x >= icon->x && zde_cursor->x <= icon->x+32) + if (zde_cursor->y >= icon->y && zde_cursor->y <= icon->y+32) { + zde_cursor->state = 0; + zde_cursor->flags |= CURSOR_FLAG_LBCLICK; + + /* create new thread as entry function */ + pthread_t thread; + pthread_create (&thread, NULL, icon->entry, icon->arg); + } + } + break; + } + case XCURSOR_STATE_RBUTTON: + { + if (!(zde_cursor->flags & CURSOR_FLAG_RBCLICK)) + if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) { + if (zde_cursor->x >= icon->x && zde_cursor->x <= icon->x+32) + if (zde_cursor->y >= icon->y && zde_cursor->y <= icon->y+32) { + zde_cursor->state = 0; + zde_cursor->flags |= CURSOR_FLAG_RBCLICK; + + /* create test window */ + zde_win_t *window = create_window ("Properties", 1); + + if (!window) + return (0); + + window->sizex = 95; + window->sizey = 100; + + if (icon->type == 0) + create_button_window ("Open", 0, handler_icon_filesystem, icon->arg, window); + if (icon->type == 1) + create_button_window ("Read", 0, handler_icon_reader, icon->arg, window); + //create_button_window ("Delete", 0, handler_icon_filesystem, icon->arg, window); + } + } + + break; } } @@ -259,21 +280,55 @@ int draw_icon_window (zde_win_t *window) obj_y += 50; } - /* we click on left button */ - if (zde_cursor->state == XCURSOR_STATE_LBUTTON) { - if (!(zde_cursor->flags & CURSOR_FLAG_LBCLICK)) - if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) - if (zde_cursor->x >= icon->x && zde_cursor->x <= icon->x+32) - if (zde_cursor->y >= icon->y && zde_cursor->y <= icon->y+32) { - if (isactive_window () != window) - continue; - - zde_cursor->state = 0; - zde_cursor->flags |= CURSOR_FLAG_LBCLICK; - - pthread_t thread; - - pthread_create (&thread, NULL, icon->entry, icon->arg); + /* button event */ + switch (zde_cursor->state) { + case XCURSOR_STATE_LBUTTON: + { + if (!(zde_cursor->flags & CURSOR_FLAG_LBCLICK)) + if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) { + if (zde_cursor->x >= icon->x && zde_cursor->x <= icon->x+32) + if (zde_cursor->y >= icon->y && zde_cursor->y <= icon->y+32) { + if (isactive_window () != window) + continue; + + zde_cursor->state = 0; + zde_cursor->flags |= CURSOR_FLAG_LBCLICK; + + pthread_t thread; + + pthread_create (&thread, NULL, icon->entry, icon->arg); + } + } + + break; + } + case XCURSOR_STATE_RBUTTON: + { + if (!(zde_cursor->flags & CURSOR_FLAG_RBCLICK)) + if (!(zde_cursor->flags & CURSOR_FLAG_MOVE)) { + if (zde_cursor->x >= icon->x && zde_cursor->x <= icon->x+32) + if (zde_cursor->y >= icon->y && zde_cursor->y <= icon->y+32) { + zde_cursor->state = 0; + zde_cursor->flags |= CURSOR_FLAG_RBCLICK; + + /* create test window */ + zde_win_t *window = create_window ("Properties", 1); + + if (!window) + return (0); + + window->sizex = 95; + window->sizey = 100; + + if (icon->type == 0) + create_button_window ("Open", 0, handler_icon_filesystem, icon->arg, window); + if (icon->type == 1) + create_button_window ("Read", 0, handler_icon_reader, icon->arg, window); + //create_button_window ("Delete", 0, handler_icon_filesystem, icon->arg, window); + } + } + + break; } } diff --git a/apps/zde/icon.h b/apps/zde/icon.h index 3ec9e10..da5e519 100755 --- a/apps/zde/icon.h +++ b/apps/zde/icon.h @@ -2,6 +2,7 @@ * ZeX/OS * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,6 +45,7 @@ typedef struct zde_icon_context { void *(*entry) (void *); void *arg; void *object; + char type; } zde_icon_t; extern zde_icon_t *create_icon (char *name, int type, void *(*entry) (void *), void *arg); diff --git a/apps/zde/main.c b/apps/zde/main.c index 08307cc..8c7dc67 100755 --- a/apps/zde/main.c +++ b/apps/zde/main.c @@ -2,6 +2,7 @@ * ZeX/OS * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +32,7 @@ #include "window.h" #include "cursor.h" #include "appsrv.h" +#include "button.h" #include "icon.h" #include "kbd.h" #include "bg.h" @@ -99,8 +101,11 @@ int draw_zde () int main (int argc, char **argv) { /* Switch to VGA graphics mode */ - xinit (); - + if (!xinit ()) { + printf ("Something is already using VGA !\n"); + return -1; + } + /* Clean screen */ xcls (0); diff --git a/apps/zde/window.c b/apps/zde/window.c index 25e8a3e..c5c7dbe 100755 --- a/apps/zde/window.c +++ b/apps/zde/window.c @@ -250,6 +250,9 @@ int draw_window () /* let's draw all objects of this window */ draw_dialog_object (window); } + + /* draw window's buttons */ + draw_button_window (window); bitmap_coord->x = 0; bitmap_coord->y = 0; diff --git a/kernel/drivers/char/video/video.c b/kernel/drivers/char/video/video.c index 1b76b66..5a4e231 100644 --- a/kernel/drivers/char/video/video.c +++ b/kernel/drivers/char/video/video.c @@ -25,6 +25,7 @@ #include #include +static unsigned char vgaused = 0; /* some program using graphics mode ? */ unsigned char vgagui = 0; /* 0 - textual; 1 - 8bpp graphics; 2 - 16bpp graphics mode*/ char *vgafb; /* frame buffer */ char *vgadb; /* double buffer */ @@ -263,6 +264,7 @@ unsigned int init_video (void) textmemptr = (unsigned short *) 0xA0000; vgagui = 0; + vgaused = 0; video_cls (); @@ -278,6 +280,11 @@ unsigned int init_video (void) char *init_vgafb () { + //if (vgaused) + // return (char *) ~0; + + vgaused ++; + vgadb = (char *) 0; vgafb = (char *) 0; @@ -346,6 +353,10 @@ char *init_vgafb () void video_gfx_exit () { + /* we dont use VGA anymore */ + if (vgaused) + vgaused = 0; + if (vgagui != 1) { /* for VESA mode */ if (vgagui == 2) @@ -546,7 +557,7 @@ bool video_acthandler (unsigned act, char *block, char *more, int block_len) switch (act) { case DEV_ACT_INIT: { - + vgaused = 0; return 1; } break; diff --git a/kernel/include/net/ndp.h b/kernel/include/net/ndp.h index a8ee574..be59bce 100644 --- a/kernel/include/net/ndp.h +++ b/kernel/include/net/ndp.h @@ -61,20 +61,7 @@ typedef struct proto_icmp_ndp2_t { mac_addr_t ll_mac; } proto_icmp_ndp2_t; -typedef struct proto_ndp_sol_t { - unsigned char type; - unsigned char code; - unsigned short checksum; - unsigned unused; - net_ipv6 target; - - /* ICMPv6 options */ - unsigned char ll_type; - unsigned char ll_length; - mac_addr_t ll_mac; -} proto_ndp_sol_t; - -typedef struct proto_ndp_adv_t { +typedef struct proto_ndp_t { unsigned char type; unsigned char code; unsigned short checksum; @@ -85,7 +72,7 @@ typedef struct proto_ndp_adv_t { unsigned char ll_type; unsigned char ll_length; mac_addr_t ll_mac; -} proto_ndp_adv_t; +} proto_ndp_t; extern unsigned ndp_cache_add (mac_addr_t mac, net_ipv6 ip); extern unsigned ndp_cache_get (net_ipv6 ip, mac_addr_t *mac); diff --git a/libx/base/xinit.c b/libx/base/xinit.c index 243d5c2..2cca9a8 100644 --- a/libx/base/xinit.c +++ b/libx/base/xinit.c @@ -21,7 +21,7 @@ #include -void xinit () +unsigned xinit () { asm volatile ( "movl $34, %%eax;" @@ -29,7 +29,13 @@ void xinit () ::: "%eax"); vgadb = (unsigned short *) *SYSV_GVGAFB; + + /* other app is using VGA */ + if (vgadb == (unsigned short *) ~0) + return 0; vgafb_res_x = 800; vgafb_res_y = 600; + + return 1; } diff --git a/libx/libx/base.h b/libx/libx/base.h index 042384a..6d628fb 100644 --- a/libx/libx/base.h +++ b/libx/libx/base.h @@ -1,6 +1,7 @@ /* * ZeX/OS * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) + * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +31,7 @@ unsigned vgafb_res_y; /* externs */ extern void xcls (unsigned color); -extern void xinit (); +extern unsigned xinit (); extern void xpixel (unsigned x, unsigned y, unsigned color); extern unsigned xpixelget (unsigned x, unsigned y); extern void xfbswap (); -- 2.11.4.GIT