マウスオーバー効果の完了
This commit is contained in:
@@ -384,6 +384,14 @@ redraw:
|
|||||||
control_expose(window, labels, &(SuwaButton){0});
|
control_expose(window, labels, &(SuwaButton){0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset_mouse_hover(SuwaWindow *window, CtrlLabels *labels) {
|
||||||
|
if (!lasthover) return;
|
||||||
|
lasthover->hovered = 0;
|
||||||
|
lasthover = NULL;
|
||||||
|
window->event = (XEvent){.type = Expose};
|
||||||
|
control_expose(window, labels, &(SuwaButton){0});
|
||||||
|
}
|
||||||
|
|
||||||
void handle_mouse_hover(SuwaWindow *window, CtrlLabels *labels, int mx, int my) {
|
void handle_mouse_hover(SuwaWindow *window, CtrlLabels *labels, int mx, int my) {
|
||||||
SuwaButton *btn = find_button_at(window, mx, my);
|
SuwaButton *btn = find_button_at(window, mx, my);
|
||||||
if (!btn) return;
|
if (!btn) return;
|
||||||
|
|||||||
@@ -47,4 +47,5 @@ void control_expose(SuwaWindow *window, CtrlLabels *labels, SuwaButton *button);
|
|||||||
void handle_button_press(SuwaWindow *window, CtrlLabels *labels, int mx, int my);
|
void handle_button_press(SuwaWindow *window, CtrlLabels *labels, int mx, int my);
|
||||||
void handle_button_release(SuwaWindow *window, CtrlLabels *labels, int mx, int my);
|
void handle_button_release(SuwaWindow *window, CtrlLabels *labels, int mx, int my);
|
||||||
void handle_key_press(SuwaWindow *window, CtrlLabels *labels);
|
void handle_key_press(SuwaWindow *window, CtrlLabels *labels);
|
||||||
|
void reset_mouse_hover(SuwaWindow *window, CtrlLabels *labels);
|
||||||
void handle_mouse_hover(SuwaWindow *window, CtrlLabels *labels, int mx, int my);
|
void handle_mouse_hover(SuwaWindow *window, CtrlLabels *labels, int mx, int my);
|
||||||
|
|||||||
@@ -334,6 +334,8 @@ __attribute__((unused)) static SuwaWindow suwaui_create_window(int x, int y, int
|
|||||||
| KeyPressMask
|
| KeyPressMask
|
||||||
| PointerMotionMask
|
| PointerMotionMask
|
||||||
| Button1MotionMask
|
| Button1MotionMask
|
||||||
|
| EnterWindowMask
|
||||||
|
| LeaveWindowMask
|
||||||
// | StructureNotifyMask
|
// | StructureNotifyMask
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
10
main.c
10
main.c
@@ -113,7 +113,10 @@ int main() {
|
|||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
Time now = window.event.xmotion.time;
|
Time now = window.event.xmotion.time;
|
||||||
if (now - lasthovertime < 40) break;
|
if (now - lasthovertime < 40) break;
|
||||||
|
if (now - lasthovertime > 80) {
|
||||||
|
reset_mouse_hover(&window, &lbl);
|
||||||
lasthovertime = now;
|
lasthovertime = now;
|
||||||
|
}
|
||||||
Window root, child;
|
Window root, child;
|
||||||
int root_x, root_y,
|
int root_x, root_y,
|
||||||
win_x, win_y;
|
win_x, win_y;
|
||||||
@@ -121,9 +124,14 @@ int main() {
|
|||||||
|
|
||||||
XQueryPointer(window.display, window.xwindow, &root, &child,
|
XQueryPointer(window.display, window.xwindow, &root, &child,
|
||||||
&root_x, &root_y, &win_x, &win_y, &mask);
|
&root_x, &root_y, &win_x, &win_y, &mask);
|
||||||
if (window.event.xmotion.state == 0) break;
|
if (window.event.xmotion.state == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
handle_mouse_hover(&window, &lbl, win_x, win_y);
|
handle_mouse_hover(&window, &lbl, win_x, win_y);
|
||||||
break;
|
break;
|
||||||
|
case LeaveNotify:
|
||||||
|
reset_mouse_hover(&window, &lbl);
|
||||||
|
break;
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
// WM_DELETE_WINDOW
|
// WM_DELETE_WINDOW
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user