Skip to content

Commit 7286514

Browse files
committed
GPU Display: Support middle mouse button
1 parent 18bc294 commit 7286514

6 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontend.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void GPUDisplayFrontend::focusLost()
214214
{
215215
std::fill(std::begin(mKeys), std::end(mKeys), false);
216216
std::fill(std::begin(mKeysShift), std::end(mKeysShift), false);
217-
mMouseDn = mMouseDnR = false;
217+
mMouseDn = mMouseDnR = mMouseDnM = false;
218218
}
219219

220220
void GPUDisplayFrontend::applyInitialWindowState()

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontend.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class GPUDisplayFrontend : public GPUDisplayFrontendInterface
124124
// Keyboard / Mouse actions
125125
bool mMouseDn = false; // Mouse button down
126126
bool mMouseDnR = false; // Right mouse button down
127+
bool mMouseDnM = false; // Middle mouse button down (not used yet)
127128
float mMouseDnX, mMouseDnY; // X/Y position where mouse button was pressed
128129
float mMouseMvX, mMouseMvY; // Current mouse pointer position
129130
int32_t mMouseWheel = 0; // Incremental value of mouse wheel, ca +/- 100 per wheel tick

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlfw.cxx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int32_t bu
207207
me->mMouseDn = true;
208208
} else if (button == 1) {
209209
me->mMouseDnR = true;
210+
} else if (button == GLFW_MOUSE_BUTTON_MIDDLE) {
211+
me->mMouseDnM = true;
210212
}
211213
me->mMouseDnX = me->mMouseMvX;
212214
me->mMouseDnY = me->mMouseMvY;
@@ -215,6 +217,8 @@ void GPUDisplayFrontendGlfw::mouseButton_callback(GLFWwindow* window, int32_t bu
215217
me->mMouseDn = false;
216218
} else if (button == 1) {
217219
me->mMouseDnR = false;
220+
} else if (button == GLFW_MOUSE_BUTTON_MIDDLE) {
221+
me->mMouseDnM = false;
218222
}
219223
}
220224
}

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendGlut.cxx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ void GPUDisplayFrontendGlut::mouseFunc(int32_t button, int32_t state, int32_t x,
195195
me->mMouseDn = true;
196196
} else if (button == GLUT_RIGHT_BUTTON) {
197197
me->mMouseDnR = true;
198+
} else if (button == GLUT_MIDDLE_BUTTON) {
199+
me->mMouseDnM = true;
198200
}
199201
me->mMouseDnX = x;
200202
me->mMouseDnY = y;
@@ -203,6 +205,8 @@ void GPUDisplayFrontendGlut::mouseFunc(int32_t button, int32_t state, int32_t x,
203205
me->mMouseDn = false;
204206
} else if (button == GLUT_RIGHT_BUTTON) {
205207
me->mMouseDnR = false;
208+
} else if (button == GLUT_MIDDLE_BUTTON) {
209+
me->mMouseDnM = false;
206210
}
207211
}
208212
}

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
158158
};
159159
auto pointer_leave = [](void* data, wl_pointer* wl_pointer, uint32_t serial, wl_surface* wl_surface) {
160160
GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data;
161-
me->mMouseDn = me->mMouseDnR = false;
161+
me->mMouseDn = me->mMouseDnR = me->mMouseDnM = false;
162162
};
163163
auto pointer_motion = [](void* data, wl_pointer* wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
164164
GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data;
@@ -172,6 +172,8 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
172172
me->mMouseDnR = true;
173173
} else if (button == BTN_LEFT) {
174174
me->mMouseDn = true;
175+
} else if (button == BTN_MIDDLE) {
176+
me->mMouseDnM = true;
175177
}
176178
me->mMouseDnX = me->mMouseMvX;
177179
me->mMouseDnY = me->mMouseMvY;
@@ -180,6 +182,8 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
180182
me->mMouseDnR = false;
181183
} else if (button == BTN_LEFT) {
182184
me->mMouseDn = false;
185+
} else if (button == BTN_MIDDLE) {
186+
me->mMouseDnM = false;
183187
}
184188
}
185189
};

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendX11.cxx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ int32_t GPUDisplayFrontendX11::FrontendMain()
349349
} else {
350350
if (event.xbutton.button == 1) {
351351
mMouseDn = true;
352+
} else if (event.xbutton.button == 2) {
353+
mMouseDnM = true;
352354
} else {
353355
mMouseDnR = true;
354356
}
@@ -362,6 +364,8 @@ int32_t GPUDisplayFrontendX11::FrontendMain()
362364
if (event.xbutton.button != 4 && event.xbutton.button != 5) {
363365
if (event.xbutton.button == 1) {
364366
mMouseDn = false;
367+
} else if (event.xbutton.button == 2) {
368+
mMouseDnM = false;
365369
} else {
366370
mMouseDnR = false;
367371
}

0 commit comments

Comments
 (0)