mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-04 20:58:11 +03:00
Remove xcore graphics backend
This removes X11 specific code, making SDL2 a hard dependency. X-based environments are continue to be supported via SDL2. This also removes joystick_linux.c which was only used if SDL2 was not available.
This commit is contained in:
@@ -15,7 +15,7 @@ jobs:
|
||||
- name: Install Deps
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
|
||||
sudo apt install libgtk2.0-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
@@ -27,26 +27,3 @@ jobs:
|
||||
- name: Test
|
||||
run: ctest --output-on-failure
|
||||
working-directory: out/${{ matrix.build-type }}
|
||||
|
||||
build-x11:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: Linux X11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install Deps
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libgtk2.0-dev
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir -p out
|
||||
cd out
|
||||
cmake ../
|
||||
make
|
||||
|
||||
- name: Test
|
||||
run: ctest --output-on-failure
|
||||
working-directory: out
|
||||
|
||||
+4
-41
@@ -36,7 +36,6 @@ check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
|
||||
check_symbol_exists(uname "sys/utsname.h" HAVE_UNAME)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
set(SDL2_FOUND 1)
|
||||
set(FREETYPE_FOUND 1)
|
||||
set(HAVE_JPEG 1)
|
||||
set(DEFAULT_FONT_PATH /fonts/)
|
||||
@@ -44,7 +43,6 @@ elseif (ANDROID)
|
||||
if (NOT DEFINED ENABLE_MODULES)
|
||||
set(ENABLE_MODULES 1)
|
||||
endif()
|
||||
set(SDL2_FOUND 1)
|
||||
set(SDL2MIXER_FOUND 1)
|
||||
set(SDL2TTF_FOUND 1)
|
||||
find_library(ndk_zlib z)
|
||||
@@ -59,11 +57,6 @@ else()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
optional_find_package(X11)
|
||||
if (X11_xf86vmode_FOUND)
|
||||
set(HAVE_XF86VMODE 1)
|
||||
endif()
|
||||
|
||||
optional_find_package(GTK2 COMPONENTS gtk)
|
||||
if (GTK2_FOUND)
|
||||
set(ENABLE_GTK 1)
|
||||
@@ -72,7 +65,7 @@ else()
|
||||
optional_find_package(Freetype)
|
||||
|
||||
include(FindPkgConfig)
|
||||
optional_pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
|
||||
pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
|
||||
optional_pkg_check_modules(SDL2MIXER IMPORTED_TARGET SDL2_mixer)
|
||||
optional_pkg_check_modules(SDL2TTF IMPORTED_TARGET SDL2_ttf)
|
||||
|
||||
@@ -85,19 +78,6 @@ else()
|
||||
endif()
|
||||
|
||||
|
||||
# Graphics
|
||||
|
||||
if (X11_FOUND)
|
||||
set(SRC_GRAPHDEV xcore_draw.c xcore_video.c xcore_mode.c xcore_event.c xcore_cursor.c xcore_maskupdate.c image.c xcore_image.c)
|
||||
set(SUMMARY_GRAPHDEV "X11")
|
||||
elseif (SDL2_FOUND)
|
||||
set(SRC_GRAPHDEV sdl_video.c sdl_draw.c sdl_event.c sdl_image.c sdl_cursor.c image.c)
|
||||
set(SUMMARY_GRAPHDEV "SDL2")
|
||||
set(ENABLE_SDL 1)
|
||||
else()
|
||||
message(FATAL_ERROR "*** No graphic device available ***")
|
||||
endif()
|
||||
|
||||
# Menu
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
@@ -116,10 +96,8 @@ elseif (GTK2_FOUND)
|
||||
include_directories(${Intl_INCLUDE_DIRS})
|
||||
link_libraries(${Intl_LIBRARIES})
|
||||
endif()
|
||||
elseif (ENABLE_SDL)
|
||||
set(SRC_MENU menu_sdl.c sdl_input.c)
|
||||
else ()
|
||||
set(SRC_MENU menu_null.c)
|
||||
set(SRC_MENU menu_sdl.c sdl_input.c)
|
||||
endif()
|
||||
|
||||
# PCM audio
|
||||
@@ -204,34 +182,20 @@ endif()
|
||||
|
||||
if (EMSCRIPTEN OR ANDROID)
|
||||
set(SRC_JOYSTICK joystick_dmy.c)
|
||||
elseif (ENABLE_SDL)
|
||||
else()
|
||||
set(SRC_JOYSTICK joystick_sdl.c)
|
||||
set(SUMMARY_JOYSTICK "SDL")
|
||||
set(HAVE_SDLJOY 1)
|
||||
else()
|
||||
check_include_file(linux/joystick.h HAVE_LINUX_JOYSTICK_H)
|
||||
if (HAVE_LINUX_JOYSTICK_H)
|
||||
set(SRC_JOYSTICK joystick_linux.c)
|
||||
set(SUMMARY_JOYSTICK "Linux ioctl")
|
||||
set(JOY_DEVICE "/dev/js0" CACHE STRING "joystick device")
|
||||
else ()
|
||||
set(SRC_JOYSTICK joystick_dmy.c)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Font
|
||||
|
||||
if (X11_FOUND)
|
||||
list(APPEND SRC_FONT font_x11.c)
|
||||
list(APPEND SUMMARY_FONT "x11")
|
||||
set(ENABLE_X11FONT 1)
|
||||
endif()
|
||||
if (FREETYPE_FOUND)
|
||||
list(APPEND SRC_FONT font_freetype2.c)
|
||||
list(APPEND SUMMARY_FONT "freetype2")
|
||||
set(ENABLE_FT2 1)
|
||||
endif()
|
||||
if (NOT X11_FOUND AND SDL2TTF_FOUND)
|
||||
if (SDL2TTF_FOUND)
|
||||
list(APPEND SRC_FONT font_sdlttf.c)
|
||||
list(APPEND SUMMARY_FONT "SDL_ttf")
|
||||
set(ENABLE_SDLTTF 1)
|
||||
@@ -253,7 +217,6 @@ endfunction()
|
||||
|
||||
message("xsystem35 summary:")
|
||||
message("------------------")
|
||||
print_summary(graphics ${SUMMARY_GRAPHDEV})
|
||||
print_summary(audio ${SUMMARY_AUDIO})
|
||||
print_summary(cdrom ${SUMMARY_CDROM})
|
||||
print_summary(midi ${SUMMARY_MIDI})
|
||||
|
||||
@@ -8,14 +8,12 @@ Prebuilt binaries for Windows and Android can be downloaded from the [Releases](
|
||||
## Build
|
||||
### Linux (Debian / Ubuntu)
|
||||
|
||||
$ sudo apt install build-essential cmake libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
|
||||
$ sudo apt install build-essential cmake libgtk2.0-dev libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev
|
||||
$ mkdir -p out/debug
|
||||
$ cd out/debug
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Debug ../../
|
||||
$ make && make install
|
||||
|
||||
You can choose between X11 and SDL2 as the graphics backend. If both libraries are found, X11 is used by default, but if `-DENABLE_X11=NO` flag is given to the `cmake` invocation, then SDL2 will be used.
|
||||
|
||||
### MacOS
|
||||
|
||||
[Homebrew](https://brew.sh/index_ja) is needed.
|
||||
|
||||
@@ -20,10 +20,8 @@
|
||||
#cmakedefine ENABLE_MIDI_SEQMIDI @ENABLE_MIDI_SEQMIDI@
|
||||
#cmakedefine ENABLE_MODULES @ENABLE_MODULES@
|
||||
#cmakedefine ENABLE_NLS @ENABLE_NLS@
|
||||
#cmakedefine ENABLE_SDL @ENABLE_SDL@
|
||||
#cmakedefine ENABLE_SDLMIXER @ENABLE_SDLMIXER@
|
||||
#cmakedefine ENABLE_SDLTTF @ENABLE_SDLTTF@
|
||||
#cmakedefine ENABLE_X11FONT @ENABLE_X11FONT@
|
||||
|
||||
#cmakedefine CDROM_DEVICE "@CDROM_DEVICE@"
|
||||
#cmakedefine JOY_DEVICE "@JOY_DEVICE@"
|
||||
@@ -38,7 +36,6 @@
|
||||
#cmakedefine HAVE_SDLJOY @HAVE_SDLJOY@
|
||||
#cmakedefine HAVE_SIGACTION @HAVE_SIGACTION@
|
||||
#cmakedefine HAVE_UNAME @HAVE_UNAME@
|
||||
#cmakedefine HAVE_XF86VMODE @HAVE_XF86VMODE@
|
||||
|
||||
#define DEFAULT_GOTHIC_TTF "@DEFAULT_FONT_PATH@MTLc3m.ttf"
|
||||
#define DEFAULT_MINCHO_TTF "@DEFAULT_FONT_PATH@mincho.otf"
|
||||
|
||||
+7
-12
@@ -24,7 +24,6 @@ target_sources(xsystem35 PRIVATE
|
||||
${SRC_AUDIO}
|
||||
${SRC_CDROM}
|
||||
${SRC_MIDI}
|
||||
${SRC_GRAPHDEV}
|
||||
${SRC_FONT}
|
||||
${SRC_MENU}
|
||||
${SRC_JOYSTICK})
|
||||
@@ -35,6 +34,11 @@ target_sources(xsystem35 PRIVATE
|
||||
cmdk.c cmdl.c cmdm.c cmdn.c cmdo.c cmdp.c cmdq.c cmds.c cmdt.c
|
||||
cmdu.c cmdv.c cmdw.c cmdy.c cmdz.c cmd2F.c cmd2F60.c)
|
||||
|
||||
# Graphics
|
||||
|
||||
target_sources(xsystem35 PRIVATE
|
||||
sdl_video.c sdl_draw.c sdl_event.c sdl_image.c sdl_cursor.c image.c)
|
||||
|
||||
# CG
|
||||
target_sources(xsystem35 PRIVATE
|
||||
pms.c vsp.c bmp.c qnt.c)
|
||||
@@ -99,22 +103,13 @@ elseif (ANDROID)
|
||||
|
||||
else() # non-emscripten, non-android
|
||||
target_link_libraries(xsystem35 PRIVATE m ZLIB::ZLIB)
|
||||
if (X11_FOUND)
|
||||
target_include_directories(xsystem35 PRIVATE ${X11_INCLUDE_DIR})
|
||||
target_link_libraries(xsystem35 PRIVATE ${X11_LIBRARIES})
|
||||
if (X11_xf86vmode_FOUND)
|
||||
target_link_libraries(xsystem35 PRIVATE ${X11_Xxf86vm_LIB})
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2)
|
||||
if (GTK2_FOUND)
|
||||
target_link_libraries(xsystem35 PRIVATE GTK2::gtk)
|
||||
endif()
|
||||
if (FREETYPE_FOUND)
|
||||
target_link_libraries(xsystem35 PRIVATE Freetype::Freetype)
|
||||
endif()
|
||||
if (ENABLE_SDL)
|
||||
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2)
|
||||
endif()
|
||||
if (SDL2MIXER_FOUND)
|
||||
target_link_libraries(xsystem35 PRIVATE PkgConfig::SDL2MIXER)
|
||||
endif()
|
||||
@@ -136,7 +131,7 @@ else() # non-emscripten, non-android
|
||||
endif()
|
||||
|
||||
# FIXME: set up dependency for xsystem35 on this
|
||||
if (ENABLE_SDL AND NOT EMSCRIPTEN AND NOT ANDROID)
|
||||
if (NOT EMSCRIPTEN AND NOT ANDROID)
|
||||
add_custom_target(sdl_keytable.h
|
||||
COMMAND perl ../tools/xsyskey.pl ${SDL2_INCLUDE_DIRS} > sdl_keytable.h
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -219,7 +219,6 @@ extern void ags_fader_callback();
|
||||
|
||||
/* フォント関連 */
|
||||
typedef enum {
|
||||
FONT_X11,
|
||||
FONT_FT2,
|
||||
FONT_SDLTTF
|
||||
} fontdev_t;
|
||||
|
||||
@@ -34,11 +34,6 @@
|
||||
|
||||
void font_init(int dev) {
|
||||
switch(dev) {
|
||||
#ifdef ENABLE_X11FONT
|
||||
case FONT_X11:
|
||||
nact->ags.font = font_x11_new();
|
||||
break;
|
||||
#endif
|
||||
#ifdef ENABLE_FT2
|
||||
case FONT_FT2:
|
||||
nact->ags.font = font_ft2_new();
|
||||
@@ -50,9 +45,6 @@ void font_init(int dev) {
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
#ifndef ENABLE_SDL
|
||||
nact->ags.font = font_x11_new();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,13 +60,6 @@ extern FONT *font_ft2_new();
|
||||
extern FONT *font_sdlttf_new();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_X11FONT
|
||||
extern FONT *font_x11_new();
|
||||
#endif
|
||||
|
||||
/* デフォルトのフォント名 */
|
||||
#define FONT_DEFAULTNAME_X "-*-*-medium-r-normal--%d-*-*-*-c-*-jisx0208.1983-0,-*-*-medium-r-normal--%d-*-*-*-c-*-jisx0201.1976-0,*"
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
int load_mincho_font(void);
|
||||
#endif
|
||||
|
||||
-228
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* font_x11.c access to x11 font device
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: font_x11.c,v 1.11 2003/01/31 12:58:28 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "font.h"
|
||||
#include "ags.h"
|
||||
#include "xcore.h"
|
||||
#include "xcore_private.h"
|
||||
#include "antialiase.h"
|
||||
|
||||
/* fontset の為の情報 */
|
||||
typedef struct {
|
||||
int size;
|
||||
int type;
|
||||
XFontSet id;
|
||||
} FontTable;
|
||||
|
||||
#define FONTTABLEMAX 256
|
||||
static FontTable fonttbl[FONTTABLEMAX];
|
||||
static int fontcnt = 0;
|
||||
static XFontSet fontset;
|
||||
static int font_ascent, font_descent;
|
||||
|
||||
/* Font Glyph を取得するためのPixmapとGC */
|
||||
static Pixmap pix_glyph;
|
||||
static GC gc_pix_glyph;
|
||||
static agsurface_t img_glyph;
|
||||
|
||||
static FONT *this;
|
||||
|
||||
#define GLYPH_PIXMAP_WIDTH 800 /* 文字イメージを取得する為のPixmapの大きさ */
|
||||
#define GLYPH_PIXMAP_HEIGHT 150
|
||||
|
||||
static void font_insert(int size, int type, XFontSet fontset) {
|
||||
fonttbl[fontcnt].size = size;
|
||||
fonttbl[fontcnt].type = type;
|
||||
fonttbl[fontcnt].id = fontset;
|
||||
|
||||
if (fontcnt >= (FONTTABLEMAX -1)) {
|
||||
WARNING("Font table is full.\n");
|
||||
} else {
|
||||
fontcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
static FontTable *font_lookup(int size, int type) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < fontcnt; i++) {
|
||||
if (fonttbl[i].size == size && fonttbl[i].type == type) {
|
||||
return &fonttbl[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void font_x11_sel_font(int type, int size) {
|
||||
XFontStruct **font_structs;
|
||||
char **font_names;
|
||||
int i, num_fonts;
|
||||
FontTable *tbl;
|
||||
|
||||
if (NULL == (tbl = font_lookup(size, type))) {
|
||||
char name[256];
|
||||
char **miss, *def;
|
||||
int n_miss;
|
||||
XFontSet fs;
|
||||
|
||||
if (type > 3) type = FONT_GOTHIC;
|
||||
|
||||
/* set size */
|
||||
snprintf(name, sizeof(name), this->name[type], size, size);
|
||||
|
||||
fs = XCreateFontSet(x11_display, name, &miss, &n_miss, &def);
|
||||
if (n_miss > 0) {
|
||||
for (i = 0; i < n_miss; i++) {
|
||||
WARNING("can't load font %s\n", miss[i]);
|
||||
}
|
||||
XFreeStringList(miss);
|
||||
SYSERROR("Font Load failed\n");
|
||||
}
|
||||
font_insert(size, type, fs);
|
||||
fontset = fs;
|
||||
} else {
|
||||
fontset = tbl->id;
|
||||
}
|
||||
|
||||
/* 最大のフォントの高さの取得 */
|
||||
num_fonts = XFontsOfFontSet(fontset, &font_structs, &font_names);
|
||||
font_ascent = font_descent = 0;
|
||||
for (i = 0; i < num_fonts; i++) {
|
||||
font_ascent = max(font_ascent, font_structs[i]->ascent);
|
||||
font_descent = max(font_descent, font_structs[i]->descent);
|
||||
}
|
||||
}
|
||||
|
||||
static agsurface_t *get_drawn_glyph(const char *str, int w) {
|
||||
XImage *src;
|
||||
agsurface_t *dst;
|
||||
|
||||
XSetForeground(x11_display, gc_pix_glyph, 0);
|
||||
XFillRectangle(x11_display, pix_glyph, gc_pix_glyph, 0, 0, GLYPH_PIXMAP_WIDTH, GLYPH_PIXMAP_HEIGHT);
|
||||
|
||||
XSetForeground(x11_display, gc_pix_glyph, 1);
|
||||
XmbDrawString(x11_display, pix_glyph, fontset, gc_pix_glyph, 0, font_ascent, str, strlen(str));
|
||||
|
||||
src = XGetImage(x11_display, pix_glyph, 0, 0, w, font_ascent + font_descent, AllPlanes, ZPixmap);
|
||||
|
||||
dst = malloc(sizeof(agsurface_t));
|
||||
|
||||
dst->width = w;
|
||||
dst->height = font_ascent + font_descent;
|
||||
dst->bytes_per_line = src->bytes_per_line;
|
||||
dst->pixel = (BYTE *)src->data;
|
||||
dst->bytes_per_pixel = x11_workinfo->cimg.bytes_per_pixel;
|
||||
|
||||
src->data = NULL;
|
||||
XDestroyImage(src);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
static agsurface_t *font_x11_get_glyph(const char *str_utf8) {
|
||||
int w = XmbTextEscapement(fontset, str_utf8, strlen(str_utf8));
|
||||
|
||||
if (w == 0)
|
||||
return NULL;
|
||||
|
||||
agsurface_t *dst = get_drawn_glyph(str_utf8, w);
|
||||
image_get_glyph(dst, &img_glyph);
|
||||
|
||||
if (this->antialiase_on) {
|
||||
aa_make(img_glyph.pixel, w, dst->height, img_glyph.bytes_per_line);
|
||||
}
|
||||
|
||||
img_glyph.width = dst->width;
|
||||
img_glyph.height = dst->height;
|
||||
|
||||
free(dst->pixel);
|
||||
free(dst);
|
||||
return &img_glyph;
|
||||
}
|
||||
|
||||
static int font_x11_draw_glyph(int x, int y, const char *str_utf8, int col) {
|
||||
int w = XmbTextEscapement(fontset, str_utf8, strlen(str_utf8));
|
||||
if (w == 0)
|
||||
return 0;
|
||||
|
||||
if (!x11_dibinfo->shared) {
|
||||
/* 一度 Pixmap に書いてからイメージを取得してDIBへ */
|
||||
agsurface_t *dst = get_drawn_glyph(str_utf8, w);
|
||||
|
||||
if (DIB_DEPTH == dib_depth_candidate) {
|
||||
image_getGlyphImage(DIB, dst, x, y, PAL2PIC(col));
|
||||
} else {
|
||||
image_getGlyphImageNto8(DIB, dst, x, y, col);
|
||||
}
|
||||
free(dst);
|
||||
} else {
|
||||
Xcore_setForeground(col);
|
||||
XmbDrawString(x11_display, x11_pixmap, fontset, x11_gc_pix, x, y + font_ascent, str_utf8, strlen(str_utf8));
|
||||
x11_needSync = TRUE;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
static boolean drawable() {
|
||||
return !this->antialiase_on;
|
||||
}
|
||||
|
||||
|
||||
FONT *font_x11_new() {
|
||||
FONT *f = malloc(sizeof(FONT));
|
||||
|
||||
f->sel_font = font_x11_sel_font;
|
||||
f->get_glyph = font_x11_get_glyph;
|
||||
f->draw_glyph = font_x11_draw_glyph;
|
||||
f->self_drawable = drawable;
|
||||
f->antialiase_on = FALSE;
|
||||
|
||||
/* Glyph取得のためのPixmapとGCとagsurface_tを用意 */
|
||||
pix_glyph = XCreatePixmap(x11_display, x11_window,
|
||||
GLYPH_PIXMAP_WIDTH, GLYPH_PIXMAP_HEIGHT, WIN_DEPTH);
|
||||
gc_pix_glyph = XCreateGC(x11_display, pix_glyph, 0, 0);
|
||||
|
||||
img_glyph.width = GLYPH_PIXMAP_WIDTH;
|
||||
img_glyph.height = GLYPH_PIXMAP_HEIGHT;
|
||||
img_glyph.bytes_per_line = GLYPH_PIXMAP_WIDTH;
|
||||
img_glyph.depth = 8;
|
||||
img_glyph.bytes_per_pixel = 1;
|
||||
img_glyph.pixel = malloc(GLYPH_PIXMAP_WIDTH * GLYPH_PIXMAP_HEIGHT);
|
||||
|
||||
this = f;
|
||||
|
||||
NOTICE("FontDevice X11\n");
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -26,10 +26,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ENABLE_SDL
|
||||
#include "sdl_core.h"
|
||||
#else
|
||||
#include "xcore.h"
|
||||
#endif
|
||||
|
||||
#endif /* !__GRAPHICDEVICE__ */
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* joystick_linux.c joystick interface for linux (kernel 2.2.x)
|
||||
*
|
||||
* Copyright (C) 1999- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: joystick_linux.c,v 1.8 2000/11/25 13:09:08 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/joystick.h>
|
||||
#include "joystick.h"
|
||||
#include "portab.h"
|
||||
|
||||
#ifndef JOY_DEVICE
|
||||
#define JOY_DEVICE "/dev/js0"
|
||||
#endif
|
||||
|
||||
static char *dev_joy = JOY_DEVICE;
|
||||
static int joy_fd=-1,joy_dat=0,joy_sens=19660;
|
||||
static unsigned char joy_axes,joy_buttons;
|
||||
static boolean joy_enable=TRUE;
|
||||
static struct js_event js;
|
||||
|
||||
void joy_set_devicename(char *name) {
|
||||
if (0 == strcmp("none", name)) dev_joy = NULL;
|
||||
else dev_joy = strdup(name);
|
||||
}
|
||||
|
||||
int joy_open(void) {
|
||||
if( dev_joy == NULL ) return -1;
|
||||
joy_fd=open(dev_joy,O_RDONLY);
|
||||
if( joy_fd < 0 ) {
|
||||
joy_enable=FALSE;
|
||||
return joy_fd;
|
||||
}
|
||||
ioctl(joy_fd,JSIOCGAXES,&joy_axes);
|
||||
ioctl(joy_fd,JSIOCGBUTTONS,&joy_buttons);
|
||||
printf("open %s axes %d buttons %d\n",dev_joy,joy_axes,joy_buttons);
|
||||
|
||||
return joy_fd;
|
||||
}
|
||||
|
||||
void joy_close(void) {
|
||||
if( joy_fd < 0 ) return;
|
||||
close(joy_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
int joy_getinfo(void) {
|
||||
int err;
|
||||
struct timeval tv;
|
||||
fd_set set;
|
||||
int max_fd;
|
||||
|
||||
return 0;
|
||||
if( joy_fd < 0 || !joy_enable ) return 0;
|
||||
max_fd = joy_fd+1;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 1000;
|
||||
FD_ZERO(&set);
|
||||
FD_SET(joy_fd,&set);
|
||||
while( select(max_fd,&set,NULL,NULL,&tv) ) {
|
||||
if( FD_ISSET(joy_fd,&set) ) {
|
||||
err=read(joy_fd,&js,sizeof(js));
|
||||
if( err != sizeof(js) ) return joy_dat;
|
||||
switch(js.type & ~JS_EVENT_INIT) {
|
||||
case JS_EVENT_BUTTON:
|
||||
if( js.number < 4 ) {
|
||||
joy_dat &= ~(1<<(js.number+4));
|
||||
joy_dat |= js.value<<(js.number+4);
|
||||
}
|
||||
break;
|
||||
case JS_EVENT_AXIS:
|
||||
if( js.number == 0 ) {
|
||||
joy_dat &= ~(0x0c);
|
||||
if( js.value > joy_sens ) joy_dat |= 8;
|
||||
if( js.value < -joy_sens ) joy_dat |= 4;
|
||||
} else if( js.number == 1 ) {
|
||||
joy_dat &= ~(0x03);
|
||||
if( js.value > joy_sens ) joy_dat |= 2;
|
||||
if( js.value < -joy_sens ) joy_dat |= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return joy_dat;
|
||||
}
|
||||
|
||||
#if 0
|
||||
boolean joy_getinfo(int *data) {
|
||||
int err;
|
||||
|
||||
if( joy_fd < 0 || !joy_enable ) return FALSE;
|
||||
|
||||
err = read(joy_fd, &js, sizeof(js));
|
||||
if( err != sizeof(js) ) {
|
||||
*data = joy_dat;
|
||||
return TRUE;
|
||||
}
|
||||
switch(js.type & ~JS_EVENT_INIT) {
|
||||
case JS_EVENT_BUTTON:
|
||||
if( js.number < 4 ) {
|
||||
joy_dat &= ~(1<<(js.number+4));
|
||||
joy_dat |= js.value<<(js.number+4);
|
||||
}
|
||||
break;
|
||||
case JS_EVENT_AXIS:
|
||||
if( js.number == 0 ) {
|
||||
joy_dat &= ~(0x0c);
|
||||
if( js.value > joy_sens ) joy_dat |= 8;
|
||||
if( js.value < -joy_sens ) joy_dat |= 4;
|
||||
} else if( js.number == 1 ) {
|
||||
joy_dat &= ~(0x03);
|
||||
if( js.value > joy_sens ) joy_dat |= 2;
|
||||
if( js.value < -joy_sens ) joy_dat |= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
*data = joy_dat;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* menu_null.c popup menu for null
|
||||
*
|
||||
* Copyright (C) 2000- Masaki Chikama (Wren) <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: menu_null.c,v 1.2 2003/01/25 01:34:50 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "nact.h"
|
||||
#include "menu.h"
|
||||
|
||||
void menu_open(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void menu_quitmenu_open(void) {
|
||||
nact->is_quit = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean menu_inputstring(INPUTSTRING_PARAM *p) {
|
||||
p->newstring = p->oldstring;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean menu_inputstring2(INPUTSTRING_PARAM *p) {
|
||||
p->newstring = p->oldstring;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean menu_inputnumber(INPUTNUM_PARAM *p) {
|
||||
p->value = p->def;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void menu_msgbox_open(char *msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
void menu_init(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
void menu_gtkmainiteration() {
|
||||
return;
|
||||
}
|
||||
@@ -173,7 +173,6 @@ extern boolean sdl_inputString(struct inputstring_param *);
|
||||
|
||||
/* misc */
|
||||
#define ResourceInit(c,v) sdl_ResourceInit((c),(v))
|
||||
#define SetNoShmMode() /* NO */
|
||||
#define Sleep(ms) sdl_sleep(ms)
|
||||
#define WaitVsync() sdl_wait_vsync()
|
||||
|
||||
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* xcore.h Xlibとの通信
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore.h,v 1.42 2003/04/22 16:34:28 chikama Exp $ */
|
||||
|
||||
#ifndef __XCORE_H__
|
||||
#define __XCORE_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <sys/types.h>
|
||||
#include "portab.h"
|
||||
#include "image.h"
|
||||
#include "xcore_image.h"
|
||||
#include "cursor.h"
|
||||
#include "ags.h"
|
||||
|
||||
/* 初期化関係 */
|
||||
extern int Xcore_Initilize(void);
|
||||
extern void Xcore_Remove(void);
|
||||
|
||||
/* ウィンド関係 */
|
||||
extern void Xcore_setWorldSize(int width, int height, int depth);
|
||||
extern void Xcore_setWindowSize(int x, int y, int width, int height);
|
||||
extern void Xcore_setWindowTitle(char *name);
|
||||
extern void Xcore_getWindowInfo(DispInfo *info);
|
||||
extern void Xcore_fullScreen(boolean on);
|
||||
extern agsurface_t *Xcore_getDIB();
|
||||
|
||||
/* 画面更新 */
|
||||
extern void Xcore_updateArea(MyRectangle *src, MyPoint *dst);
|
||||
extern void Xcore_sync();
|
||||
|
||||
/* パレット関係 */
|
||||
extern void Xcore_setPalette(Palette256 *pal, int src, int cnt);
|
||||
extern void Xcore_setForeground(unsigned long col);
|
||||
|
||||
/* 描画関係 */
|
||||
extern void Xcore_drawRectangle(int x, int y, int w, int h, unsigned long col);
|
||||
extern void Xcore_fillRectangle(int x, int y, int w, int h, unsigned long col);
|
||||
extern void Xcore_drawLine(int x0, int y0, int x1, int y1, unsigned long col);
|
||||
extern int Xcore_drawString(int x, int y, const char *str_utf8, unsigned long col);
|
||||
extern void Xcore_copyArea(int sx, int sy, int w, int h, int dx, int dy);
|
||||
// extern void Xcore_drawTT(int x, int y, int w, int h, const char *bitmap, int ww, boolean antialiased);
|
||||
extern int Xcore_eCopyArea(int sx, int sy, int w, int h, int dx, int dy, int t,int opt, boolean flg, int spCol);
|
||||
extern void Xcore_zoom(int x, int y, int w, int h);
|
||||
extern void Xcore_restoreRegion(void *img, int x, int y);
|
||||
extern void Xcore_delRegion(void *img);
|
||||
extern void Xcore_putRegion(void *img, int x, int y);
|
||||
extern void *Xcore_saveRegion(int x, int y, int w, int h);
|
||||
extern void Xcore_copyRegion(void *i, int sx, int sy, int w, int h, int dx, int dy);
|
||||
extern void Xcore_maskupdate(int sx, int sy, int w, int h, int dx, int dy, int func, int step);
|
||||
|
||||
/* フォント関連 */
|
||||
// extern FONT *Xcore_getFontDevice(void);
|
||||
extern void Xcore_setFontDevice(struct _FONT *f);
|
||||
|
||||
/* fader */
|
||||
extern void Xcore_fadeIn(int step);
|
||||
extern void Xcore_fadeOut(int step);
|
||||
extern void Xcore_whiteIn(int step);
|
||||
extern void Xcore_whiteOut(int step);
|
||||
|
||||
/* key/pointer 関係 */
|
||||
extern int Xcore_getMouseInfo(MyPoint *p);
|
||||
extern int Xcore_getKeyInfo();
|
||||
extern void Xcore_setCursorLocation(int x, int y);
|
||||
extern boolean Xcore_cursorNew(BYTE* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry);
|
||||
extern void Xcore_setCursorType(int type);
|
||||
extern int Xcore_keywait(int ms, boolean cancel);
|
||||
extern void Xcore_setAutoRepeat(boolean bool);
|
||||
|
||||
/* misc */
|
||||
// extern void Xcore_mainloop(int (*idle_func)(void));
|
||||
extern void Xcore_eventCallnack();
|
||||
extern void Xcore_setNoShmMode();
|
||||
extern void Xcore_mainIterarion();
|
||||
extern boolean RawKeyInfo[256];
|
||||
|
||||
/* 初期化関係 */
|
||||
#define GraphicsInitilize() Xcore_Initilize()
|
||||
#define GraphicsRemove() Xcore_Remove()
|
||||
|
||||
/* ウィンド関係 */
|
||||
#define GetWindowInfo(info) Xcore_getWindowInfo(info)
|
||||
#define SetWorldSize(w,h,d) Xcore_setWorldSize((w),(h),(d))
|
||||
#define SetWindowSize(x,y,w,h) Xcore_setWindowSize((x),(y),(w),(h))
|
||||
#define SetWindowTitle(size) Xcore_setWindowTitle((size))
|
||||
#define GetDIB() Xcore_getDIB()
|
||||
|
||||
/* 画面更新 */
|
||||
#define DspDeviceSync() Xcore_sync()
|
||||
#define UpdateArea(src,dst) Xcore_updateArea((src),(dst))
|
||||
#define FullScreen(on) Xcore_fullScreen(on)
|
||||
|
||||
/* パレット関係 */
|
||||
#define SetPalette(pal,src,cnt) Xcore_setPalette((pal),(src),(cnt))
|
||||
#define SetForeground(col) Xcore_setForeground((col))
|
||||
|
||||
/* 描画関係 */
|
||||
#define DrawString(x,y,str_utf8,col) Xcore_drawString((x),(y),(str_utf8),(col))
|
||||
#define FillRectangle(x,y,w,h,col) Xcore_fillRectangle((x),(y),(w),(h),(col))
|
||||
#define CopyArea(sx,sy,w,h,dx,dy) Xcore_copyArea((sx),(sy),(w),(h),(dx),(dy))
|
||||
#define CopyAreaSP(sx,sy,w,h,dx,dy,col) image_copyAreaSP(nact->ags.dib, (sx),(sy),(w),(h),(dx),(dy),(col))
|
||||
#define DrawLine(x0,y0,x1,y1,col) Xcore_drawLine((x0),(y0),(x1),(y1),(col))
|
||||
#define DrawTT(x,y,w,h,bm,ww,anti) Xcore_drawTT((x),(y),(w),(h),(bm),(ww),(anti))
|
||||
#define ScaledCopyArea(sx,sy,sw,sh,dx,dy,dw,dh,mirror_sw) image_scaledCopyArea(NULL,nact->ags.dib,sx,sy,sw,sh,dx,dy,dw,dh,mirror_sw)
|
||||
#define Zoom(x,y,w,h) Xcore_zoom(x,y,w,h)
|
||||
#define WrapColor(x,y,w,h,p1,p2) image_wrapColor(nact->ags.dib,x,y,w,h,p1,p2)
|
||||
#define GetPixel(x,y,cell) image_getPixel(nact->ags.dib,x,y,cell)
|
||||
#define DrawImage8_fromData(info,x,y,w,h) image_drawImage8_fromData(nact->ags.dib, info,x,y,w,h)
|
||||
#define DrawImage16_fromData(info,x,y,w,h) image_drawImage16_fromData(nact->ags.dib, info,x,y,w,h)
|
||||
#define CopyAreaSP16_shadow(sx,sy,w,h,dx,dy) image_copyAreaSP16_shadow(nact->ags.dib,sx,sy,w,h,dx,dy,255)
|
||||
#define CopyAreaSP16_shadow_withRate(sx,sy,w,h,dx,dy,lv) image_copyAreaSP16_shadow(nact->ags.dib,sx,sy,w,h,dx,dy,lv)
|
||||
#define CopyAreaSP16_alphaLevel(sx,sy,w,h,dx,dy,lv) image_copyAreaSP16_alphaLevel(nact->ags.dib,sx,sy,w,h,dx,dy,lv)
|
||||
#define CopyAreaSP16_alphaBlend(sx,sy,w,h,dx,dy,lv) image_copyAreaSP16_alphaBlend(nact->ags.dib,sx,sy,w,h,dx,dy,lv)
|
||||
#define CopyAreaSP16_whiteLevel(sx,sy,w,h,dx,dy,lv) image_copyAreaSP16_whiteLevel(nact->ags.dib,sx,sy,w,h,dx,dy,lv)
|
||||
#define Copy_from_alpha(sx,sy,w,h,dx,dy,flg) image_copy_from_alpha(nact->ags.dib,sx,sy,w,h,dx,dy,flg)
|
||||
#define Copy_to_alpha(sx,sy,w,h,dx,dy,flg) image_copy_to_alpha(nact->ags.dib,sx,sy,w,h,dx,dy,flg)
|
||||
#define ChangeColorArea(x,y,w,h,s,d,c) Xcore_changeColorArea(x,y,w,h,s,d,c)
|
||||
#define DrawRectangle(x,y,w,h,col) Xcore_drawRectangle((x),(y),(w),(h),(col))
|
||||
#define Mosaic(sx,sy,w,h,dx,dy,sl) image_Mosaic(nact->ags.dib,(sx),(sy),(w),(h),(dx),(dy),(sl))
|
||||
#define RestoreRegion(img,x,y) image_restoreRegion(nact->ags.dib,(img),(x),(y))
|
||||
#define SaveRegion(x,y,w,h) image_saveRegion(nact->ags.dib,(x),(y),(w),(h))
|
||||
#define DelRegion(i) image_delRegion(i)
|
||||
#define PutRegion(i,x,y) image_putRegion(nact->ags.dib,i,x,y)
|
||||
#define CopyRegion(i,sx,sy,w,h,dx,dy) image_copyRegion(i,sx,sy,w,h,nact->ags.dib,dx,dy)
|
||||
#define Maskupdate(sx,sy,w,h,dx,dy,f,st) Xcore_maskupdate(sx,sy,w,h,dx,dy,f,st)
|
||||
|
||||
/* フォント関連 */
|
||||
#define SetFontDevice(f) Xcore_setFontDevice(f)
|
||||
|
||||
/* fader 関連 */
|
||||
#define FadeOut Xcore_fadeOut
|
||||
#define FadeIn Xcore_fadeIn
|
||||
#define WhiteIn Xcore_whiteIn
|
||||
#define WhiteOut Xcore_whiteOut
|
||||
|
||||
/* key/pointer 関係 */
|
||||
#define GetKeyInfo() Xcore_getKeyInfo()
|
||||
#define SetCursorType(t) Xcore_setCursorType((t))
|
||||
#define GetMouseInfo(info) Xcore_getMouseInfo(info)
|
||||
#define Keywait(r,flg) Xcore_keywait(r,flg)
|
||||
#define SetCursorLocation(x,y) Xcore_setCursorLocation((x),(y))
|
||||
#define CursorNew(d,no,i,dir) Xcore_cursorNew((d),(no),(i),(dir))
|
||||
#define SetAutoRepeat(b) Xcore_setAutoRepeat(b);
|
||||
|
||||
/* misc */
|
||||
// #define Mainloop(ptr) Xcore_mainloop(ptr)
|
||||
#define SetNoShmMode Xcore_setNoShmMode
|
||||
// #define MainIteration() Xcore_mainIteration()
|
||||
#define EventCallback Xcore_eventCallback
|
||||
#define Sleep(ms) usleep((ms) * 1000)
|
||||
#define WaitVsync() Sleep(16)
|
||||
|
||||
#endif /* !__XCORE_H__ */
|
||||
@@ -1,257 +0,0 @@
|
||||
/*
|
||||
* xcore_cursor.c カーソル処理 for Xcore
|
||||
*
|
||||
* Copyright (C) 2000- TAJIRI Yasuhiro <tajiri@venus.dti.ne.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_cursor.c,v 1.8 2001/03/30 19:16:38 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "cursor.h"
|
||||
#include "xcore_private.h"
|
||||
|
||||
/* マウスカーソルフォントイメージ*/
|
||||
#include "bitmaps/curbm0.xbm"
|
||||
#include "bitmaps/curbm1.xbm"
|
||||
#include "bitmaps/curbm2.xbm"
|
||||
#include "bitmaps/curbm3.xbm"
|
||||
#include "bitmaps/curbm4.xbm"
|
||||
#include "bitmaps/curbm5.xbm"
|
||||
#include "bitmaps/curbm6.xbm"
|
||||
#include "bitmaps/maskbm0.xbm"
|
||||
#include "bitmaps/maskbm1.xbm"
|
||||
#include "bitmaps/maskbm2.xbm"
|
||||
#include "bitmaps/maskbm3.xbm"
|
||||
#include "bitmaps/maskbm4.xbm"
|
||||
#include "bitmaps/maskbm5.xbm"
|
||||
#include "bitmaps/maskbm6.xbm"
|
||||
|
||||
static Cursor cursor[256];
|
||||
static GC cursorGC;
|
||||
|
||||
/* mouse cursur の初期化 */
|
||||
void x11_init_cursor(void) {
|
||||
XColor black, white;
|
||||
Pixmap curPix[7], maskPix[7],tmpPixmap;
|
||||
MyPoint spot[7] = {{10, 6}, {15, 15}, {14, 15}, {14, 15}, {14, 14}, {15, 15},{16,16}};
|
||||
|
||||
black.pixel = 0x00000000;
|
||||
black.red = 0;
|
||||
black.green = 0;
|
||||
black.blue = 0;
|
||||
white.pixel = 0xffffffff;
|
||||
white.red = 0xffff;
|
||||
white.green = 0xffff;
|
||||
white.blue = 0xffff;
|
||||
|
||||
curPix[0] = XCreateBitmapFromData(x11_display, x11_window, curbm0_bits,
|
||||
curbm0_width, curbm0_height);
|
||||
maskPix[0] = XCreateBitmapFromData(x11_display, x11_window, maskbm0_bits,
|
||||
maskbm0_width, maskbm0_height);
|
||||
curPix[1] = XCreateBitmapFromData(x11_display, x11_window, curbm1_bits,
|
||||
curbm1_width, curbm1_height);
|
||||
maskPix[1] = XCreateBitmapFromData(x11_display, x11_window, maskbm1_bits,
|
||||
maskbm1_width, maskbm1_height);
|
||||
curPix[2] = XCreateBitmapFromData(x11_display, x11_window, curbm2_bits,
|
||||
curbm2_width, curbm2_height);
|
||||
maskPix[2] = XCreateBitmapFromData(x11_display, x11_window, maskbm2_bits,
|
||||
maskbm2_width, maskbm2_height);
|
||||
curPix[3] = XCreateBitmapFromData(x11_display, x11_window, curbm3_bits,
|
||||
curbm3_width, curbm3_height);
|
||||
maskPix[3] = XCreateBitmapFromData(x11_display, x11_window, maskbm3_bits,
|
||||
maskbm3_width, maskbm3_height);
|
||||
curPix[4] = XCreateBitmapFromData(x11_display, x11_window, curbm4_bits,
|
||||
curbm4_width, curbm4_height);
|
||||
maskPix[4] = XCreateBitmapFromData(x11_display, x11_window, maskbm4_bits,
|
||||
maskbm4_width, maskbm4_height);
|
||||
curPix[5] = XCreateBitmapFromData(x11_display, x11_window, curbm5_bits,
|
||||
curbm5_width, curbm5_height);
|
||||
maskPix[5] = XCreateBitmapFromData(x11_display, x11_window, maskbm5_bits,
|
||||
maskbm5_width, maskbm5_height);
|
||||
curPix[6] = XCreateBitmapFromData(x11_display, x11_window, curbm6_bits,
|
||||
curbm6_width, curbm6_height);
|
||||
maskPix[6] = XCreateBitmapFromData(x11_display, x11_window, maskbm6_bits,
|
||||
maskbm6_width, maskbm6_height);
|
||||
|
||||
cursor[CURSOR_ARROW] = XCreatePixmapCursor(x11_display, curPix[0], maskPix[0],
|
||||
&black, &white, spot[0].x, spot[0].y);
|
||||
cursor[CURSOR_CROSS] = XCreateFontCursor(x11_display, XC_tcross);
|
||||
cursor[CURSOR_IBEAM] = cursor[CURSOR_ICON] = XCreateFontCursor(x11_display, XC_icon);
|
||||
cursor[CURSOR_NO] = XCreateFontCursor(x11_display, XC_X_cursor);
|
||||
cursor[CURSOR_SIZE] = XCreatePixmapCursor(x11_display, curPix[6], maskPix[6],
|
||||
&black, &white, spot[6].x, spot[6].y);
|
||||
cursor[CURSOR_SIZEALL] = cursor[CURSOR_SIZE];
|
||||
cursor[CURSOR_SIZENESW] = XCreatePixmapCursor(x11_display, curPix[4], maskPix[4],
|
||||
&black, &white, spot[4].x, spot[4].y);
|
||||
cursor[CURSOR_SIZENS] = XCreatePixmapCursor(x11_display, curPix[2], maskPix[2],
|
||||
&black, &white, spot[2].x, spot[2].y);
|
||||
cursor[CURSOR_SIZENWSE] = XCreatePixmapCursor(x11_display, curPix[3], maskPix[3],
|
||||
&black, &white, spot[3].x, spot[3].y);
|
||||
cursor[CURSOR_SIZEWE] = XCreatePixmapCursor(x11_display, curPix[1], maskPix[1],
|
||||
&black, &white, spot[1].x, spot[1].y);
|
||||
cursor[CURSOR_UPARROW] = XCreateFontCursor(x11_display, XC_sb_up_arrow);
|
||||
// cursor[CURSOR_WAIT] = XCreateFontCursor(x11_display, XC_watch);
|
||||
cursor[CURSOR_WAIT] = XCreatePixmapCursor(x11_display, curPix[5], maskPix[5],
|
||||
&black, &white, spot[5].x, spot[5].y);
|
||||
|
||||
if ((tmpPixmap = XCreatePixmap(x11_display,x11_window, 1, 1, 1)))
|
||||
{
|
||||
cursorGC = XCreateGC( x11_display, tmpPixmap, 0, NULL );
|
||||
XSetGraphicsExposures( x11_display, cursorGC, False );
|
||||
XFreePixmap( x11_display, tmpPixmap );
|
||||
}
|
||||
}
|
||||
|
||||
boolean Xcore_cursorNew(BYTE* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry) {
|
||||
int xormasklen, andmasklen, xornum;
|
||||
int i, j, k, l;
|
||||
int h = 0;
|
||||
BYTE *buf1, *buf2, *buf3,*buf4;
|
||||
Pixmap xorPix, andPix;
|
||||
XColor bg, fg;
|
||||
|
||||
bg.pixel = 0xffffff;
|
||||
bg.red = cursorImage->icColors[0].rgbRed*256;
|
||||
bg.green = cursorImage->icColors[0].rgbGreen*256;
|
||||
bg.blue = cursorImage->icColors[0].rgbBlue*256;
|
||||
fg.pixel = 0xffffff;
|
||||
fg.red = cursorImage->icColors[1].rgbRed*256;
|
||||
fg.green = cursorImage->icColors[1].rgbGreen*256;
|
||||
fg.blue = cursorImage->icColors[1].rgbBlue*256;
|
||||
|
||||
xornum = (cursordirentry->bWidth * cursordirentry->bHeight);
|
||||
xormasklen = (xornum * cursorImage->icHeader.biBitCount) / 8;
|
||||
NOTICE("Cursor: xormasklen==%d, xornum==%d\n", xormasklen, xornum);
|
||||
|
||||
andmasklen = xornum / 8;
|
||||
cursorImage->xormasklen = xormasklen;
|
||||
cursorImage->andmasklen = andmasklen;
|
||||
|
||||
|
||||
buf1 = malloc(sizeof(BYTE) * xornum);
|
||||
buf2 = malloc(sizeof(BYTE) * xornum);
|
||||
buf3 = malloc(sizeof(BYTE) * xornum);
|
||||
buf4 = malloc(sizeof(BYTE) * xornum);
|
||||
|
||||
memcpy(buf1, data, min(xormasklen, xornum));
|
||||
data += xormasklen;
|
||||
|
||||
memcpy(buf2, data, min(andmasklen, xornum));
|
||||
data += andmasklen;
|
||||
|
||||
#define height cursordirentry->bHeight
|
||||
#define width cursordirentry->bWidth
|
||||
|
||||
for (j = 0; j < height; j++) {
|
||||
for (i = 0; i < width * cursorImage->icHeader.biBitCount /8; i++) {
|
||||
k = buf1[(height-j-1)*height*cursorImage->icHeader.biBitCount/8+i];
|
||||
l = buf2[(height-j-1)*height*cursorImage->icHeader.biBitCount/8+i];
|
||||
#define SWAPBITS(x) ((x& 1)<<7|(x& 2)<<5|(x& 4)<<3|(x& 8)<<1|\
|
||||
(x&0x10)>>1|(x&0x20)>>3|(x&0x40)>>5|(x&0x80)>>7)
|
||||
buf3[h] = SWAPBITS(l);
|
||||
buf4[h] = SWAPBITS(k);
|
||||
h++;
|
||||
#undef SWAPBITS
|
||||
}
|
||||
}
|
||||
xorPix = XCreateBitmapFromData(x11_display, x11_window, buf3, width, height);
|
||||
andPix = XCreateBitmapFromData(x11_display, x11_window, buf4, width, height);
|
||||
|
||||
/*ここから、XOR,ANDがたから、X用のカーソルに作りかえ*/
|
||||
/*wine-991114 windows/x11drv/mouse.cより引用
|
||||
* X11 mouse driver
|
||||
*
|
||||
* Copyright 1998 Ulrich Weigand
|
||||
*/
|
||||
{
|
||||
Pixmap pixmapBits, pixmapMask, pixmapMaskInv;
|
||||
pixmapBits = XCreatePixmap( x11_display, x11_window,
|
||||
width, height, 1 );
|
||||
pixmapMask = XCreatePixmap( x11_display, x11_window,
|
||||
width, height, 1 );
|
||||
pixmapMaskInv = XCreatePixmap( x11_display, x11_window,
|
||||
width, height, 1 );
|
||||
|
||||
if (pixmapBits && pixmapMask && xorPix && andPix)
|
||||
{
|
||||
XSetFunction( x11_display, cursorGC, GXcopy );
|
||||
XCopyArea( x11_display, xorPix, pixmapBits, cursorGC,
|
||||
0, 0, width, height, 0, 0 );
|
||||
XCopyArea( x11_display, xorPix, pixmapMask, cursorGC,
|
||||
0, 0, width, height, 0, 0 );
|
||||
XCopyArea( x11_display, xorPix, pixmapMaskInv, cursorGC,
|
||||
0, 0, width, height, 0, 0 );
|
||||
XSetFunction( x11_display, cursorGC, GXand );
|
||||
XCopyArea( x11_display, andPix, pixmapMaskInv, cursorGC,
|
||||
0, 0, width, height, 0, 0 );
|
||||
XSetFunction( x11_display, cursorGC, GXandReverse );
|
||||
XCopyArea( x11_display, andPix, pixmapBits, cursorGC,
|
||||
0, 0, width, height, 0, 0 );
|
||||
XSetFunction( x11_display, cursorGC, GXorReverse );
|
||||
XCopyArea( x11_display, andPix, pixmapMask, cursorGC,
|
||||
0, 0, width, height, 0, 0 );
|
||||
XSetFunction( x11_display, cursorGC, GXor );
|
||||
XCopyArea( x11_display, pixmapMaskInv, pixmapMask, cursorGC,
|
||||
0, 0, width, height, 1, 1 );
|
||||
XCopyArea( x11_display, pixmapMaskInv, pixmapBits, cursorGC,
|
||||
0, 0, width, height, 1, 1 );
|
||||
XSetFunction( x11_display, cursorGC, GXcopy );
|
||||
cursor[no] = XCreatePixmapCursor(x11_display, pixmapBits, pixmapMask,
|
||||
&fg, &bg, cursordirentry->wxHotspot,
|
||||
cursordirentry->wyHotspot);
|
||||
}
|
||||
|
||||
if (xorPix) XFreePixmap( x11_display, xorPix );
|
||||
if (andPix) XFreePixmap(x11_display, andPix );
|
||||
if (pixmapBits) XFreePixmap( x11_display, pixmapBits );
|
||||
if (pixmapMask) XFreePixmap( x11_display, pixmapMask );
|
||||
if (pixmapMaskInv) XFreePixmap( x11_display, pixmapMaskInv );
|
||||
}
|
||||
|
||||
free(buf1);
|
||||
free(buf2);
|
||||
free(buf3);
|
||||
free(buf4);
|
||||
|
||||
#undef height
|
||||
#undef width
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* マウスの位置の移動 */
|
||||
void Xcore_setCursorLocation(int x, int y) {
|
||||
XWarpPointer(x11_display, x11_window, x11_window,
|
||||
0, 0, 0, 0,
|
||||
x + winoffset_x, y + winoffset_y);
|
||||
XFlush(x11_display);
|
||||
}
|
||||
|
||||
/* マウスカーソルの形状の設定 */
|
||||
void Xcore_setCursorType(int type) {
|
||||
XDefineCursor(x11_display, x11_window, cursor[type]);
|
||||
}
|
||||
@@ -1,606 +0,0 @@
|
||||
/*
|
||||
* xcore_draw.c X11 draw to DIB
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_draw.c,v 1.7 2004/10/31 04:18:06 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef X_LOCALE
|
||||
#include <X11/Xlocale.h>
|
||||
#else
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "font.h"
|
||||
#include "ags.h"
|
||||
#include "image.h"
|
||||
#include "nact.h"
|
||||
#include "xcore.h"
|
||||
#include "xcore_private.h"
|
||||
|
||||
static void Xcore_updateAll();
|
||||
static void rect_comimg(agsurface_t *src, agsurface_t *dst, int sx, int sy, int sw, int sh);
|
||||
static void workImageToWindow();
|
||||
static void DIBToWorkImage(int sx, int sy, int w, int h, int dx, int dy);
|
||||
|
||||
|
||||
/* 全画面更新 */
|
||||
static void Xcore_updateAll() {
|
||||
MyRectangle src;
|
||||
MyPoint dst;
|
||||
|
||||
src.x = view_x;
|
||||
src.y = view_y;
|
||||
src.width = min(DIB->width, view_w);
|
||||
src.height = min(DIB->height, view_h);
|
||||
dst.x = dst.y = 0;
|
||||
Xcore_updateArea(&src, &dst);
|
||||
}
|
||||
|
||||
/* offscreenの指定領域をWindowへ転送 */
|
||||
void Xcore_updateArea(MyRectangle *src, MyPoint *dst) {
|
||||
agsurface_t _dib, _work;
|
||||
|
||||
if (x11_dibinfo->shared) {
|
||||
XCopyArea(x11_display, x11_pixmap, x11_window, x11_gc_pix,
|
||||
src->x, src->y, src->width, src->height,
|
||||
winoffset_x + dst->x, winoffset_y + dst->y);
|
||||
} else {
|
||||
if (DIB_DEPTH == 8) {
|
||||
if (WIN_DEPTH == 8) {
|
||||
XPutImage(x11_display, x11_window,
|
||||
x11_gc_pix, x11_dibinfo->ximg,
|
||||
src->x, src->y,
|
||||
winoffset_x + dst->x, winoffset_y + dst->y,
|
||||
src->width, src->height);
|
||||
} else {
|
||||
rect_comimg(DIB, &_dib,
|
||||
src->x, src->y, src->width, src->height);
|
||||
rect_comimg(WORK, &_work,
|
||||
dst->x, dst->y, src->width, src->height);
|
||||
|
||||
image_expandPixel(&_dib, &_work, 255);
|
||||
|
||||
if (x11_workinfo->shared) {
|
||||
XShmPutImage(x11_display, x11_window,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
dst->x, dst->y,
|
||||
winoffset_x + dst->x, winoffset_y + dst->y,
|
||||
src->width, src->height, False);
|
||||
} else {
|
||||
XPutImage(x11_display, x11_window,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
dst->x, dst->y,
|
||||
winoffset_x + dst->x, winoffset_y + dst->y,
|
||||
src->width, src->height);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (packed24bpp) {
|
||||
rect_comimg(DIB, &_dib,
|
||||
src->x, src->y, src->width, src->height);
|
||||
rect_comimg(WORK, &_work,
|
||||
dst->x, dst->y, src->width, src->height);
|
||||
|
||||
image_trans_pixel_24to24p(&_dib, &_work);
|
||||
|
||||
XPutImage(x11_display, x11_window,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
dst->x, dst->y,
|
||||
winoffset_x + dst->x, winoffset_y + dst->y,
|
||||
src->width, src->height);
|
||||
} else {
|
||||
XPutImage(x11_display, x11_window,
|
||||
x11_gc_pix, x11_dibinfo->ximg,
|
||||
src->x, src->y,
|
||||
winoffset_x + dst->x, winoffset_y + dst->y,
|
||||
src->width, src->height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XSync(x11_display, False); x11_needSync = False;
|
||||
}
|
||||
|
||||
/* draw rectangle */
|
||||
void Xcore_drawRectangle(int x, int y, int w, int h, unsigned long col) {
|
||||
if (!x11_dibinfo->shared) {
|
||||
image_drawRectangle(DIB, x, y, w, h, PAL2PIC(col));
|
||||
} else {
|
||||
Xcore_setForeground(col);
|
||||
XDrawRectangle(x11_display, x11_pixmap, x11_gc_pix, x, y, w - 1, h - 1);
|
||||
x11_needSync = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* fill rectangle */
|
||||
void Xcore_fillRectangle(int x, int y, int w, int h, unsigned long col) {
|
||||
if (!x11_dibinfo->shared) {
|
||||
image_fillRectangle(DIB, x, y, w, h, PAL2PIC(col));
|
||||
} else {
|
||||
Xcore_setForeground(col);
|
||||
XFillRectangle(x11_display, x11_pixmap, x11_gc_pix, x, y, w, h);
|
||||
x11_needSync = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy area */
|
||||
void Xcore_copyArea(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
if (!x11_dibinfo->shared) {
|
||||
image_copyArea(DIB, sx, sy, w, h, dx, dy);
|
||||
} else {
|
||||
XCopyArea(x11_display, x11_pixmap, x11_pixmap, x11_gc_pix,
|
||||
sx, sy, w, h, dx, dy);
|
||||
x11_needSync = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* 直線描画 */
|
||||
void Xcore_drawLine(int x1, int y1, int x2, int y2, unsigned long col) {
|
||||
if (!x11_dibinfo->shared) {
|
||||
image_drawLine(DIB, x1, y1, x2, y2, PAL2PIC(col));
|
||||
} else {
|
||||
Xcore_setForeground(col);
|
||||
XDrawLine(x11_display, x11_pixmap, x11_gc_pix, x1, y1, x2, y2);
|
||||
x11_needSync = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
int Xcore_drawString(int x, int y, const char *str_utf8, unsigned long col) {
|
||||
int w;
|
||||
|
||||
if (x11_font->self_drawable()) {
|
||||
w = x11_font->draw_glyph(x, y, str_utf8, col);
|
||||
x11_needSync = TRUE;
|
||||
} else {
|
||||
agsurface_t *glyph = x11_font->get_glyph(str_utf8);
|
||||
|
||||
if (glyph == NULL) return 0;
|
||||
|
||||
if (x11_font->antialiase_on && DIB_DEPTH != 8) {
|
||||
if (x > 0) x -= 1;
|
||||
if (y > 0) y -= 1;
|
||||
image_draw_antialiased_pattern(DIB, glyph,
|
||||
x, y,
|
||||
glyph->width +2, glyph->height +2,
|
||||
PAL2PIC(col));
|
||||
} else {
|
||||
image_draw_pattern(DIB, glyph,
|
||||
x, y,
|
||||
glyph->width, glyph->height,
|
||||
PAL2PIC(col));
|
||||
}
|
||||
w = glyph->width;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void Xcore_zoom(int x, int y, int w, int h) {
|
||||
if (DIB_DEPTH == WIN_DEPTH) {
|
||||
agsurface_t _dib, _work;
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
rect_comimg(DIB, &_dib, x, y, w, h);
|
||||
image_scaledCopyArea(DIB, &_work, x, y, w, h,
|
||||
0, 0, view_w, view_h, 0);
|
||||
workImageToWindow();
|
||||
} else {
|
||||
/* TODO */
|
||||
}
|
||||
}
|
||||
|
||||
/* Color の複数個指定 */
|
||||
void Xcore_setPalette(Palette256 *pal, int src, int cnt) {
|
||||
int i;
|
||||
|
||||
if (x11_visual->class == PseudoColor) {
|
||||
for (i = 0; i < cnt; i++) {
|
||||
x11_col[src + i].pixel = src + i;
|
||||
x11_col[src + i].flags = DoRed | DoGreen | DoBlue;
|
||||
x11_col[src + i].red = pal->red [src + i] * 257;
|
||||
x11_col[src + i].green = pal->green[src + i] * 257;
|
||||
x11_col[src + i].blue = pal->blue [src + i] * 257;
|
||||
}
|
||||
XStoreColors(x11_display, x11_cm, &x11_col[src], cnt);
|
||||
}
|
||||
}
|
||||
|
||||
/* foreground のセット */
|
||||
void Xcore_setForeground(unsigned long col) {
|
||||
static unsigned long fc = 0;
|
||||
|
||||
if (fc == col && x11_visual->class == PseudoColor) return;
|
||||
|
||||
fc = col;
|
||||
|
||||
if (x11_visual->class != PseudoColor) {
|
||||
XSetForeground(x11_display, x11_gc_pix, PAL2PIC(col));
|
||||
} else {
|
||||
XSetForeground(x11_display, x11_gc_pix, col);
|
||||
}
|
||||
}
|
||||
|
||||
/* background のセット */
|
||||
void Xcore_setBackground(unsigned long col) {
|
||||
static unsigned long bc = 0;
|
||||
|
||||
if (bc == col) return;
|
||||
|
||||
bc = col;
|
||||
|
||||
if (x11_visual->class != PseudoColor) {
|
||||
XSetBackground(x11_display, x11_gc_win, PAL2PIC(col));
|
||||
} else {
|
||||
XSetBackground(x11_display, x11_gc_win, col);
|
||||
}
|
||||
}
|
||||
|
||||
/* X-Serverとの同期を取る */
|
||||
void Xcore_sync() {
|
||||
if (x11_needSync) { XSync(x11_display, False); x11_needSync = FALSE; }
|
||||
}
|
||||
|
||||
static void rect_comimg(agsurface_t *src, agsurface_t *dst, int sx, int sy, int sw, int sh) {
|
||||
memcpy(dst, src, sizeof(agsurface_t));
|
||||
|
||||
//dst->x = sx;
|
||||
//dst->y = sy;
|
||||
dst->width = sw;
|
||||
dst->height = sh;
|
||||
dst->pixel = GETOFFSET_PIXEL(src, sx, sy);
|
||||
}
|
||||
|
||||
/* fader で workImage の内容をWindowに描画 */
|
||||
static void workImageToWindow() {
|
||||
if (x11_workinfo->shared) {
|
||||
XSync(x11_display, False);
|
||||
XShmPutImage(x11_display, x11_window,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
0, 0,
|
||||
winoffset_x, winoffset_y,
|
||||
view_w, view_h, False);
|
||||
} else {
|
||||
XPutImage(x11_display, x11_window,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
0, 0,
|
||||
winoffset_x, winoffset_y,
|
||||
view_w, view_h);
|
||||
}
|
||||
}
|
||||
|
||||
/* DIB から work image への展開 */
|
||||
static void DIBToWorkImage(int sx, int sy, int w, int h, int dx, int dy) {
|
||||
if (DIB_DEPTH == dib_depth_candidate) {
|
||||
int y;
|
||||
BYTE *src = GETOFFSET_PIXEL(&(x11_dibinfo->cimg), sx, sy);
|
||||
BYTE *dst = GETOFFSET_PIXEL(&(x11_workinfo->cimg), dx, dy);
|
||||
for (y = 0; y < h; y++) {
|
||||
memcpy(dst, src, w * x11_dibinfo->cimg.bytes_per_pixel);
|
||||
src += x11_dibinfo->cimg.bytes_per_line;
|
||||
dst += x11_workinfo->cimg.bytes_per_line;
|
||||
}
|
||||
} else {
|
||||
agsurface_t _dib, _work;
|
||||
rect_comimg(DIB, &_dib, sx, sy, w, h);
|
||||
rect_comimg(WORK, &_work, dx, dy, w, h);
|
||||
image_expandPixel(&_dib, &_work, 255);
|
||||
}
|
||||
}
|
||||
|
||||
/* 指定の明度以上に明るさを設定 */
|
||||
/* (255-col)/255 * val + col */
|
||||
static void setWhiteness8(int val) {
|
||||
int i;
|
||||
Palette256 *pal = nact->sys_pal;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
x11_col[i].pixel = i;
|
||||
x11_col[i].flags = DoRed | DoGreen | DoBlue;
|
||||
x11_col[i].red = ((((255 - pal->red[i]) * val) / 256) + pal->red[i]) * 257;
|
||||
x11_col[i].green = ((((255 - pal->green[i]) * val) / 256) + pal->green[i]) * 257;
|
||||
x11_col[i].blue = ((((255 - pal->blue[i]) * val) / 256) + pal->blue[i]) * 257;
|
||||
}
|
||||
XStoreColors(x11_display, x11_cm, x11_col, 256);
|
||||
}
|
||||
|
||||
/* 指定の明度以下に明るさを抑える */
|
||||
static void setBlightness8(int val) {
|
||||
int i;
|
||||
Palette256 *pal = nact->sys_pal;
|
||||
|
||||
for (i =0; i < 256; i++) {
|
||||
x11_col[i].pixel = i;
|
||||
x11_col[i].flags = DoRed | DoGreen | DoBlue;
|
||||
x11_col[i].red = (val * pal->red[i] / 255) * 257;
|
||||
x11_col[i].green = (val * pal->green[i] / 255) * 257;
|
||||
x11_col[i].blue = (val * pal->blue[i] / 255) * 257;
|
||||
}
|
||||
XStoreColors(x11_display, x11_cm, x11_col, 256);
|
||||
}
|
||||
|
||||
static int fadestep[256] =
|
||||
{0,1,3,4,6,7,9,10,12,14,15,17,18,20,21,23,25,26,28,29,31,32,34,36,37,39,40,
|
||||
42,43,45,46,48,49,51,53,54,56,57,59,60,62,63,65,66,68,69,71,72,74,75,77,78,
|
||||
80,81,83,84,86,87,89,90,92,93,95,96,97,99,100,102,103,105,106,108,109,110,
|
||||
112,113,115,116,117,119,120,122,123,124,126,127,128,130,131,132,134,135,136,
|
||||
138,139,140,142,143,144,146,147,148,149,151,152,153,155,156,157,158,159,161,
|
||||
162,163,164,166,167,168,169,170,171,173,174,175,176,177,178,179,181,182,183,
|
||||
184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,
|
||||
203,204,205,206,207,208,209,210,211,211,212,213,214,215,216,217,217,218,219,
|
||||
220,221,221,222,223,224,225,225,226,227,227,228,229,230,230,231,232,232,233,
|
||||
234,234,235,235,236,237,237,238,238,239,239,240,241,241,242,242,243,243,244,
|
||||
244,244,245,245,246,246,247,247,247,248,248,249,249,249,250,250,250,251,251,
|
||||
251,251,252,252,252,252,253,253,253,253,254,254,254,254,254,254,255,255,255,
|
||||
255,255,255,255,255,255,255,255,255,255,255};
|
||||
|
||||
static void fadein_8_n8(int step) {
|
||||
static agsurface_t _dib, _work;
|
||||
|
||||
if (step == 0) {
|
||||
rect_comimg(DIB, &_dib, view_x, view_y, view_w, view_h);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
image_expandPixel(&_dib, &_work, fadestep[step]);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void fadein_n8(int step) {
|
||||
static agsurface_t _dib, _work;
|
||||
|
||||
if (step == 0) {
|
||||
rect_comimg(DIB, &_dib, view_x, view_y, view_w, view_h);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
memset(_work.pixel, 0, x11_workinfo->cimg.bytes_per_pixel * view_w * view_h);
|
||||
}
|
||||
if (step == 255) {
|
||||
ags_updateFull();
|
||||
return;
|
||||
}
|
||||
image_fadeIn(&_dib, &_work, step /16);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void fadeout_8_n8(int step) {
|
||||
static agsurface_t _dib, _work;
|
||||
|
||||
if (step == 0) {
|
||||
rect_comimg(DIB, &_dib, view_x, view_y, view_w, view_h);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
if (step == 255) {
|
||||
Xcore_setBackground(0);
|
||||
XClearWindow(x11_display, x11_window);
|
||||
return;
|
||||
}
|
||||
image_expandPixel(&_dib, &_work, fadestep[255 - step]);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void fadeout_n8(int step) {
|
||||
static agsurface_t _work;
|
||||
|
||||
if (step == 0) {
|
||||
DIBToWorkImage(view_x, view_y, view_w, view_h, 0, 0);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
if (step == 255) {
|
||||
Xcore_setBackground(0);
|
||||
XClearWindow(x11_display, x11_window);
|
||||
return;
|
||||
}
|
||||
image_fadeOut(&_work, (255-step)/16, 0);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void whitein_8_n8(int step) {
|
||||
static agsurface_t _dib, _work;
|
||||
|
||||
if (step == 0) {
|
||||
rect_comimg(DIB, &_dib, view_x, view_y, view_w, view_h);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
image_expandPixel(&_dib, &_work, fadestep[255-step]+255);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void whitein_n8(int step) {
|
||||
static agsurface_t _dib, _work;
|
||||
|
||||
if (step == 0) {
|
||||
rect_comimg(DIB, &_dib, view_x, view_y, view_w, view_h);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
if (step == 255) {
|
||||
ags_updateFull();
|
||||
return;
|
||||
}
|
||||
image_fadeIn(&_dib, &_work, (255-step)/16);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void whiteout_8_n8(int step) {
|
||||
static agsurface_t _dib, _work;
|
||||
|
||||
if (step == 0) {
|
||||
rect_comimg(DIB, &_dib, view_x, view_y, view_w, view_h);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
image_expandPixel(&_dib, &_work, fadestep[step]+255);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
static void whiteout_n8(int step) {
|
||||
static agsurface_t _work;
|
||||
|
||||
if (step == 0) {
|
||||
DIBToWorkImage(view_x, view_y, view_w, view_h, 0, 0);
|
||||
rect_comimg(WORK, &_work, 0, 0, view_w, view_h);
|
||||
}
|
||||
if (step == 255) {
|
||||
memset(x11_workinfo->cimg.pixel, 255, x11_workinfo->cimg.bytes_per_pixel * view_w * view_h);
|
||||
workImageToWindow();
|
||||
return;
|
||||
}
|
||||
image_fadeOut(&_work, step/16, 0xffffffff);
|
||||
workImageToWindow();
|
||||
}
|
||||
|
||||
void Xcore_fadeIn(int step) {
|
||||
|
||||
if (step == 0) {
|
||||
Xcore_sync();
|
||||
}
|
||||
|
||||
if (DIB_DEPTH == 8) {
|
||||
if (WIN_DEPTH == 8) {
|
||||
if (step == 0) Xcore_updateAll();
|
||||
setBlightness8(fadestep[step]);
|
||||
} else {
|
||||
fadein_8_n8(step);
|
||||
}
|
||||
} else {
|
||||
fadein_n8(step);
|
||||
}
|
||||
}
|
||||
|
||||
void Xcore_fadeOut(int step) {
|
||||
|
||||
if (step == 0) {
|
||||
Xcore_sync();
|
||||
}
|
||||
|
||||
if (DIB_DEPTH == 8) {
|
||||
if (WIN_DEPTH == 8) {
|
||||
setBlightness8(fadestep[255-step]);
|
||||
} else {
|
||||
fadeout_8_n8(step);
|
||||
}
|
||||
} else {
|
||||
fadeout_n8(step);
|
||||
}
|
||||
}
|
||||
|
||||
void Xcore_whiteIn(int step) {
|
||||
|
||||
if (step == 0) {
|
||||
Xcore_sync();
|
||||
}
|
||||
|
||||
if (DIB_DEPTH == 8) {
|
||||
if (WIN_DEPTH == 8) {
|
||||
if (step == 0) Xcore_updateAll();
|
||||
setWhiteness8(fadestep[step]);
|
||||
} else {
|
||||
whitein_8_n8(step);
|
||||
}
|
||||
} else {
|
||||
whitein_n8(step);
|
||||
}
|
||||
}
|
||||
|
||||
void Xcore_whiteOut(int step) {
|
||||
|
||||
if (step == 0) {
|
||||
Xcore_sync();
|
||||
}
|
||||
|
||||
if (DIB_DEPTH == 8) {
|
||||
if (WIN_DEPTH == 8) {
|
||||
setWhiteness8(fadestep[255-step]);
|
||||
} else {
|
||||
whiteout_8_n8(step);
|
||||
}
|
||||
} else {
|
||||
whiteout_n8(step);
|
||||
}
|
||||
}
|
||||
|
||||
Pixmap x11_clip_from_DIB(int sx, int sy, int w, int h) {
|
||||
agsurface_t _dib, _work;
|
||||
Pixmap clippix;
|
||||
|
||||
clippix = XCreatePixmap(x11_display, x11_window, w, h, WIN_DEPTH);
|
||||
|
||||
if (x11_dibinfo->shared) {
|
||||
XCopyArea(x11_display, x11_pixmap, clippix, x11_gc_pix,
|
||||
sx, sy, w, h, 0, 0);
|
||||
} else {
|
||||
if (DIB_DEPTH == 8) {
|
||||
if (WIN_DEPTH == 8) {
|
||||
XPutImage(x11_display, clippix,
|
||||
x11_gc_pix, x11_dibinfo->ximg,
|
||||
sx, sy, 0, 0, w, h);
|
||||
} else {
|
||||
rect_comimg(DIB, &_dib,
|
||||
sx, sy, w, h);
|
||||
rect_comimg(WORK, &_work,
|
||||
0, 0, w, h);
|
||||
|
||||
image_expandPixel(&_dib, &_work, 255);
|
||||
|
||||
if (x11_workinfo->shared) {
|
||||
XShmPutImage(x11_display, clippix,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
0, 0,
|
||||
0, 0,
|
||||
sx, sy, False);
|
||||
} else {
|
||||
XPutImage(x11_display, clippix,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
0, 0,
|
||||
0, 0,
|
||||
w, h);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (packed24bpp) {
|
||||
rect_comimg(DIB, &_dib,
|
||||
sx, sy, w, h);
|
||||
rect_comimg(WORK, &_work,
|
||||
0, 0, w, h);
|
||||
|
||||
image_trans_pixel_24to24p(&_dib, &_work);
|
||||
|
||||
XPutImage(x11_display, clippix,
|
||||
x11_gc_win, x11_workinfo->ximg,
|
||||
0, 0,
|
||||
0, 0,
|
||||
w, h);
|
||||
} else {
|
||||
XPutImage(x11_display, clippix,
|
||||
x11_gc_pix, x11_dibinfo->ximg,
|
||||
sx, sy,
|
||||
0, 0,
|
||||
w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return clippix;
|
||||
}
|
||||
@@ -1,260 +0,0 @@
|
||||
/*
|
||||
* xcore_event.c X11 event handler
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_event.c,v 1.12 2004/10/31 04:18:06 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "xcore.h"
|
||||
#include "xcore_private.h"
|
||||
#include "nact.h"
|
||||
#include "counter.h"
|
||||
#include "input.h"
|
||||
#include "menu.h"
|
||||
#include "joystick.h"
|
||||
#include "xcore_input.c"
|
||||
|
||||
static boolean xcore_getEvent(void);
|
||||
static int check_button(void);
|
||||
|
||||
/* pointer の状態 */
|
||||
static int mousex, mousey;
|
||||
|
||||
static boolean xcore_getEvent(void) {
|
||||
XEvent e;
|
||||
Window root, child;
|
||||
int rx, ry, wx, wy;
|
||||
int mask;
|
||||
boolean getkey = FALSE, msg_skip = FALSE;
|
||||
|
||||
while(XPending(x11_display)) {
|
||||
XNextEvent(x11_display, &e);
|
||||
switch(e.type) {
|
||||
case LeaveNotify:
|
||||
mousex = -1; mousey = -1; // mouseb = 0;
|
||||
memset(RawKeyInfo, 0, sizeof(RawKeyInfo));
|
||||
getkey = TRUE;
|
||||
if (x11_fs_on) {
|
||||
XUngrabPointer(x11_display, CurrentTime);
|
||||
XSync(x11_display, False);
|
||||
}
|
||||
break;
|
||||
case EnterNotify:
|
||||
if (x11_fs_on) {
|
||||
XGrabPointer(x11_display, x11_window, True, 0,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
x11_window, None, CurrentTime);
|
||||
XSync(x11_display, False);
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
if (!XQueryPointer(x11_display, x11_window, &root, &child, &rx, &ry, &wx, &wy, &mask))
|
||||
break;
|
||||
mousex = wx; mousey = wy;
|
||||
if (nact->ags.eventcb) {
|
||||
agsevent_t agse;
|
||||
agse.type = AGSEVENT_MOUSE_MOTION;
|
||||
agse.d1 = wx; agse.d2 = wy; agse.d3 = 0;
|
||||
nact->ags.eventcb(&agse);
|
||||
}
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case ButtonPress:
|
||||
mouseb |= (1 << e.xbutton.button);
|
||||
getkey = TRUE;
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
mouseb &= (0xffffffff ^ (1 << e.xbutton.button));
|
||||
getkey = TRUE;
|
||||
break;
|
||||
#endif
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
buttonEventProcess((XButtonEvent *)&e);
|
||||
getkey = TRUE;
|
||||
break;
|
||||
|
||||
case Expose: {
|
||||
MyRectangle src;
|
||||
MyPoint dst;
|
||||
XExposeEvent *ev = (XExposeEvent *)&e;
|
||||
if (ev->count == 0) {
|
||||
src.x = view_x + ev->x - winoffset_x;
|
||||
src.y = view_y + ev->y - winoffset_y;
|
||||
src.width = min(DIB->width, ev->width);
|
||||
src.height = min(DIB->height, ev->height);
|
||||
dst.x = ev->x - winoffset_x;
|
||||
dst.y = ev->y - winoffset_y;
|
||||
if (src.x > view_w || src.x < 0) break;
|
||||
if (src.y > view_h || src.y < 0) break;
|
||||
Xcore_updateArea(&src, &dst);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case KeyPress:
|
||||
keyEventProsess((XKeyEvent *)&e);
|
||||
getkey = TRUE;
|
||||
break;
|
||||
|
||||
case KeyRelease: {
|
||||
KeySym sym;
|
||||
|
||||
keyEventProsess((XKeyEvent *)&e);
|
||||
sym = XkbKeycodeToKeysym(x11_display, e.xkey.keycode, 0, 0);
|
||||
if (sym == XK_F4) {
|
||||
Xcore_fullScreen(!x11_fs_on);
|
||||
} else if (sym == XK_F1) {
|
||||
msg_skip = TRUE;
|
||||
}
|
||||
getkey = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case ClientMessage:
|
||||
if (e.xclient.message_type == atom_wmprot &&
|
||||
e.xclient.data.l[0] == atom_delwin) {
|
||||
menu_quitmenu_open();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg_skip) set_skipMode(!get_skipMode());
|
||||
return getkey;
|
||||
}
|
||||
|
||||
int Xcore_keywait(int msec, boolean cancel) {
|
||||
boolean bool = FALSE;
|
||||
int key = 0, retval, rest = msec;
|
||||
int cnt = get_high_counter(SYSTEMCOUNTER_MSEC);
|
||||
|
||||
if (msec < 0) return 0;
|
||||
#if 1
|
||||
while (msec > (get_high_counter(SYSTEMCOUNTER_MSEC) - cnt)) {
|
||||
bool = xcore_getEvent();
|
||||
//key = check_button() | Xcore_getKeyInfo() | joy_getinfo();
|
||||
key |= check_button() | Xcore_getKeyInfo() | joy_getinfo();
|
||||
if( cancel && key ) break;
|
||||
rest = msec - (get_high_counter(SYSTEMCOUNTER_MSEC) - cnt);
|
||||
if (rest < 0) break;
|
||||
if (rest < 10) {
|
||||
usleep(1000 * rest);
|
||||
} else {
|
||||
usleep(10000);
|
||||
}
|
||||
nact->callback();
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
while (rest > 0) {
|
||||
struct timeval tv;
|
||||
fd_set fdset;
|
||||
int x11_fd = ConnectionNumber(x11_display);
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(x11_fd, &fdset);
|
||||
|
||||
cnt = get_high_counter(SYSTEMCOUNTER_MSEC);
|
||||
tv.tv_sec = 0;
|
||||
if (rest < 100) {
|
||||
tv.tv_usec = rest * 1000;
|
||||
} else {
|
||||
tv.tv_usec = 100 * 1000;
|
||||
}
|
||||
retval = select(x11_fd + 1, &fdset, NULL, NULL, &tv);
|
||||
if (retval > 0) {
|
||||
if (FD_ISSET(x11_fd, &fdset)) {
|
||||
bool = xcore_getEvent();
|
||||
}
|
||||
} else if (retval < 0) {
|
||||
perror("select");
|
||||
}
|
||||
if (bool) {
|
||||
key |= (check_button() | Xcore_getKeyInfo());
|
||||
if (cancel) break;
|
||||
}
|
||||
rest -= (get_high_counter(SYSTEMCOUNTER_MSEC) - cnt);
|
||||
nact->callback();
|
||||
}
|
||||
#endif
|
||||
return key;
|
||||
}
|
||||
|
||||
/* キー情報の取得 */
|
||||
int Xcore_getKeyInfo() {
|
||||
xcore_getEvent();
|
||||
|
||||
return ((RawKeyInfo[KEY_UP] || RawKeyInfo[KEY_PAD_8]) |
|
||||
((RawKeyInfo[KEY_DOWN] || RawKeyInfo[KEY_PAD_2]) << 1) |
|
||||
((RawKeyInfo[KEY_LEFT] || RawKeyInfo[KEY_PAD_4]) << 2) |
|
||||
((RawKeyInfo[KEY_RIGHT] || RawKeyInfo[KEY_PAD_6]) << 3) |
|
||||
(RawKeyInfo[KEY_ENTER] << 4) |
|
||||
(RawKeyInfo[KEY_SPACE] << 5) |
|
||||
(RawKeyInfo[KEY_ESC] << 6) |
|
||||
(RawKeyInfo[KEY_TAB] << 7));
|
||||
}
|
||||
|
||||
/* mouse 情報の取得 */
|
||||
int Xcore_getMouseInfo(MyPoint *p) {
|
||||
xcore_getEvent();
|
||||
|
||||
if (mousex < 0) {
|
||||
if (p) {
|
||||
p->x=0; p->y=0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p) {
|
||||
p->x = mousex - winoffset_x;
|
||||
p->y = mousey - winoffset_y;
|
||||
}
|
||||
return check_button();
|
||||
}
|
||||
|
||||
/* mouse のボタン状態の取得 */
|
||||
static int check_button(void) {
|
||||
int m1, m2;
|
||||
|
||||
if (RawKeyInfo[KEY_MOUSE_MIDDLE]) {
|
||||
menu_open();
|
||||
} else {
|
||||
m1 = RawKeyInfo[KEY_MOUSE_LEFT] ? SYS35KEY_RET : 0;
|
||||
m2 = RawKeyInfo[KEY_MOUSE_RIGHT] ? SYS35KEY_SPC : 0;
|
||||
return m1|m2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
-1620
File diff suppressed because it is too large
Load Diff
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* image.h image操作
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: image.h,v 1.24 2003/01/12 10:48:50 chikama Exp $ */
|
||||
|
||||
#ifndef __XCORE_IMAGE__
|
||||
#define __XCORE_IMAGE__
|
||||
|
||||
#include "cg.h"
|
||||
#include "ags.h"
|
||||
|
||||
extern void xcore_image_setdepth(int);
|
||||
extern void image_expandPixel(agsurface_t *img_src, agsurface_t *img_dst, int lv);
|
||||
extern void image_scaledCopyArea(agsurface_t *dib, agsurface_t *src, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror);
|
||||
|
||||
extern void image_drawImage8_fromData(agsurface_t *img, cgdata *cg, int x, int y, int w, int h);
|
||||
extern void image_drawImage16_fromData(agsurface_t *img, cgdata *cg, int x, int y, int w, int h);
|
||||
extern void image_drawRectangle(agsurface_t *dib, int x, int y, int w, int h, int col);
|
||||
extern void image_copyArea(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy);
|
||||
extern void image_copyAreaSP(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int col);
|
||||
extern void image_copyAreaSP16_shadow(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int lv);
|
||||
extern void image_copyAreaSP16_alphaBlend(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int col);
|
||||
extern void image_copyAreaSP16_alphaLevel(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int col);
|
||||
extern void image_copyAreaSP16_whiteLevel(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int col);
|
||||
extern void image_wrapColor(agsurface_t *dib, int sx, int sy, int w, int h, int col, int rate);
|
||||
extern void image_getPixel(agsurface_t *dib, int x, int y, Palette *cell);
|
||||
|
||||
extern agsurface_t* image_saveRegion(agsurface_t *dib, int x, int y, int w, int h);
|
||||
extern void image_putRegion(agsurface_t *dib, agsurface_t *dst, int x, int y);
|
||||
extern void image_restoreRegion(agsurface_t *dib, agsurface_t *dst, int x, int y);
|
||||
extern void image_copyRegion(agsurface_t *src, int sx, int sy, int w, int h, agsurface_t *dib, int dx, int dy);
|
||||
extern void image_delRegion(agsurface_t *r);
|
||||
|
||||
extern void image_getGlyphImage(agsurface_t *dib, agsurface_t *glyph, int dx, int dy, int col);
|
||||
extern void image_getGlyphImageNto8(agsurface_t *dib, agsurface_t *glyph, int dx, int dy, int col);
|
||||
extern void image_changeColorArea8(agsurface_t *dib, int sx, int sy, int w, int h, int src, int dst, int cnt);
|
||||
extern void image_get_glyph(agsurface_t *gls, agsurface_t *gld);
|
||||
extern void image_draw_antialiased_pattern(agsurface_t *dib, agsurface_t *pattern, int dx, int dy, int dw, int dh, int col);
|
||||
extern void image_draw_pattern(agsurface_t *dib, agsurface_t *pattern, int dx, int dy, int dw, int dh, int col);
|
||||
extern void image_trans_pixel_24to24p(agsurface_t *src, agsurface_t *dst);
|
||||
|
||||
#endif /* __XCORE_IMAGE__ */
|
||||
|
||||
@@ -1,354 +0,0 @@
|
||||
/*
|
||||
* xcore_input.c キー入力処理
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_input.c,v 1.13 2003/04/25 17:23:55 chikama Exp $ */
|
||||
|
||||
#include "key.h"
|
||||
#include <X11/keysym.h>
|
||||
#include "ags.h"
|
||||
|
||||
|
||||
boolean RawKeyInfo[256];
|
||||
static int convertKeyCode(unsigned int keycode);
|
||||
static void keyEventProsess(XKeyEvent *e);
|
||||
static void buttonEventProcess(XButtonEvent *e);
|
||||
|
||||
|
||||
static void keyEventProsess(XKeyEvent *e) {
|
||||
agsevent_t agse;
|
||||
boolean bool;
|
||||
int code = convertKeyCode(e->keycode);
|
||||
|
||||
if (e->type == KeyPress) {
|
||||
bool = TRUE;
|
||||
agse.type = AGSEVENT_KEY_PRESS;
|
||||
} else {
|
||||
bool = FALSE;
|
||||
agse.type = AGSEVENT_KEY_RELEASE;
|
||||
}
|
||||
|
||||
RawKeyInfo[code] = bool;
|
||||
|
||||
if (nact->ags.eventcb) {
|
||||
agse.d1 = e->x;
|
||||
agse.d2 = e->y;
|
||||
agse.d3 = code;
|
||||
nact->ags.eventcb(&agse);
|
||||
}
|
||||
}
|
||||
|
||||
static void buttonEventProcess(XButtonEvent *e) {
|
||||
agsevent_t agse;
|
||||
boolean bool;
|
||||
|
||||
if (e->type == ButtonPress) {
|
||||
bool = TRUE;
|
||||
agse.type = AGSEVENT_BUTTON_PRESS;
|
||||
} else {
|
||||
bool = FALSE;
|
||||
agse.type = AGSEVENT_BUTTON_RELEASE;
|
||||
}
|
||||
|
||||
switch(e->button) {
|
||||
case Button1:
|
||||
RawKeyInfo[KEY_MOUSE_LEFT] = bool;
|
||||
agse.d3 = AGSEVENT_BUTTON_LEFT;
|
||||
break;
|
||||
case Button2:
|
||||
RawKeyInfo[KEY_MOUSE_MIDDLE] = bool;
|
||||
agse.d3 = AGSEVENT_BUTTON_MID;
|
||||
break;
|
||||
case Button3:
|
||||
RawKeyInfo[KEY_MOUSE_RIGHT] = bool;
|
||||
agse.d3 = AGSEVENT_BUTTON_RIGHT;
|
||||
break;
|
||||
case Button4:
|
||||
agse.d3 = AGSEVENT_WHEEL_UP;
|
||||
break;
|
||||
case Button5:
|
||||
agse.d3 = AGSEVENT_WHEEL_DN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (nact->ags.eventcb) {
|
||||
agse.d1 = e->x;
|
||||
agse.d2 = e->y;
|
||||
nact->ags.eventcb(&agse);
|
||||
}
|
||||
}
|
||||
|
||||
static int convertKeyCode(unsigned int keycode) {
|
||||
KeySym sym = XkbKeycodeToKeysym(x11_display, keycode, 0, 0);
|
||||
switch(sym) {
|
||||
case XK_BackSpace:
|
||||
return KEY_BS;
|
||||
case XK_Tab:
|
||||
return KEY_TAB;
|
||||
case XK_Clear:
|
||||
return KEY_CLEAR;
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
return KEY_ENTER;
|
||||
case XK_Shift_L:
|
||||
case XK_Shift_R:
|
||||
return KEY_SHIFT;
|
||||
case XK_Control_L:
|
||||
case XK_Control_R:
|
||||
return KEY_CTRL;
|
||||
case XK_Alt_L:
|
||||
case XK_Alt_R:
|
||||
return KEY_ALT;
|
||||
case XK_Pause:
|
||||
return KEY_PAUSE;
|
||||
case XK_Caps_Lock:
|
||||
return KEY_CAPSLOCK;
|
||||
case XK_Kanji:
|
||||
return KEY_KANAKAN;
|
||||
case XK_Escape :
|
||||
return KEY_ESC;
|
||||
case XK_space:
|
||||
return KEY_SPACE;
|
||||
case XK_Page_Up:
|
||||
return KEY_PAGEUP;
|
||||
case XK_Page_Down:
|
||||
return KEY_PAGEDOWN;
|
||||
case XK_End:
|
||||
return KEY_END;
|
||||
case XK_Home:
|
||||
return KEY_HOME;
|
||||
case XK_Left:
|
||||
return KEY_LEFT;
|
||||
case XK_Up:
|
||||
return KEY_UP;
|
||||
case XK_Right:
|
||||
return KEY_RIGHT;
|
||||
case XK_Down:
|
||||
return KEY_DOWN;
|
||||
case XK_Select:
|
||||
return KEY_SELECT;
|
||||
case XK_Execute:
|
||||
return KEY_EXECUTE;
|
||||
case XK_Print:
|
||||
return KEY_PRINTSCREEN;
|
||||
case XK_Insert:
|
||||
return KEY_INS;
|
||||
case XK_Delete:
|
||||
return KEY_DEL;
|
||||
case XK_Help:
|
||||
return KEY_HELP;
|
||||
case XK_0:
|
||||
return KEY_0;
|
||||
case XK_1:
|
||||
return KEY_1;
|
||||
case XK_2:
|
||||
return KEY_2;
|
||||
case XK_3:
|
||||
return KEY_3;
|
||||
case XK_4:
|
||||
return KEY_4;
|
||||
case XK_5:
|
||||
return KEY_5;
|
||||
case XK_6:
|
||||
return KEY_6;
|
||||
case XK_7:
|
||||
return KEY_7;
|
||||
case XK_8:
|
||||
return KEY_8;
|
||||
case XK_9:
|
||||
return KEY_9;
|
||||
case XK_a:
|
||||
case XK_A:
|
||||
return KEY_A;
|
||||
case XK_b:
|
||||
case XK_B:
|
||||
return KEY_B;
|
||||
case XK_c:
|
||||
case XK_C:
|
||||
return KEY_C;
|
||||
case XK_d:
|
||||
case XK_D:
|
||||
return KEY_D;
|
||||
case XK_e:
|
||||
case XK_E:
|
||||
return KEY_E;
|
||||
case XK_f:
|
||||
case XK_F:
|
||||
return KEY_F;
|
||||
case XK_g:
|
||||
case XK_G:
|
||||
return KEY_G;
|
||||
case XK_h:
|
||||
case XK_H:
|
||||
return KEY_H;
|
||||
case XK_i:
|
||||
case XK_I:
|
||||
return KEY_I;
|
||||
case XK_j:
|
||||
case XK_J:
|
||||
return KEY_J;
|
||||
case XK_k:
|
||||
case XK_K:
|
||||
return KEY_K;
|
||||
case XK_l:
|
||||
case XK_L:
|
||||
return KEY_L;
|
||||
case XK_m:
|
||||
case XK_M:
|
||||
return KEY_M;
|
||||
case XK_n:
|
||||
case XK_N:
|
||||
return KEY_N;
|
||||
case XK_o:
|
||||
case XK_O:
|
||||
return KEY_O;
|
||||
case XK_p:
|
||||
case XK_P:
|
||||
return KEY_P;
|
||||
case XK_q:
|
||||
case XK_Q:
|
||||
return KEY_Q;
|
||||
case XK_r:
|
||||
case XK_R:
|
||||
return KEY_R;
|
||||
case XK_s:
|
||||
case XK_S:
|
||||
return KEY_S;
|
||||
case XK_t:
|
||||
case XK_T:
|
||||
return KEY_T;
|
||||
case XK_u:
|
||||
case XK_U:
|
||||
return KEY_U;
|
||||
case XK_v:
|
||||
case XK_V:
|
||||
return KEY_V;
|
||||
case XK_w:
|
||||
case XK_W:
|
||||
return KEY_W;
|
||||
case XK_x:
|
||||
case XK_X:
|
||||
return KEY_X;
|
||||
case XK_y:
|
||||
case XK_Y:
|
||||
return KEY_Y;
|
||||
case XK_z:
|
||||
case XK_Z:
|
||||
return KEY_Z;
|
||||
case XK_KP_Insert:
|
||||
case XK_KP_0:
|
||||
return KEY_PAD_0;
|
||||
case XK_KP_End:
|
||||
case XK_KP_1:
|
||||
return KEY_PAD_1;
|
||||
case XK_KP_Down:
|
||||
case XK_KP_2:
|
||||
return KEY_PAD_2;
|
||||
case XK_KP_Page_Down:
|
||||
case XK_KP_3:
|
||||
return KEY_PAD_3;
|
||||
case XK_KP_Left:
|
||||
case XK_KP_4:
|
||||
return KEY_PAD_4;
|
||||
case XK_KP_5:
|
||||
return KEY_PAD_5;
|
||||
case XK_KP_Right:
|
||||
case XK_KP_6:
|
||||
return KEY_PAD_6;
|
||||
case XK_KP_Home:
|
||||
case XK_KP_7:
|
||||
return KEY_PAD_7;
|
||||
case XK_KP_Up:
|
||||
case XK_KP_8:
|
||||
return KEY_PAD_8;
|
||||
case XK_KP_Page_Up:
|
||||
case XK_KP_9:
|
||||
return KEY_PAD_9;
|
||||
case XK_KP_Multiply:
|
||||
return KEY_PAD_STAR;
|
||||
case XK_KP_Add:
|
||||
return KEY_PAD_PLUS;
|
||||
case XK_KP_Separator:
|
||||
return KEY_PAD_SEP;
|
||||
case XK_KP_Subtract:
|
||||
return KEY_PAD_MINUS;
|
||||
case XK_KP_Delete:
|
||||
return KEY_PAD_DOT;
|
||||
case XK_KP_Divide:
|
||||
return KEY_PAD_SLASH;
|
||||
case XK_F1:
|
||||
return KEY_F1;
|
||||
case XK_F2:
|
||||
return KEY_F2;
|
||||
case XK_F3:
|
||||
return KEY_F3;
|
||||
case XK_F4:
|
||||
return KEY_F4;
|
||||
case XK_F5:
|
||||
return KEY_F5;
|
||||
case XK_F6:
|
||||
return KEY_F6;
|
||||
case XK_F7:
|
||||
return KEY_F7;
|
||||
case XK_F8:
|
||||
return KEY_F8;
|
||||
case XK_F9:
|
||||
return KEY_F9;
|
||||
case XK_F10:
|
||||
return KEY_F10;
|
||||
case XK_F11:
|
||||
return KEY_F11;
|
||||
case XK_F12:
|
||||
return KEY_F12;
|
||||
case XK_F13:
|
||||
return KEY_F13;
|
||||
case XK_F14:
|
||||
return KEY_F14;
|
||||
case XK_F15:
|
||||
return KEY_F15;
|
||||
case XK_F16:
|
||||
return KEY_F16;
|
||||
case XK_F17:
|
||||
return KEY_F17;
|
||||
case XK_F18:
|
||||
return KEY_F18;
|
||||
case XK_F19:
|
||||
return KEY_F19;
|
||||
case XK_F20:
|
||||
return KEY_F20;
|
||||
case XK_F21:
|
||||
return KEY_F21;
|
||||
case XK_F22:
|
||||
return KEY_F22;
|
||||
case XK_F23:
|
||||
return KEY_F23;
|
||||
case XK_F24:
|
||||
return KEY_F24;
|
||||
case XK_Num_Lock:
|
||||
return KEY_NUMLOCK;
|
||||
case XK_Scroll_Lock:
|
||||
return KEY_SCROLL_LOCK;
|
||||
default:
|
||||
return KEY_UNDEFINED;
|
||||
}
|
||||
return KEY_UNDEFINED;
|
||||
}
|
||||
@@ -1,372 +0,0 @@
|
||||
/*
|
||||
* xcore_maskupdate.c X11 mask 付き update
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_maskupdate.c,v 1.4 2002/05/02 17:21:32 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "xcore_private.h"
|
||||
|
||||
static Pixmap maskpix; /* clipmask 用 Bitmap */
|
||||
static Pixmap clippix; /* copy 元 Pixmap */
|
||||
static Pixmap savepix; /* copy 先 Pixmap */
|
||||
static Pixmap doublepix;/* double buffer 用 Pixmap */
|
||||
static GC maskgc; /* clipmask Bitmap 用 GC */
|
||||
|
||||
static void draw_5star(double mul, double rad, int off_x, int off_y);
|
||||
static void draw_6star(double mul, double rad, int off_x, int off_y);
|
||||
static void draw_windwheel_90(double rad, int r, int off_x, int off_y);
|
||||
static void draw_windwheel_180(double rad, int r, int off_x, int off_y);
|
||||
static void draw_windwheel_360(double rad, int r, int off_x, int off_y);
|
||||
|
||||
/*
|
||||
* 五芒星を描く
|
||||
* mul : 倍率 (1 で 100 * 100) の星が描かれる
|
||||
* rad : 回転角度(radian)
|
||||
* off_x: 中心座標の x 方向 offset
|
||||
* off_y: 中心座標の y 方向 offset
|
||||
*/
|
||||
static void draw_5star(double mul, double rad, int off_x, int off_y) {
|
||||
static XPoint pt[] = {
|
||||
{ 0, -50},
|
||||
{-29, 40},
|
||||
{ 47, -15},
|
||||
{-47, -15},
|
||||
{ 29, 40}
|
||||
};
|
||||
XPoint p[5];
|
||||
int i;
|
||||
|
||||
/*
|
||||
* x' cos(X) -sin(X) mul 0 x
|
||||
* = * *
|
||||
* y' sin(X) cos(X) 0 mul y
|
||||
*/
|
||||
for (i = 0; i < 5; i++) {
|
||||
p[i].x = mul * (pt[i].x * cos(rad) - pt[i].y * sin(rad)) + off_x;
|
||||
p[i].y = mul * (pt[i].x * sin(rad) + pt[i].y * cos(rad)) + off_y;
|
||||
}
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 5, Complex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
/*
|
||||
* 六芒星を描く
|
||||
* mul : 倍率 (1 で 100 * 100) の星が描かれる
|
||||
* rad : 回転角度(radian)
|
||||
* off_x: 中心座標の x 方向 offset
|
||||
* off_y: 中心座標の y 方向 offset
|
||||
*/
|
||||
static void draw_6star(double mul, double rad, int off_x, int off_y) {
|
||||
static XPoint pt1[] = {
|
||||
{ 0, -50},
|
||||
{-43, 25},
|
||||
{ 43, 25}
|
||||
};
|
||||
static XPoint pt2[] = {
|
||||
{-43, -25},
|
||||
{ 0, 50},
|
||||
{ 43, -25}
|
||||
};
|
||||
XPoint p[3];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
p[i].x = mul * (pt1[i].x * cos(rad) - pt1[i].y * sin(rad)) + off_x;
|
||||
p[i].y = mul * (pt1[i].x * sin(rad) + pt1[i].y * cos(rad)) + off_y;
|
||||
}
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
p[i].x = mul * (pt2[i].x * cos(rad) - pt2[i].y * sin(rad)) + off_x;
|
||||
p[i].y = mul * (pt2[i].x * sin(rad) + pt2[i].y * cos(rad)) + off_y;
|
||||
}
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
/*
|
||||
* 扇型の中心角 (てきとー)
|
||||
* 0.2 radian
|
||||
*/
|
||||
#define WHEELDELTA 0.2
|
||||
|
||||
/*
|
||||
* 風車90°
|
||||
* rad : 回転角 (radian) 0 - pi/2
|
||||
* r : 半径
|
||||
* off_x: 中心座標の x 方向 offset
|
||||
* off_y: 中心座標の y 方向 offset
|
||||
*/
|
||||
static void draw_windwheel_90(double rad, int r, int off_x, int off_y) {
|
||||
XPoint p[3];
|
||||
|
||||
p[0].x = 0 + off_x;
|
||||
p[0].y = 0 + off_y;
|
||||
|
||||
p[1].x = r * sin(rad) + off_x;
|
||||
p[1].y = -r * cos(rad) + off_y;
|
||||
|
||||
p[2].x = r * sin(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = -r * cos(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
|
||||
p[1].x = r * cos(rad) + off_x;
|
||||
p[1].y = r * sin(rad) + off_y;
|
||||
|
||||
p[2].x = r * cos(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = r * sin(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
|
||||
p[1].x = -r * sin(rad) + off_x;
|
||||
p[1].y = r * cos(rad) + off_y;
|
||||
|
||||
p[2].x = -r * sin(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = r * cos(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
p[1].x = -r * cos(rad) + off_x;
|
||||
p[1].y = -r * sin(rad) + off_y;
|
||||
|
||||
p[2].x = -r * cos(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = -r * sin(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
/*
|
||||
* 風車180°
|
||||
* rad : 回転角 (radian) 0 - pi
|
||||
* r : 半径
|
||||
* off_x: 中心座標の x 方向 offset
|
||||
* off_y: 中心座標の y 方向 offset
|
||||
*/
|
||||
static void draw_windwheel_180(double rad, int r, int off_x, int off_y) {
|
||||
XPoint p[3];
|
||||
|
||||
p[0].x = 0 + off_x;
|
||||
p[0].y = 0 + off_y;
|
||||
|
||||
|
||||
p[1].x = -r * cos(rad) + off_x;
|
||||
p[1].y = -r * sin(rad) + off_y;
|
||||
|
||||
p[2].x = -r * cos(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = -r * sin(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
|
||||
p[1].x = r * cos(rad) + off_x;
|
||||
p[1].y = r * sin(rad) + off_y;
|
||||
|
||||
p[2].x = r * cos(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = r * sin(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
}
|
||||
|
||||
/*
|
||||
* 風車180°
|
||||
* rad : 回転角 (radian) 0 - 2pi
|
||||
* r : 半径
|
||||
* off_x: 中心座標の x 方向 offset
|
||||
* off_y: 中心座標の y 方向 offset
|
||||
*/
|
||||
static void draw_windwheel_360(double rad, int r, int off_x, int off_y) {
|
||||
XPoint p[3];
|
||||
|
||||
p[0].x = 0 + off_x;
|
||||
p[0].y = 0 + off_y;
|
||||
|
||||
p[1].x = -r * cos(rad) + off_x;
|
||||
p[1].y = -r * sin(rad) + off_y;
|
||||
|
||||
p[2].x = -r * cos(rad + WHEELDELTA) + off_x;
|
||||
p[2].y = -r * sin(rad + WHEELDELTA) + off_y;
|
||||
|
||||
XFillPolygon(x11_display, maskpix, maskgc, p, 3, Convex, CoordModeOrigin);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* マスク付き領域更新
|
||||
* sx: コピー元 x 座標
|
||||
* sy: コピー元 y 座標
|
||||
* w : コピー元 width
|
||||
* h : コピー元 height
|
||||
* dx: コピー先 x 座標
|
||||
* dy: コピー先 y 座標
|
||||
* func: マスク種類
|
||||
* 44: 五芒星(内->外)
|
||||
* 45: 五芒星(外->内)
|
||||
* 46: 六芒星(内->外)
|
||||
* 47: 六芒星(外->内)
|
||||
* 50: 風車90°
|
||||
* 51: 風車180°
|
||||
* 52: 風車360°
|
||||
* step: 呼び出し番号 0 - 256
|
||||
*/
|
||||
void Xcore_maskupdate(int sx, int sy, int w, int h, int dx, int dy, int func, int step) {
|
||||
GC gc;
|
||||
|
||||
dx -= view_x;
|
||||
dy -= view_y;
|
||||
|
||||
if (step == 0) {
|
||||
/* 最初にいろいろと準備 */
|
||||
XSync(x11_display, False);
|
||||
/* コピー元を DIB から pixmap に持って来る */
|
||||
clippix = x11_clip_from_DIB(sx, sy, w, h);
|
||||
|
||||
/* clip mask 用 Pixmap の生成 */
|
||||
maskpix = XCreatePixmap(x11_display, x11_window, w, h, 1);
|
||||
maskgc = XCreateGC(x11_display, maskpix, None, NULL);
|
||||
|
||||
/* clipmask 用 Pixmap の初期化 */
|
||||
XSetForeground(x11_display, maskgc, 0);
|
||||
XFillRectangle(x11_display, maskpix, maskgc, 0, 0, w, h);
|
||||
|
||||
/* 線が交差するときの塗りつぶしのルールを設定 */
|
||||
XSetFillRule(x11_display, maskgc, WindingRule);
|
||||
|
||||
/* 更新先の Window の領域を保存 */
|
||||
savepix = XCreatePixmap(x11_display, x11_window, w, h, WIN_DEPTH);
|
||||
XCopyArea(x11_display, x11_window, savepix, x11_gc_pix,
|
||||
winoffset_x + dx, winoffset_y + dy, w, h, 0, 0);
|
||||
|
||||
/* ダブルバッファ用に Pixmap を確保 */
|
||||
doublepix = XCreatePixmap(x11_display, x11_window, w, h, WIN_DEPTH);
|
||||
XCopyArea(x11_display, x11_window, doublepix, x11_gc_pix,
|
||||
winoffset_x + dx, winoffset_y + dy, w, h, 0, 0);
|
||||
|
||||
XSync(x11_display, False);
|
||||
return;
|
||||
} else if (step == 256) {
|
||||
/* 最後に後始末 */
|
||||
#if 0
|
||||
XCopyArea(x11_display, clippix, x11_window, x11_gc_pix,
|
||||
0, 0, w, h, winoffset_x + dx, winoffset_y + dy);
|
||||
#endif
|
||||
#if 0
|
||||
XCopyArea(x11_display, clippix, x11_pixmap, x11_gc_pix,
|
||||
0, 0, w, h, winoffset_x + dx, winoffset_y + dy);
|
||||
ags_updateFull();
|
||||
#endif
|
||||
ags_copyArea(sx, sy, w, h, dx + view_x, dy + view_y);
|
||||
ags_updateArea(dx + view_x, dy + view_y, w, h);
|
||||
XFreePixmap(x11_display, maskpix);
|
||||
|
||||
XFreePixmap(x11_display, clippix);
|
||||
XFreePixmap(x11_display, savepix);
|
||||
XFreePixmap(x11_display, doublepix);
|
||||
XFreeGC(x11_display, maskgc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* clipmask 用の GC を生成 (毎回生成しなくても良いかも?) */
|
||||
gc = XCreateGC(x11_display, clippix, None, NULL);
|
||||
XSetClipMask(x11_display, gc, maskpix);
|
||||
XSetClipOrigin(x11_display, gc, 0, 0);
|
||||
|
||||
switch(func) {
|
||||
case 44:
|
||||
case 46:
|
||||
/* 内から外へ */
|
||||
XSetForeground(x11_display, maskgc, 0);
|
||||
XFillRectangle(x11_display, maskpix, maskgc, 0, 0, w, h);
|
||||
XSetForeground(x11_display, maskgc, 1);
|
||||
break;
|
||||
case 45:
|
||||
case 47:
|
||||
/* 外から内へ */
|
||||
XSetForeground(x11_display, maskgc, 1);
|
||||
XFillRectangle(x11_display, maskpix, maskgc, 0, 0, w, h);
|
||||
XSetForeground(x11_display, maskgc, 0);
|
||||
break;
|
||||
default:
|
||||
XSetForeground(x11_display, maskgc, 1);
|
||||
}
|
||||
|
||||
/* mask を描画 */
|
||||
switch(func) {
|
||||
case 44:
|
||||
draw_5star(1.5 * (max(w,h) * step) / (256 * 50.0),
|
||||
1.0 * M_PI * step / 256, w/2, h/2);
|
||||
break;
|
||||
|
||||
case 45:
|
||||
draw_5star(1.5 * (max(w,h) * (256-step)) / (256 * 50.0),
|
||||
1.0 * M_PI * step / 256, w/2, h/2);
|
||||
break;
|
||||
|
||||
case 46:
|
||||
draw_6star((max(w,h) * step) / (256 * 50.0),
|
||||
1.0 * M_PI * step / 256, w/2, h/2);
|
||||
break;
|
||||
|
||||
case 47:
|
||||
draw_6star((max(w,h) * (256-step)) / (256 * 50.0),
|
||||
1.0 * M_PI * step / 256, w/2, h/2);
|
||||
break;
|
||||
|
||||
case 50:
|
||||
draw_windwheel_90(0.5 * M_PI * step / 256, sqrt(w*w+h*h)/2,
|
||||
w/2, h/2);
|
||||
break;
|
||||
case 51:
|
||||
draw_windwheel_180(1.0 * M_PI * step / 256, sqrt(w*w+h*h)/2,
|
||||
w/2, h/2);
|
||||
break;
|
||||
case 52:
|
||||
draw_windwheel_360(2.0 * M_PI * step / 256, sqrt(w*w+h*h)/2,
|
||||
w/2, h/2);
|
||||
break;
|
||||
}
|
||||
|
||||
/* double buffer へ 保存した window の内容をコピー */
|
||||
XCopyArea(x11_display, savepix, doublepix, x11_gc_win,
|
||||
0, 0, w, h, 0, 0);
|
||||
|
||||
/* コピー元の内容を mask付きで double buffer へコピー */
|
||||
XCopyArea(x11_display, clippix, doublepix, gc,
|
||||
0, 0, w, h, 0, 0);
|
||||
|
||||
/* double buffer から window へコピー */
|
||||
XCopyArea(x11_display, doublepix, x11_window, x11_gc_win,
|
||||
0, 0, w, h, winoffset_x + dx, winoffset_y + dy);
|
||||
|
||||
/* 同期 */
|
||||
XSync(x11_display, False);
|
||||
|
||||
/* clipmask 用 gc の破棄 */
|
||||
XFreeGC(x11_display, gc);
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* xcore_mode.c X11 video mode and full-screen
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_mode.c,v 1.7 2003/01/31 12:58:28 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef HAVE_XF86VMODE
|
||||
# include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "xcore.h"
|
||||
#include "xcore_private.h"
|
||||
|
||||
#ifdef HAVE_XF86VMODE
|
||||
static int vm_count;
|
||||
static XF86VidModeModeInfo **vm_modelines;
|
||||
#endif
|
||||
static boolean have_vm;
|
||||
|
||||
void x11_vm_init(void) {
|
||||
#ifdef HAVE_XF86VMODE
|
||||
int foo, bar, i, ma, mi;
|
||||
|
||||
if (XF86VidModeQueryExtension(x11_display, &foo, &bar)) {
|
||||
XF86VidModeQueryVersion(x11_display, &ma, &mi);
|
||||
|
||||
NOTICE("VidMode version %d.%d\n", ma, mi);
|
||||
have_vm = TRUE;
|
||||
|
||||
XF86VidModeGetAllModeLines(x11_display, XDefaultScreen(x11_display),
|
||||
&vm_count, &vm_modelines);
|
||||
NOTICE(" available video mode(s):");
|
||||
for (i = 0; i < vm_count; i++) {
|
||||
NOTICE(" %dx%d",
|
||||
vm_modelines[i]->hdisplay, vm_modelines[i]->vdisplay);
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void x11_vm_exit() {
|
||||
#ifdef HAVE_XF86VMODE
|
||||
if (x11_fs_on) {
|
||||
XF86VidModeSwitchToMode(x11_display, XDefaultScreen(x11_display),
|
||||
vm_modelines[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static int search_preferable_fullscreen_mode() {
|
||||
#ifdef HAVE_XF86VMODE
|
||||
int i, vm = 0, delta = INT_MAX;
|
||||
|
||||
/* すべてのmodeのなかで最も適切なモードを選択 */
|
||||
for (i = 0; i < vm_count; i++) {
|
||||
if (vm_modelines[i]->hdisplay >= view_w &&
|
||||
vm_modelines[i]->vdisplay >= view_y) {
|
||||
int deltaw = vm_modelines[i]->hdisplay - view_w;
|
||||
int deltah = vm_modelines[i]->vdisplay - view_h;
|
||||
if (delta > (deltaw + deltah)) {
|
||||
vm = i;
|
||||
delta = deltaw + deltah;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vm;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void set_vidmode(int mode) {
|
||||
#ifdef HAVE_XF86VMODE
|
||||
XF86VidModeSwitchToMode(x11_display, DefaultScreen(x11_display), vm_modelines[mode]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Fullscreen 移行前の Window の座標 */
|
||||
static int winsave_x, winsave_y;
|
||||
|
||||
static void enter_fullscreen() {
|
||||
#ifdef HAVE_XF86VMODE
|
||||
int w, h, b, d;
|
||||
Window root;
|
||||
|
||||
XGetGeometry(x11_display, x11_window, &root, &winsave_x, &winsave_y,
|
||||
&w, &h, &b, &d);
|
||||
Xcore_setWindowSize(view_x, view_y, view_w, view_h);
|
||||
XSync(x11_display, False);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void quit_fullscreen() {
|
||||
#ifdef HAVE_XF86VMODE
|
||||
XF86VidModeSwitchToMode(x11_display, DefaultScreen(x11_display), vm_modelines[0]);
|
||||
XUngrabPointer(x11_display, CurrentTime);
|
||||
XMoveWindow(x11_display, x11_window, winsave_x, winsave_y);
|
||||
XSync(x11_display, False);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Xcore_fullScreen(boolean on) {
|
||||
if (!have_vm) return;
|
||||
|
||||
#if HAVE_XF86VMODE
|
||||
if (on && !x11_fs_on) {
|
||||
x11_fs_on = TRUE;
|
||||
enter_fullscreen();
|
||||
} else if (!on && x11_fs_on) {
|
||||
quit_fullscreen();
|
||||
x11_fs_on = FALSE;
|
||||
}
|
||||
XSync(x11_display, False);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Windowの大きさの変更 */
|
||||
void Xcore_setWindowSize(int x, int y, int width, int height) {
|
||||
|
||||
view_x = x;
|
||||
view_y = y;
|
||||
|
||||
if (width == view_w && height == view_h && !x11_fs_on) return;
|
||||
|
||||
view_w = width;
|
||||
view_h = height;
|
||||
|
||||
#ifdef HAVE_XF86VMODE
|
||||
if (x11_fs_on) {
|
||||
int mode = search_preferable_fullscreen_mode();
|
||||
NOTICE("width = %d, height = %d\n",
|
||||
vm_modelines[mode]->hdisplay,
|
||||
vm_modelines[mode]->vdisplay);
|
||||
if (vm_modelines[mode]->hdisplay != view_w ||
|
||||
vm_modelines[mode]->vdisplay != view_h) {
|
||||
winoffset_x = (vm_modelines[mode]->hdisplay - view_w)/2;
|
||||
winoffset_y = (vm_modelines[mode]->vdisplay - view_h)/2;
|
||||
width = vm_modelines[mode]->hdisplay;
|
||||
height = vm_modelines[mode]->vdisplay;
|
||||
XClearWindow(x11_display, x11_window);
|
||||
} else {
|
||||
winoffset_x = winoffset_y = 0;
|
||||
}
|
||||
XMoveWindow(x11_display, x11_window, 0, 0);
|
||||
set_vidmode(mode);
|
||||
XF86VidModeSetViewPort(x11_display, XDefaultScreen(x11_display), 0, 0);
|
||||
|
||||
XGrabPointer(x11_display, x11_window, True, 0,
|
||||
GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime);
|
||||
XSync(x11_display, False);
|
||||
}
|
||||
#endif
|
||||
|
||||
XResizeWindow(x11_display, x11_window, width, height);
|
||||
x11_makeWorkImage(width, height);
|
||||
XFlush(x11_display);
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* xcore_private.c X11 only private data
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_private.h,v 1.5 2003/06/29 15:28:12 chikama Exp $ */
|
||||
|
||||
#ifndef __XCORE_PRIVATE_H__
|
||||
#define __XCORE_PRIVATE_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "ags.h"
|
||||
#include "image.h"
|
||||
|
||||
struct _FONT;
|
||||
|
||||
/* dib/work image 情報 */
|
||||
typedef struct {
|
||||
XImage *ximg; /* XImage/ShmXImage 使用時の XImage */
|
||||
XShmSegmentInfo info; /* Shared Pixmap info */
|
||||
boolean shared; /* is Shared Pixmap ? */
|
||||
agsurface_t cimg; /* Common Image for image manupilate */
|
||||
} IMAGEINFO;
|
||||
|
||||
struct xcore_private_data {
|
||||
boolean local_X11; /* flag: TRUE if local display */
|
||||
Display *dsp; /* Used for event and window management */
|
||||
Visual *vis; /* Vidusl of Current Window */
|
||||
|
||||
Window win; /* Main Window */
|
||||
int win_depth; /* Main Window Depth */
|
||||
int winoffset_x; /* draw offset in Window x */
|
||||
int winoffset_y; /* y */
|
||||
|
||||
Atom atom_wmprot; /* window manager protocol atom */
|
||||
Atom atom_delwin; /* close-window protocol atom */
|
||||
|
||||
GC gc_win; /* The Graphics context for drawing to Window */
|
||||
|
||||
GC gc_pix; /* The Graphics context for drawing to Pixmap */
|
||||
Pixmap pix; /* Pixmap for offscreen image */
|
||||
|
||||
int dib_depth_candidate; /* DIB depth if required pixmap depth isnt 8 */
|
||||
|
||||
struct _FONT *fontinfo; /* font object */
|
||||
|
||||
boolean noSHM; /* dont have X-SHM extension */
|
||||
|
||||
boolean packed24bpp; /* window is packed 24 bpp? */
|
||||
|
||||
/* SharedPixmapを使用中にXの描画が入った場合 XSyncを発行するためのフラグ */
|
||||
boolean needSync;
|
||||
|
||||
boolean fullscreen; /* FullScreen Mode である */
|
||||
|
||||
IMAGEINFO *dib; /* DIB? information */
|
||||
int view_x;
|
||||
int view_y;
|
||||
int view_width;
|
||||
int view_height;
|
||||
|
||||
IMAGEINFO *work;
|
||||
|
||||
XColor col[256]; /* palette and color map */
|
||||
Colormap cm;
|
||||
};
|
||||
|
||||
extern void x11_init_cursor(void);
|
||||
extern void x11_makeWorkImage(int w, int h);
|
||||
extern void x11_vm_init(void);
|
||||
extern void x11_vm_exit(void);
|
||||
extern Pixmap x11_clip_from_DIB(int sx, int sy, int w, int h);
|
||||
|
||||
|
||||
extern struct xcore_private_data *x11_videodev;
|
||||
|
||||
#define local_X11 (x11_videodev->local_X11)
|
||||
#define x11_display (x11_videodev->dsp)
|
||||
#define x11_visual (x11_videodev->vis)
|
||||
#define x11_window (x11_videodev->win)
|
||||
#define winoffset_x (x11_videodev->winoffset_x)
|
||||
#define winoffset_y (x11_videodev->winoffset_y)
|
||||
#define atom_delwin (x11_videodev->atom_delwin)
|
||||
#define atom_wmprot (x11_videodev->atom_wmprot)
|
||||
#define x11_gc_win (x11_videodev->gc_win)
|
||||
#define x11_gc_pix (x11_videodev->gc_pix)
|
||||
#define x11_pixmap (x11_videodev->pix)
|
||||
#define dib_depth_candidate (x11_videodev->dib_depth_candidate)
|
||||
#define x11_font (x11_videodev->fontinfo)
|
||||
#define x11_noSHM (x11_videodev->noSHM)
|
||||
#define packed24bpp (x11_videodev->packed24bpp)
|
||||
#define x11_needSync (x11_videodev->needSync)
|
||||
#define x11_dibinfo (x11_videodev->dib)
|
||||
#define x11_workinfo (x11_videodev->work)
|
||||
#define view_x (x11_videodev->view_x)
|
||||
#define view_y (x11_videodev->view_y)
|
||||
#define view_w (x11_videodev->view_width)
|
||||
#define view_h (x11_videodev->view_height)
|
||||
#define x11_cm (x11_videodev->cm)
|
||||
#define x11_col (x11_videodev->col)
|
||||
#define x11_fs_on (x11_videodev->fullscreen)
|
||||
#define DRAW_BY_X (!x11_dibinfo->shared)
|
||||
#define DIB (&(x11_dibinfo->cimg))
|
||||
#define DIB_DEPTH (x11_dibinfo->cimg.depth)
|
||||
#define WIN_DEPTH (x11_videodev->win_depth)
|
||||
|
||||
#define WORK (&(x11_workinfo->cimg))
|
||||
|
||||
// #define WROK_DEPTH (x11_workinfo->cimg.depth)
|
||||
|
||||
#define PAL2PIC(i) image_index2pixel(DIB_DEPTH, i)
|
||||
|
||||
|
||||
#endif /* __XCORE_PRIVATE_H__ */
|
||||
@@ -1,528 +0,0 @@
|
||||
/*
|
||||
* xcore_video.c X11 video init
|
||||
*
|
||||
* Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
|
||||
* 1998- <masaki-c@is.aist-nara.ac.jp>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
/* $Id: xcore_video.c,v 1.15 2003/06/29 15:28:12 chikama Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef X_LOCALE
|
||||
#include <X11/Xlocale.h>
|
||||
#else
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "font.h"
|
||||
#include "joystick.h"
|
||||
#include "xsystem35.h"
|
||||
#include "xcore.h"
|
||||
#include "xcore_private.h"
|
||||
|
||||
static void check_SHMext(void);
|
||||
static void check_packed24bpp(void);
|
||||
static void init_window(void);
|
||||
static void init_offscreen(void);
|
||||
static void releaseDIB(void);
|
||||
static void makeNonShmXImage(IMAGEINFO *simg, int w, int h, int depth);
|
||||
static boolean makeShmXImage(IMAGEINFO *simg, int w, int h, int depth);
|
||||
static void releaseNonShmXImage(IMAGEINFO *simg);
|
||||
static void releaseShmXImage(IMAGEINFO *simg);
|
||||
static void makeDIB(int w, int h, int depth);
|
||||
static void releaseWorkImage();
|
||||
|
||||
|
||||
struct xcore_private_data *x11_videodev;
|
||||
static boolean noshm;
|
||||
|
||||
/* init/remove */
|
||||
|
||||
int Xcore_Initilize(void) {
|
||||
char *display;
|
||||
|
||||
x11_videodev = calloc(1, sizeof(struct xcore_private_data));
|
||||
x11_noSHM = noshm;
|
||||
|
||||
/* locale init ( for no gtk option ) */
|
||||
if (setlocale(LC_ALL,"") == NULL) {
|
||||
if (setlocale(LC_ALL, "C") == NULL) {
|
||||
SYSERROR("locale not supported\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Open the X11 display */
|
||||
display = NULL; /* Get it from DISPLAY environment variable */
|
||||
|
||||
if ((strncmp(XDisplayName(display), ":", 1) == 0) ||
|
||||
(strncmp(XDisplayName(display), "unix:", 5) == 0)) {
|
||||
local_X11 = TRUE;
|
||||
} else {
|
||||
local_X11 = FALSE;
|
||||
}
|
||||
|
||||
x11_display = XOpenDisplay(NULL);
|
||||
if (x11_display == NULL) {
|
||||
SYSERROR("Can't Open Display\n");
|
||||
}
|
||||
|
||||
/* check packed 24 bpp */
|
||||
check_packed24bpp();
|
||||
|
||||
/* check SHM extension is avaibale */
|
||||
check_SHMext();
|
||||
|
||||
/* create toplevel window */
|
||||
init_window();
|
||||
|
||||
/* map window to display */
|
||||
XMapWindow(x11_display, x11_window);
|
||||
|
||||
/* discpriter init */
|
||||
//x11_selinfo.fd_x = ConnectionNumber(x11_display);
|
||||
|
||||
/* event mask */
|
||||
XSelectInput(x11_display, x11_window, ExposureMask |
|
||||
KeyPressMask | KeyReleaseMask |
|
||||
LeaveWindowMask | EnterWindowMask |
|
||||
ButtonPressMask | ButtonReleaseMask |
|
||||
// PointerMotionMask | PointerMotionHintMask);
|
||||
PointerMotionMask);
|
||||
/* ???? */
|
||||
XSetGraphicsExposures(x11_display, x11_gc_win, False);
|
||||
|
||||
/* create initial off-screen */
|
||||
init_offscreen();
|
||||
|
||||
/* Window title bar */
|
||||
XStoreName(x11_display, x11_window, "XSystem3.5 Version "VERSION);
|
||||
|
||||
/* wm hint */
|
||||
atom_wmprot = XInternAtom(x11_display, "WM_PROTOCOLS", False);
|
||||
atom_delwin = XInternAtom(x11_display, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(x11_display, x11_window, &atom_delwin, 1);
|
||||
|
||||
/* init cursor */
|
||||
x11_init_cursor();
|
||||
|
||||
/* final */
|
||||
XFlush(x11_display);
|
||||
|
||||
/* window size set */
|
||||
Xcore_setWindowSize(0, 0, SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* remove X */
|
||||
void Xcore_Remove(void) {
|
||||
if (x11_videodev == NULL) return;
|
||||
|
||||
if (x11_display != NULL) {
|
||||
NOTICE("Now X shutdown ... ");
|
||||
|
||||
x11_vm_exit();
|
||||
|
||||
if (x11_workinfo != NULL) {
|
||||
releaseWorkImage();
|
||||
}
|
||||
|
||||
if (x11_dibinfo != NULL) {
|
||||
releaseDIB();
|
||||
}
|
||||
XCloseDisplay(x11_display);
|
||||
|
||||
joy_close();
|
||||
|
||||
NOTICE("Done!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* SHMext を使用しないモードに設定 */
|
||||
void Xcore_setNoShmMode(void) {
|
||||
// x11_noSHM = TRUE;
|
||||
noshm = TRUE;
|
||||
}
|
||||
|
||||
/* SHMext が使用できるかチェック */
|
||||
static void check_SHMext(void) {
|
||||
int major, minor;
|
||||
Bool pixmaps;
|
||||
|
||||
#if defined(__osf__)
|
||||
x11_noSHM = TRUE; /* buggy X at least DIGITAL UNIX V4.0F */
|
||||
#endif
|
||||
|
||||
if (x11_noSHM) return;
|
||||
|
||||
if (local_X11) {
|
||||
x11_noSHM = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (False == XShmQueryVersion(x11_display, &major, &minor, &pixmaps)) {
|
||||
WARNING("MIT-SHMextension is not supported\n");
|
||||
goto errexit;
|
||||
}
|
||||
|
||||
if (False == pixmaps) {
|
||||
WARNING("SharedPixmap is not supported\n");
|
||||
goto errexit;
|
||||
}
|
||||
|
||||
if (ZPixmap != XShmPixmapFormat(x11_display)) {
|
||||
WARNING("SharedPixmap's format is not ZPixmap\n");
|
||||
goto errexit;
|
||||
}
|
||||
|
||||
x11_noSHM = FALSE;
|
||||
return;
|
||||
|
||||
errexit:
|
||||
x11_noSHM = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
static void check_packed24bpp(void) {
|
||||
XPixmapFormatValues *list;
|
||||
int i, cnt;
|
||||
|
||||
list = XListPixmapFormats(x11_display, &cnt);
|
||||
if (list == NULL) return;
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
if (list[i].depth == 24 && list[i].bits_per_pixel == 24) {
|
||||
packed24bpp = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
XFree(list);
|
||||
}
|
||||
|
||||
|
||||
/* create toplevel window */
|
||||
static void init_window(void) {
|
||||
int depth = DefaultDepth(x11_display, 0);
|
||||
boolean simple = FALSE;
|
||||
int attrib_mask;
|
||||
XSetWindowAttributes at;
|
||||
XVisualInfo vinfo;
|
||||
|
||||
memset(&at, 0, sizeof(at));
|
||||
|
||||
if (depth == 8) {
|
||||
/* 8bit の時 15/16/24bit True Color の visual を持っているか? */
|
||||
if (True == XMatchVisualInfo(x11_display, None, 16, TrueColor, &vinfo)) {
|
||||
WIN_DEPTH = 16;
|
||||
} else if (True == XMatchVisualInfo(x11_display, None, 15, TrueColor, &vinfo)) {
|
||||
WIN_DEPTH = 15;
|
||||
} else if (True == XMatchVisualInfo(x11_display, None, 24, TrueColor, &vinfo)) {
|
||||
WIN_DEPTH = 24;
|
||||
} else if (True == XMatchVisualInfo(x11_display, None, 8, PseudoColor, &vinfo)) {
|
||||
WIN_DEPTH = 8;
|
||||
simple = TRUE;
|
||||
} else {
|
||||
SYSERROR("No required Visual\n");
|
||||
}
|
||||
} else {
|
||||
simple = TRUE;
|
||||
if (False == XMatchVisualInfo(x11_display, None, depth, TrueColor, &vinfo)) {
|
||||
SYSERROR("No required Visual\n");
|
||||
}
|
||||
WIN_DEPTH = depth;
|
||||
}
|
||||
|
||||
x11_visual = vinfo.visual;
|
||||
|
||||
if (simple) {
|
||||
x11_window = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0),
|
||||
0, 0,
|
||||
SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT,
|
||||
0, 0, 0);
|
||||
/* colormap */
|
||||
if (x11_visual->class == PseudoColor) {
|
||||
x11_cm = XCreateColormap(x11_display, RootWindow(x11_display,0), x11_visual, AllocAll);
|
||||
XSetWindowColormap(x11_display, x11_window, x11_cm);
|
||||
} else {
|
||||
x11_cm = DefaultColormap(x11_display, 0);
|
||||
}
|
||||
/* backing store */
|
||||
at.backing_store = WhenMapped;
|
||||
XChangeWindowAttributes(x11_display, x11_window, CWBackingStore, &at);
|
||||
} else {
|
||||
XVisualInfo *vinfo_g;
|
||||
int vinfo_n;
|
||||
|
||||
vinfo.depth = WIN_DEPTH;
|
||||
vinfo_g = XGetVisualInfo(x11_display, VisualDepthMask | VisualClassMask| VisualRedMaskMask, &vinfo, &vinfo_n);
|
||||
if (vinfo_g == NULL) {
|
||||
SYSERROR("No required Visual\n");
|
||||
}
|
||||
x11_visual = vinfo_g->visual;
|
||||
XFree(vinfo_g);
|
||||
|
||||
at.background_pixel = BlackPixel (x11_display, 0);
|
||||
at.border_pixel = BlackPixel (x11_display, 0);
|
||||
at.backing_store = WhenMapped;
|
||||
attrib_mask = CWBorderPixel | CWBackPixel | CWColormap | CWBackingStore;
|
||||
x11_cm = at.colormap = XCreateColormap(x11_display, RootWindow(x11_display, 0), x11_visual, AllocNone);
|
||||
x11_window = XCreateWindow(x11_display, RootWindow(x11_display, 0),
|
||||
0, 0, SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT,
|
||||
0, WIN_DEPTH,
|
||||
InputOutput, x11_visual, attrib_mask, &at);
|
||||
}
|
||||
|
||||
/* determin dib depth candidate */
|
||||
dib_depth_candidate = (depth == 16 && vinfo.red_mask == 0x7c00) ? 15: WIN_DEPTH;
|
||||
|
||||
/* create graphic context for window */
|
||||
x11_gc_win = XCreateGC(x11_display, x11_window, 0, 0);
|
||||
|
||||
/* for fullscreen window init */
|
||||
x11_vm_init();
|
||||
|
||||
}
|
||||
|
||||
static void init_offscreen(void) {
|
||||
makeDIB(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT, SYS35_DEFAULT_DEPTH);
|
||||
|
||||
x11_makeWorkImage(SYS35_DEFAULT_WIDTH, SYS35_DEFAULT_HEIGHT);
|
||||
}
|
||||
|
||||
/* OffScreenImageに関する情報の解放 */
|
||||
static void releaseDIB(void) {
|
||||
XFreePixmap(x11_display, x11_pixmap);
|
||||
XFreeGC(x11_display, x11_gc_pix);
|
||||
|
||||
if (x11_dibinfo->shared) {
|
||||
releaseShmXImage(x11_dibinfo);
|
||||
} else {
|
||||
releaseNonShmXImage(x11_dibinfo);
|
||||
}
|
||||
}
|
||||
|
||||
static void makeNonShmXImage(IMAGEINFO *simg, int w, int h, int depth) {
|
||||
simg->ximg = XCreateImage(x11_display, x11_visual, depth, ZPixmap, 0, NULL, w, h, packed24bpp ? 8 : 32, 0);
|
||||
|
||||
/* XXXX */
|
||||
if (depth == 32 && packed24bpp) {
|
||||
simg->ximg->bytes_per_line = w * 4;
|
||||
}
|
||||
|
||||
if (NULL == (simg->ximg->data = malloc(simg->ximg->bytes_per_line * h))) {
|
||||
NOMEMERR();
|
||||
}
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
simg->ximg->byte_order = MSBFirst;
|
||||
#else
|
||||
simg->ximg->byte_order = LSBFirst;
|
||||
#endif
|
||||
}
|
||||
|
||||
static boolean makeShmXImage(IMAGEINFO *simg, int w, int h, int depth) {
|
||||
simg->ximg = XShmCreateImage(x11_display, x11_visual, depth, ZPixmap, NULL, &simg->info, w, h);
|
||||
|
||||
if ((simg->info.shmid = shmget(IPC_PRIVATE,
|
||||
simg->ximg->bytes_per_line * h,
|
||||
IPC_CREAT | 0666)) < 0) {
|
||||
WARNING("shmget: size:%x %s\n",
|
||||
simg->ximg->bytes_per_line * h, strerror(errno));
|
||||
XDestroyImage(simg->ximg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((char *)-1 == (simg->info.shmaddr = simg->ximg->data = shmat(simg->info.shmid, 0, 0))) {
|
||||
SYSERROR("shmat: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
simg->info.readOnly = False;
|
||||
XShmAttach(x11_display, &simg->info);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void releaseNonShmXImage(IMAGEINFO *simg) {
|
||||
XDestroyImage(simg->ximg);
|
||||
}
|
||||
|
||||
static void releaseShmXImage(IMAGEINFO *simg) {
|
||||
XShmDetach(x11_display, &simg->info);
|
||||
XDestroyImage(simg->ximg);
|
||||
|
||||
if (0 > shmdt(simg->info.shmaddr)) {
|
||||
SYSERROR("shmdt: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (0 > shmctl(simg->info.shmid, IPC_RMID, 0)) {
|
||||
SYSERROR("shmctl: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
static void makeDIB(int w, int h, int depth) {
|
||||
static boolean alloced = FALSE;
|
||||
|
||||
if (WIN_DEPTH == 8 && depth != 8) {
|
||||
SYSERROR("You cannot play highcolor game in 256 color mode\n");
|
||||
}
|
||||
|
||||
if (alloced) {
|
||||
releaseDIB();
|
||||
free(x11_dibinfo);
|
||||
}
|
||||
|
||||
x11_dibinfo = malloc(sizeof(IMAGEINFO));
|
||||
|
||||
if (depth != 8) {
|
||||
depth = dib_depth_candidate;
|
||||
}
|
||||
|
||||
if (x11_noSHM ||
|
||||
packed24bpp ||
|
||||
depth != WIN_DEPTH ||
|
||||
!makeShmXImage(x11_dibinfo, w, h, depth)) {
|
||||
makeNonShmXImage(x11_dibinfo, w, h, packed24bpp ? 32 : depth);
|
||||
x11_pixmap = XCreatePixmap(x11_display, x11_window, w, h, WIN_DEPTH);
|
||||
x11_dibinfo->shared = FALSE;
|
||||
} else {
|
||||
x11_pixmap = XShmCreatePixmap(x11_display, x11_window, x11_dibinfo->ximg->data, &x11_dibinfo->info, w, h, depth);
|
||||
x11_dibinfo->shared = TRUE;
|
||||
}
|
||||
|
||||
x11_gc_pix = XCreateGC(x11_display, x11_pixmap, 0, 0);
|
||||
|
||||
x11_dibinfo->cimg.width = w;
|
||||
x11_dibinfo->cimg.height = h;
|
||||
x11_dibinfo->cimg.pixel = x11_dibinfo->ximg->data;
|
||||
x11_dibinfo->cimg.bytes_per_line = x11_dibinfo->ximg->bytes_per_line;
|
||||
x11_dibinfo->cimg.depth = depth;
|
||||
x11_dibinfo->cimg.bytes_per_pixel = (depth == 8 ? 1 :
|
||||
depth == 15 || depth == 16 ? 2 :
|
||||
depth == 24 || depth == 32 ? 4 : 1);
|
||||
x11_dibinfo->cimg.alpha = NULL;
|
||||
|
||||
image_setdepth(depth);
|
||||
xcore_image_setdepth(depth);
|
||||
alloced = TRUE;
|
||||
}
|
||||
|
||||
/* fader用のImageを解放 */
|
||||
static void releaseWorkImage() {
|
||||
if (x11_workinfo->shared) {
|
||||
releaseShmXImage(x11_workinfo);
|
||||
} else {
|
||||
releaseNonShmXImage(x11_workinfo);
|
||||
}
|
||||
}
|
||||
|
||||
/* fader/ecopy用のImageを確保 */
|
||||
void x11_makeWorkImage(int w, int h) {
|
||||
static boolean alloced = FALSE;
|
||||
|
||||
if (alloced) {
|
||||
releaseWorkImage();
|
||||
free(x11_workinfo);
|
||||
}
|
||||
|
||||
x11_workinfo = malloc(sizeof(IMAGEINFO));
|
||||
|
||||
if (x11_noSHM ||
|
||||
packed24bpp ||
|
||||
!makeShmXImage(x11_workinfo, w, h, WIN_DEPTH)) {
|
||||
makeNonShmXImage(x11_workinfo, w, h, WIN_DEPTH);
|
||||
x11_workinfo->shared = FALSE;
|
||||
} else {
|
||||
x11_workinfo->shared = TRUE;
|
||||
}
|
||||
|
||||
XSync(x11_display, False);
|
||||
|
||||
x11_workinfo->cimg.width = w;
|
||||
x11_workinfo->cimg.height = h;
|
||||
x11_workinfo->cimg.pixel = x11_workinfo->ximg->data;
|
||||
x11_workinfo->cimg.bytes_per_line = x11_workinfo->ximg->bytes_per_line;
|
||||
x11_workinfo->cimg.depth = x11_workinfo->ximg->depth;
|
||||
x11_workinfo->cimg.bytes_per_pixel = (WIN_DEPTH == 8 ? 1 :
|
||||
WIN_DEPTH == 15 || WIN_DEPTH == 16 ? 2 :
|
||||
WIN_DEPTH == 24 && packed24bpp ? 3 :
|
||||
WIN_DEPTH == 24 || WIN_DEPTH == 32 ? 4 : 1);
|
||||
x11_workinfo->cimg.alpha = NULL;
|
||||
|
||||
alloced = TRUE;
|
||||
}
|
||||
|
||||
void Xcore_setFontDevice(struct _FONT *f) {
|
||||
x11_font = f;
|
||||
}
|
||||
|
||||
/* name is UTF-8 */
|
||||
void Xcore_setWindowTitle(char *name) {
|
||||
XmbSetWMProperties (x11_display, x11_window,
|
||||
name, name, NULL, 0, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* offscreen の設定 */
|
||||
void Xcore_setWorldSize(int width, int height, int depth) {
|
||||
makeDIB(width, height, depth);
|
||||
Xcore_fillRectangle(0, 0, width, height, 0);
|
||||
XSync(x11_display, False);
|
||||
}
|
||||
|
||||
/* Windowの size と depth の取得 */
|
||||
void Xcore_getWindowInfo(DispInfo *info) {
|
||||
info->width = DisplayWidth(x11_display, 0);
|
||||
info->height = DisplayHeight(x11_display, 0);
|
||||
info->depth = WIN_DEPTH;
|
||||
}
|
||||
|
||||
/*
|
||||
DIBの取得
|
||||
SharedPixma / XImage / MemoryImageのいずれか
|
||||
*/
|
||||
agsurface_t *Xcore_getDIB(void) {
|
||||
return DIB;
|
||||
}
|
||||
|
||||
/* AutoRepeat の設定 */
|
||||
void Xcore_setAutoRepeat(boolean bool) {
|
||||
if (bool) {
|
||||
XAutoRepeatOn(x11_display);
|
||||
} else {
|
||||
XAutoRepeatOff(x11_display);
|
||||
}
|
||||
}
|
||||
+2
-19
@@ -5,20 +5,11 @@
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# 使用するフォントデバイスの選択
|
||||
# (x11,ft2,sdlが使用可能です)
|
||||
# (ft2,sdlが使用可能です)
|
||||
# font_device: sdl
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# 使用するフォントの指定 for x11
|
||||
# フォントサイズの場所を %d にするのを忘れないで下さい。
|
||||
#
|
||||
|
||||
font_mincho: -*-mincho-medium-r-normal--%d-0-0-0-c-0-jisx0208.1983-0,-*-mincho-medium-r-normal--%d-0-0-0-c-0-jisx0201.1976-0
|
||||
|
||||
font_gothic: -*-*-medium-r-normal--%d-*-*-*-c-*-jisx0208.1983-0,-*-*-medium-r-normal--%d-*-*-*-c-*-jisx0201.1976-0
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# 使用するフォントの指定 for FreeType / SDL_ttf
|
||||
# 使用するフォントの指定
|
||||
#
|
||||
|
||||
#ttfont_mincho: /usr/local/share/xsystem35/fonts/mincho.otf
|
||||
@@ -89,14 +80,6 @@ font_gothic: -*-*-medium-r-normal--%d-*-*-*-c-*-jisx0208.1983-0,-*-*-medium-r-no
|
||||
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# X の SharedMemoryExtension を使わない設定
|
||||
# Xdec(DigitalUNIX), Xpmac(LinuxPPC)で必要
|
||||
|
||||
#no_shm: Yes
|
||||
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# リソースファイルによるマウスカーソルの形状変更を無効にする
|
||||
# にする場合、以下を Yes にする (なにも指定しない場合は有効)
|
||||
|
||||
+5
-67
@@ -38,9 +38,7 @@
|
||||
# include <gtk/gtk.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SDL
|
||||
# include <SDL.h>
|
||||
#endif
|
||||
#include <SDL.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
@@ -94,16 +92,13 @@ static int debuglv = DEBUGLEVEL;
|
||||
static int audio_buffer_size = 0;
|
||||
|
||||
/* font name from rcfile */
|
||||
static char *fontname[FONTTYPEMAX];
|
||||
static char *fontname_tt[FONTTYPEMAX] = {DEFAULT_GOTHIC_TTF, DEFAULT_MINCHO_TTF};
|
||||
static char fontface[FONTTYPEMAX];
|
||||
|
||||
#ifdef ENABLE_SDLTTF
|
||||
#define DEFAULT_FONT_DEVICE FONT_SDLTTF
|
||||
#elif defined(ENABLE_SDL)
|
||||
#define DEFAULT_FONT_DEVICE FONT_FT2
|
||||
#else
|
||||
#define DEFAULT_FONT_DEVICE FONT_X11
|
||||
#define DEFAULT_FONT_DEVICE FONT_FT2
|
||||
#endif
|
||||
|
||||
static fontdev_t fontdev = DEFAULT_FONT_DEVICE;
|
||||
@@ -125,7 +120,6 @@ static void sys35_usage(boolean verbose) {
|
||||
puts("Usage: xsystem35 [OPTIONS]\n");
|
||||
puts("OPTIONS");
|
||||
puts(" -gamefile file : set game resource file to 'file'");
|
||||
puts(" -no-shm : don't use MIT-SHM (use in another display)");
|
||||
puts(" -devcd device : set cdrom device name to 'device'");
|
||||
puts(" -devmidi device: set midi device name to 'device'");
|
||||
|
||||
@@ -151,24 +145,15 @@ static void sys35_usage(boolean verbose) {
|
||||
#ifdef ENABLE_FT2
|
||||
puts(" -devfont ft2 : FreeType");
|
||||
#endif
|
||||
#ifdef ENABLE_X11FONT
|
||||
puts(" -devfont x11 : x11");
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SDLTTF
|
||||
puts(" : default is sdl");
|
||||
#elif defined(ENABLE_SDL)
|
||||
puts(" : default is ft2");
|
||||
#else
|
||||
puts(" : default is x11");
|
||||
puts(" : default is ft2");
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SDLTTF) || defined(ENABLE_FT2)
|
||||
puts(" -ttfont_mincho: set TrueType font for mincho");
|
||||
puts(" -ttfont_gothic: set TrueType font for mincho");
|
||||
#endif
|
||||
puts(" -font_mincho : set X11(gtk) font for mincho");
|
||||
puts(" -font_gothic : set X11(gtk) font for mincho");
|
||||
|
||||
#ifdef DEBUG
|
||||
puts(" -debuglv # : debug level");
|
||||
@@ -252,11 +237,6 @@ static int check_fontdev(char *devname) {
|
||||
if (0 == strcmp(devname, "ft2")) {
|
||||
return FONT_FT2;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_X11FONT
|
||||
if (0 == strcmp(devname, "x11")) {
|
||||
return FONT_X11;
|
||||
}
|
||||
#endif
|
||||
return DEFAULT_FONT_DEVICE;
|
||||
}
|
||||
@@ -275,23 +255,8 @@ static void sys35_init() {
|
||||
ags_init();
|
||||
|
||||
for (i = 0; i < FONTTYPEMAX; i++) {
|
||||
switch(fontdev) {
|
||||
case FONT_FT2:
|
||||
case FONT_SDLTTF:
|
||||
nact->ags.font->name[i] = fontname_tt[i];
|
||||
nact->ags.font->face[i] = fontface[i];
|
||||
break;
|
||||
|
||||
case FONT_X11:
|
||||
if (fontname[i] == NULL) {
|
||||
nact->ags.font->name[i] = strdup(FONT_DEFAULTNAME_X);
|
||||
} else {
|
||||
nact->ags.font->name[i] = fontname[i];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
nact->ags.font->name[i] = fontname_tt[i];
|
||||
nact->ags.font->face[i] = fontface[i];
|
||||
}
|
||||
|
||||
ags_fullscreen(fs_on);
|
||||
@@ -364,8 +329,6 @@ static void sys35_ParseOption(int *argc, char **argv) {
|
||||
}
|
||||
fclose(fp);
|
||||
gameResourceFile = argv[i + 1];
|
||||
} else if (0 == strcmp(argv[i], "-no-shm")) {
|
||||
SetNoShmMode();
|
||||
} else if (0 == strcmp(argv[i], "-devcd")) {
|
||||
if (argv[i + 1] != NULL) {
|
||||
cd_set_devicename(argv[i + 1]);
|
||||
@@ -392,14 +355,6 @@ static void sys35_ParseOption(int *argc, char **argv) {
|
||||
if (argv[i + 1] != NULL) {
|
||||
fontdev = check_fontdev(argv[i + 1]);
|
||||
}
|
||||
} else if (0 == strcmp(argv[i], "-font_gothic")) {
|
||||
if (argv[i + 1] != NULL) {
|
||||
fontname[FONT_GOTHIC] = argv[i + 1];
|
||||
}
|
||||
} else if (0 == strcmp(argv[i], "-font_mincho")) {
|
||||
if (argv[i + 1] != NULL) {
|
||||
fontname[FONT_MINCHO] = argv[i + 1];
|
||||
}
|
||||
} else if (0 == strcmp(argv[i], "-ttfont_gothic")) {
|
||||
if (argv[i + 1] != NULL) {
|
||||
fontname_tt[FONT_GOTHIC] = argv[i + 1];
|
||||
@@ -429,16 +384,6 @@ static void check_profile() {
|
||||
if (param) {
|
||||
fontdev = check_fontdev(param);
|
||||
}
|
||||
/* ゴシックフォントの設定 */
|
||||
param = get_profile("font_gothic");
|
||||
if (param) {
|
||||
fontname[FONT_GOTHIC] = param;
|
||||
}
|
||||
/* 明朝フォントの設定 */
|
||||
param = get_profile("font_mincho");
|
||||
if (param) {
|
||||
fontname[FONT_MINCHO] = param;
|
||||
}
|
||||
/* ゴシックフォント(TT)の設定 */
|
||||
param = get_profile("ttfont_gothic");
|
||||
if (param) {
|
||||
@@ -496,13 +441,6 @@ static void check_profile() {
|
||||
}
|
||||
midi_set_output_device(*param | subdev);
|
||||
}
|
||||
/* no-shm flag */
|
||||
param = get_profile("no_shm");
|
||||
if (param) {
|
||||
if (0 == strcmp(param, "Yes")) {
|
||||
SetNoShmMode();
|
||||
}
|
||||
}
|
||||
/* disable image cursor */
|
||||
param = get_profile("no_imagecursor");
|
||||
if (param) {
|
||||
|
||||
Reference in New Issue
Block a user