From: Holger Schemel Date: Sun, 10 Jan 1999 04:20:01 +0000 (+0100) Subject: rnd-19990110-1 X-Git-Tag: 1.3.0^2~29 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=403fa67c24301d440ae0871c2e31e1e395133a41;p=rocksndiamonds.git rnd-19990110-1 --- diff --git a/src/buttons.c b/src/buttons.c index 8df941b2..c8a380ff 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1549,7 +1549,13 @@ static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my) return gi; } -static void default_callback_function(void *ptr) +static void default_callback_info(void *ptr) +{ + if (game_status == LEVELED) + HandleEditorGadgetInfoText(ptr); +} + +static void default_callback_action(void *ptr) { return; } @@ -1564,8 +1570,9 @@ struct GadgetInfo *CreateGadget(int first_tag, ...) /* always start with reliable default values */ memset(new_gadget, 0, sizeof(struct GadgetInfo)); /* zero all fields */ - new_gadget->id = getNewGadgetID(); /* new gadget id */ - new_gadget->callback = default_callback_function; /* dummy function */ + new_gadget->id = getNewGadgetID(); + new_gadget->callback_info = default_callback_info; + new_gadget->callback_action = default_callback_action; while (tag != GDI_END) { @@ -1575,6 +1582,10 @@ struct GadgetInfo *CreateGadget(int first_tag, ...) new_gadget->custom_id = va_arg(ap, int); break; + case GDI_DESCRIPTION_TEXT: + new_gadget->description_text = va_arg(ap, char *); + break; + case GDI_X: new_gadget->x = va_arg(ap, int); break; @@ -1737,8 +1748,12 @@ struct GadgetInfo *CreateGadget(int first_tag, ...) new_gadget->scrollbar.item_position = va_arg(ap, int); break; - case GDI_CALLBACK: - new_gadget->callback = va_arg(ap, gadget_callback_function); + case GDI_CALLBACK_INFO: + new_gadget->callback_info = va_arg(ap, gadget_function); + break; + + case GDI_CALLBACK_ACTION: + new_gadget->callback_action = va_arg(ap, gadget_function); break; default: @@ -2011,6 +2026,7 @@ static struct GadgetInfo *last_gi = NULL; void HandleGadgets(int mx, int my, int button) { + static struct GadgetInfo *last_info_gi = NULL; static unsigned long pressed_delay = 0; static int last_button = 0; static int last_mx = 0, last_my = 0; @@ -2027,6 +2043,7 @@ void HandleGadgets(int mx, int my, int button) boolean gadget_released; boolean gadget_released_inside; boolean gadget_released_off_borders; + boolean changed_position = FALSE; /* check if there are any gadgets defined */ if (gadget_list_first_entry == NULL) @@ -2054,7 +2071,7 @@ void HandleGadgets(int mx, int my, int button) DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); if (gi->event_mask & GD_EVENT_TEXT_LEAVING) - gi->callback(gi); + gi->callback_action(gi); last_gi = NULL; } @@ -2088,18 +2105,36 @@ void HandleGadgets(int mx, int my, int button) if (button == 0 && last_gi && last_gi->type != GD_TYPE_TEXTINPUT) last_gi = NULL; - if (gi) + if (new_gi) { - gi->event.x = mx - gi->x; - gi->event.y = my - gi->y; + int last_x = new_gi->event.x; + int last_y = new_gi->event.y; - if (gi->type == GD_TYPE_DRAWING_AREA) + new_gi->event.x = mx - new_gi->x; + new_gi->event.y = my - new_gi->y; + + if (new_gi->type == GD_TYPE_DRAWING_AREA) { - gi->event.x /= gi->drawing.item_xsize; - gi->event.y /= gi->drawing.item_ysize; + new_gi->event.x /= new_gi->drawing.item_xsize; + new_gi->event.y /= new_gi->drawing.item_ysize; + + if (last_x != new_gi->event.x || last_y != new_gi->event.y) + changed_position = TRUE; } } + /* handle gadget popup info text */ + if (last_info_gi != new_gi || + (new_gi && new_gi->type == GD_TYPE_DRAWING_AREA)) + { + last_info_gi = new_gi; + + if (new_gi != NULL) + new_gi->callback_info(new_gi); + else + default_callback_info(NULL); + } + if (gadget_pressed) { if (gi->type == GD_TYPE_RADIO_BUTTON) @@ -2150,7 +2185,8 @@ void HandleGadgets(int mx, int my, int button) struct GadgetScrollbar *gs = &gi->scrollbar; int old_item_position = gs->item_position; - boolean changed_position = FALSE; + + changed_position = FALSE; gs->item_position += gs->items_visible * (mpos < gpos + gi->scrollbar.position ? -1 : +1); @@ -2173,7 +2209,7 @@ void HandleGadgets(int mx, int my, int button) gi->event.off_borders = FALSE; if (gi->event_mask & GD_EVENT_MOVING && changed_position) - gi->callback(gi); + gi->callback_action(gi); /* don't handle this scrollbar anymore while mouse button pressed */ last_gi = NULL; @@ -2194,20 +2230,18 @@ void HandleGadgets(int mx, int my, int button) DelayReached(&pressed_delay, GADGET_FRAME_DELAY); if (gi->event_mask & GD_EVENT_PRESSED) - gi->callback(gi); + gi->callback_action(gi); } if (gadget_pressed_repeated) { if (gi->event_mask & GD_EVENT_REPEATED && DelayReached(&pressed_delay, GADGET_FRAME_DELAY)) - gi->callback(gi); + gi->callback_action(gi); } if (gadget_moving) { - boolean changed_position = FALSE; - if (gi->type & GD_TYPE_BUTTON) { if (gadget_moving_inside && gi->state == GD_BUTTON_UNPRESSED) @@ -2239,9 +2273,6 @@ void HandleGadgets(int mx, int my, int button) DrawGadget(gi, DG_PRESSED, DG_DIRECT); } - if (gi->type == GD_TYPE_DRAWING_AREA) - changed_position = TRUE; - gi->state = (gadget_moving_inside || gi->type & GD_TYPE_SCROLLBAR ? GD_BUTTON_PRESSED : GD_BUTTON_UNPRESSED); gi->event.type = GD_EVENT_MOVING; @@ -2249,7 +2280,7 @@ void HandleGadgets(int mx, int my, int button) if (gi->event_mask & GD_EVENT_MOVING && changed_position && (gadget_moving_inside || gi->event_mask & GD_EVENT_OFF_BORDERS)) - gi->callback(gi); + gi->callback_action(gi); } if (gadget_released_inside) @@ -2261,7 +2292,7 @@ void HandleGadgets(int mx, int my, int button) gi->event.type = GD_EVENT_RELEASED; if (gi->event_mask & GD_EVENT_RELEASED) - gi->callback(gi); + gi->callback_action(gi); } if (gadget_released_off_borders) @@ -2273,7 +2304,7 @@ void HandleGadgets(int mx, int my, int button) if (gi->event_mask & GD_EVENT_RELEASED && gi->event_mask & GD_EVENT_OFF_BORDERS) - gi->callback(gi); + gi->callback_action(gi); } } @@ -2305,7 +2336,7 @@ void HandleGadgetsKeyInput(KeySym key) DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); if (gi->event_mask & GD_EVENT_TEXT_RETURN) - gi->callback(gi); + gi->callback_action(gi); last_gi = NULL; } diff --git a/src/buttons.h b/src/buttons.h index b5ca564b..5d5b2ac3 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -329,14 +329,16 @@ int CheckCountButtons(int, int, int); #define GDI_DESIGN_BORDER 19 #define GDI_EVENT_MASK 20 #define GDI_EVENT 21 -#define GDI_CALLBACK 22 -#define GDI_AREA_SIZE 23 -#define GDI_ITEM_SIZE 24 -#define GDI_SCROLLBAR_ITEMS_MAX 25 -#define GDI_SCROLLBAR_ITEMS_VISIBLE 26 -#define GDI_SCROLLBAR_ITEM_POSITION 27 +#define GDI_CALLBACK_INFO 22 +#define GDI_CALLBACK_ACTION 23 +#define GDI_AREA_SIZE 24 +#define GDI_ITEM_SIZE 25 +#define GDI_SCROLLBAR_ITEMS_MAX 26 +#define GDI_SCROLLBAR_ITEMS_VISIBLE 27 +#define GDI_SCROLLBAR_ITEM_POSITION 28 +#define GDI_DESCRIPTION_TEXT 29 -typedef void (*gadget_callback_function)(void *); +typedef void (*gadget_function)(void *); struct GadgetDesign { @@ -375,6 +377,7 @@ struct GadgetInfo { int id; /* internal gadget identifier */ int custom_id; /* custom gadget identifier */ + char *description_text; /* short text describing gadget */ int x, y; /* gadget position */ int width, height; /* gadget size */ unsigned long type; /* type (button, text input, ...) */ @@ -390,7 +393,8 @@ struct GadgetInfo int design_border; /* border size of gadget decoration */ unsigned long event_mask; /* possible events for this gadget */ struct GadgetEvent event; /* actual gadget event */ - gadget_callback_function callback; + gadget_function callback_info; /* function for pop-up info text */ + gadget_function callback_action; /* function for gadget action */ struct GadgetDrawingArea drawing; /* fields for drawing area gadget */ struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */ struct GadgetInfo *next; /* next list entry */ diff --git a/src/editor.c b/src/editor.c index 2ec6a80c..b6ae1b0c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -74,6 +74,7 @@ /* values for properties window */ #define ED_PROPERTIES_XPOS (TILEX - MINI_TILEX/2) + /* values for counter gadgets */ #define ED_COUNT_VALUE_XOFFSET 5 #define ED_COUNT_VALUE_YOFFSET 3 @@ -173,6 +174,32 @@ #define UNDO_IMMEDIATE 0 #define UNDO_ACCUMULATE 1 +static char *control_infotext[ED_NUM_CTRL_BUTTONS] = +{ + "draw single items", + "draw connected items", + "draw lines", + "enter text elements", + "draw outline rectangles", + "draw filled boxes", + "wrap (rotate) level up", + "properties of drawing element", + "flood fill", + "wrap (rotate) level left", + "", + "wrap (rotate) level right", + "random element placement", + "grab brush", + "wrap (rotate) level down", + "pick drawing element from editing area", + "undo last operation", + "level properties", + "save level", + "clear level", + "test level", + "exit level editor", +}; + static struct { int x, y; @@ -188,16 +215,29 @@ static struct int xpos, ypos; int x, y; int gadget_id; + char *text; } scrollbutton_info[ED_NUM_SCROLLBUTTONS] = { - { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, ED_CTRL_ID_SCROLL_UP }, - { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, ED_CTRL_ID_SCROLL_DOWN }, - { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, ED_CTRL_ID_SCROLL_LEFT }, - { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, ED_CTRL_ID_SCROLL_RIGHT } + { + ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, + ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, ED_CTRL_ID_SCROLL_UP, + "scroll level editing area up" + }, + { + ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, + ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, ED_CTRL_ID_SCROLL_DOWN, + "scroll level editing area down" + }, + { + ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, + ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, ED_CTRL_ID_SCROLL_LEFT, + "scroll level editing area left" + }, + { + ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, + ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, ED_CTRL_ID_SCROLL_RIGHT, + "scroll level editing area right" + } }; static struct @@ -207,18 +247,25 @@ static struct int width, height; int type; int gadget_id; + char *text; } scrollbar_info[ED_NUM_SCROLLBARS] = { - { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, + { + ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, ED_SCROLL_VERTICAL_XPOS, ED_SCROLL_VERTICAL_YPOS, ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, - ED_CTRL_ID_SCROLL_VERTICAL }, - { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, + ED_CTRL_ID_SCROLL_VERTICAL, + "scroll level editing area vertically" + }, + { + ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, ED_SCROLL_HORIZONTAL_XPOS, ED_SCROLL_HORIZONTAL_YPOS, ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, GD_TYPE_SCROLLBAR_HORIZONTAL, - ED_CTRL_ID_SCROLL_HORIZONTAL }, + ED_CTRL_ID_SCROLL_HORIZONTAL, + "scroll level editing area horizontally" + }, }; @@ -229,6 +276,7 @@ static void CopyLevelToUndoBuffer(int); static void HandleControlButtons(struct GadgetInfo *); static void HandleCounterButtons(struct GadgetInfo *); static void HandleDrawingAreas(struct GadgetInfo *); +static void HandleDrawingAreaInfo(struct GadgetInfo *); static void HandleTextInputGadgets(struct GadgetInfo *); static struct GadgetInfo *level_editor_gadget[ED_NUM_GADGETS]; @@ -744,6 +792,7 @@ static void CreateControlButtons() gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_ALT_GFX_YPOS + gd_yoffset; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_DESCRIPTION_TEXT, control_infotext[i], GDI_X, EX + gd_xoffset, GDI_Y, EY + gd_yoffset, GDI_WIDTH, width, @@ -757,7 +806,7 @@ static void CreateControlButtons() GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2, GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleControlButtons, + GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); if (gi == NULL) @@ -779,6 +828,7 @@ static void CreateControlButtons() gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_DESCRIPTION_TEXT, scrollbutton_info[i].text, GDI_X, SX + scrollbutton_info[i].x, GDI_Y, SY + scrollbutton_info[i].y, GDI_WIDTH, ED_SCROLLBUTTON_XSIZE, @@ -788,7 +838,7 @@ static void CreateControlButtons() GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y, GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleControlButtons, + GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); if (gi == NULL) @@ -830,7 +880,7 @@ static void CreateCounterButtons() GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y, GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleCounterButtons, + GDI_CALLBACK_ACTION, HandleCounterButtons, GDI_END); if (gi == NULL) @@ -857,17 +907,12 @@ static void CreateDrawingAreas() gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_X, SX, GDI_Y, SY, - - /* - GDI_WIDTH, SXSIZE, - GDI_HEIGHT, SYSIZE, - */ - GDI_TYPE, GD_TYPE_DRAWING_AREA, GDI_AREA_SIZE, ED_FIELDX, ED_FIELDY, GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleDrawingAreas, + GDI_CALLBACK_INFO, HandleDrawingAreaInfo, + GDI_CALLBACK_ACTION, HandleDrawingAreas, GDI_END); if (gi == NULL) @@ -890,7 +935,8 @@ static void CreateDrawingAreas() GDI_TYPE, GD_TYPE_DRAWING_AREA, GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleDrawingAreas, + GDI_CALLBACK_INFO, HandleDrawingAreaInfo, + GDI_CALLBACK_ACTION, HandleDrawingAreas, GDI_END); if (gi == NULL) @@ -909,7 +955,8 @@ static void CreateDrawingAreas() GDI_TYPE, GD_TYPE_DRAWING_AREA, GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleDrawingAreas, + GDI_CALLBACK_INFO, HandleDrawingAreaInfo, + GDI_CALLBACK_ACTION, HandleDrawingAreas, GDI_END); if (gi == NULL) @@ -942,7 +989,7 @@ static void CreateTextInputGadgets() GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y, GDI_DESIGN_BORDER, 3, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleTextInputGadgets, + GDI_CALLBACK_ACTION, HandleTextInputGadgets, GDI_END); if (gi == NULL) @@ -985,6 +1032,7 @@ static void CreateScrollbarGadgets() gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_DESCRIPTION_TEXT, scrollbar_info[i].text, GDI_X, SX + scrollbar_info[i].x, GDI_Y, SY + scrollbar_info[i].y, GDI_WIDTH, scrollbar_info[i].width, @@ -998,7 +1046,7 @@ static void CreateScrollbarGadgets() GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2, GDI_DESIGN_BORDER, 3, GDI_EVENT_MASK, event_mask, - GDI_CALLBACK, HandleControlButtons, + GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); if (gi == NULL) @@ -1388,6 +1436,29 @@ void AdjustLevelScrollPosition() level_ypos = -1; } +void AdjustEditorScrollbar(int id) +{ + struct GadgetInfo *gi = level_editor_gadget[id]; + struct GadgetScrollbar *gs = &gi->scrollbar; + int items_max, items_visible, item_position = gs->item_position; + + if (id == ED_CTRL_ID_SCROLL_HORIZONTAL) + { + items_max = lev_fieldx + 2; + items_visible = ED_FIELDX; + } + else + { + items_max = lev_fieldy + 2; + items_visible = ED_FIELDY; + } + + if (item_position > items_max - items_visible) + item_position = items_max - items_visible; + + AdjustScrollbar(gi, items_max, item_position); +} + static void PickDrawingElement(int button, int element) { if (button < 1 || button > 3) @@ -2098,9 +2169,11 @@ static void DrawDrawingWindow() { ClearWindow(); UnmapLevelEditorWindowGadgets(); - MapMainDrawingArea(); AdjustLevelScrollPosition(); + AdjustEditorScrollbar(ED_CTRL_ID_SCROLL_HORIZONTAL); + AdjustEditorScrollbar(ED_CTRL_ID_SCROLL_VERTICAL); DrawMiniLevel(level_xpos, level_ypos); + MapMainDrawingArea(); } static void DrawElementContentAreas() @@ -3418,3 +3491,58 @@ static void HandleTextInputGadgets(struct GadgetInfo *gi) break; } } + +/* values for ClearEditorGadgetInfoText() and HandleGadgetInfoText() */ +#define INFOTEXT_XPOS SX +#define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2) +#define INFOTEXT_XSIZE SXSIZE +#define INFOTEXT_YSIZE MINI_TILEX +#define MAX_INFOTEXT_LEN (SXSIZE / FONT2_XSIZE) + +void ClearEditorGadgetInfoText() +{ + XFillRectangle(display, drawto, gc, + INFOTEXT_XPOS, INFOTEXT_YPOS, INFOTEXT_XSIZE, INFOTEXT_YSIZE); + redraw_mask |= REDRAW_FIELD; +} + +void HandleEditorGadgetInfoText(void *ptr) +{ + struct GadgetInfo *gi = (struct GadgetInfo *)ptr; + char infotext[MAX_INFOTEXT_LEN + 1]; + + ClearEditorGadgetInfoText(); + + if (gi == NULL || gi->description_text == NULL) + return; + + strncpy(infotext, gi->description_text, MAX_INFOTEXT_LEN); + infotext[MAX_INFOTEXT_LEN] = '\0'; + + DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FS_SMALL, FC_YELLOW); +} + +static void HandleDrawingAreaInfo(struct GadgetInfo *gi) +{ + int id = gi->custom_id; + int sx = gi->event.x; + int sy = gi->event.y; + int lx = sx + level_xpos; + int ly = sy + level_ypos; + + ClearEditorGadgetInfoText(); + + if (id == ED_CTRL_ID_DRAWING_LEVEL) + { + if (IN_LEV_FIELD(lx, ly)) + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + "Level: %d, %d (Screen: %d, %d)", lx, ly, sx, sy); + } + else if (id == ED_CTRL_ID_AMOEBA_CONTENT) + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + "Amoeba content"); + else + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + "Cruncher %d content: %d, %d", id - ED_CTRL_ID_ELEMCONT_0 + 1, + sx, sy); +} diff --git a/src/editor.h b/src/editor.h index f9967014..665ff1b8 100644 --- a/src/editor.h +++ b/src/editor.h @@ -30,5 +30,6 @@ void DrawLevelEd(void); void LevelEd(int, int, int); void HandleLevelEditorKeyInput(KeySym); void LevelNameTyping(KeySym); +void HandleEditorGadgetInfoText(void *ptr); #endif diff --git a/src/events.c b/src/events.c index b9e4e9a2..15106c87 100644 --- a/src/events.c +++ b/src/events.c @@ -226,9 +226,21 @@ void HandleButtonEvent(XButtonEvent *event) void HandleMotionEvent(XMotionEvent *event) { + Window root, child; + int root_x, root_y; + int win_x, win_y; + unsigned int mask; + + if (!XQueryPointer(display, window, &root, &child, &root_x, &root_y, + &win_x, &win_y, &mask)) + return; + + if (!button_status && game_status != LEVELED) + return; + motion_status = TRUE; - HandleButton(event->x, event->y, button_status); + HandleButton(win_x, win_y, button_status); } void HandleKeyEvent(XKeyEvent *event) diff --git a/src/init.c b/src/init.c index 0711f651..b8e6704e 100644 --- a/src/init.c +++ b/src/init.c @@ -436,9 +436,11 @@ void InitWindow(int argc, char *argv[]) XFree(iconName.value); /* Select event types wanted */ - window_event_mask = ExposureMask | StructureNotifyMask | FocusChangeMask | - ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | - KeyPressMask | KeyReleaseMask; + window_event_mask = + ExposureMask | StructureNotifyMask | FocusChangeMask | + ButtonPressMask | ButtonReleaseMask | PointerMotionMask | + PointerMotionHintMask | KeyPressMask | KeyReleaseMask; + XSelectInput(display, window, window_event_mask); #endif